i made a shared library, linked it to a main program, but this main program cannot see any of the shared library methods, nor import it's headers. This is what i did:
g++ -c -fPIC -o objname.o objname.cpp -I"HeadersFolder"
g++ -shared -o libmylib.so obj1.o obj2.o etc.. etc..
g++ main.cpp -L. -lmylib
Now in this main i imported one of the lib headers, something like:
#include <Header.hpp>
And g++ tells me no such file or directory.
"Now in this main i imported one of the lib headers, something like: ..."
You also need to add the -I
option to compile main.cpp
in this case:
g++ main.cpp -I"HeadersFolder" -L. -lmylib
Also you should use
#include "Header.hpp" // Note the quotes "
the angle brackets ( <>
) are for including system headers (that could possibly collide with your own when the preprocessor evaluates them).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.