Advertisement
lignite

library template

Aug 21st, 2017
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. gcc -c -Wall -Werror -fPIC shared.cc  -shared -o libshared.so
  2. gcc -L. -Wall share.cc -o share -lshared
  3.  
  4. share.cc:
  5. #include<stdio.h>
  6. extern unsigned int add(unsigned int a, unsigned int b);
  7.  
  8. int main(void)
  9. {
  10.     unsigned int a = 1;
  11.     unsigned int b = 2;
  12.     unsigned int result = 0;
  13.  
  14.     result = add(a,b);
  15.  
  16.     printf("\n The result is [%u]\n",result);
  17.     return 0;
  18. }
  19.  
  20. shared.cc:
  21. #include<stdio.h>
  22. extern unsigned int add(unsigned int a, unsigned int b);
  23.  
  24. unsigned int add(unsigned int a, unsigned int b)
  25. {
  26.     printf("\n Inside add()\n");
  27.     return (a+b);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement