I have created a shared library, copied it to /usr/lib, run ldconfig (it shows up on the list when run with -v) and copied the .h file into /usr/include. However when I try and use the lib #include , i get "Undefined Reference to 'Method1'. What an I doing wrong? My makefile has no special commands as all files are in the standard places.
Asked
Active
Viewed 44 times
-1
-
linker's not magic. Use `-lMyLibrary` (lowercase L) to tell the linker to look for symbols in your library. – Oct 04 '13 at 10:20
1 Answers
0
#include
will include the header file when you compile your source code.
However you also need to link to your shared library. For most unix compilers, that is done with the -l flag
For a shared library with the name libFoo.so
, use the flag -lFoo
when linking your program.

nos
- 223,662
- 58
- 417
- 506
-
I was trying to be clever and included the #pragma GCC visibility(hidden) around the whole file and this removed the functions I needed to be exposed - user error as usual! – user2810158 Oct 04 '13 at 10:47