问题
My build requires that I issue the following commands:
$ g++ sniff.cpp -o sniff -lcrafter
However, in my Eclipse build, all the complier gets is:
g++ -o "sniffer_crafter" ./src/sniffer_crafter.o
After getting these commands it complains that I have an undefined reference to the library Crafter.
How can I resolve this linking issue using Eclipse? I have seen others answers to similar questions, but they don't seem to address Eclipse's current layout. I'm using the most recent edition of Eclipse Kepler.
回答1:
Include libraries:-
right click on the project -->
- Goto Properties
- then goto --> C/C++ Build --> Settings
There you will find Linker and sub type Libraries.
Add the library path in Library Search Path on right hand side (where your .so file is located) and give the lib name in libraries
for libcrafter.so path --> /opt/myLib/lib
give path as /opt/myLib/lib and library name as crafter
来源:https://stackoverflow.com/questions/19502795/compiler-flags-in-eclipse