Fist i am confused should i set libraries under Linker/Libraries or to set them under "path and symbol". i think that they are the same. am i correct?
any way for my question - i need to link static library , so i tried few things:
First try I try to add gtest (this is the library) and gtest path in the link library. in this way its compiled and linked correct , but failed in runtime , because when it tried to load shared library (i want static library !) error is
error while loading shared libraries: libgtest.so.0
Second try - I try do define it in path and symbol add to libraries the complete path '/root/workspace/gmock/gtest/lib/.lib/libgtest.a' . in this case i got error in the linkage :
g++ -L/root/workspace/gmock/lib/.libs -L/root/workspace/gmock/gtest/lib/.libs -o "playground" ./src/p.o ./src/playground.o -lpthread -l/root/workspace/gmock/gtest/lib/.lib/libgtest.a -l/root/workspace/gmock/lib/.lib/libgmock.a
/usr/bin/ld: cannot find -l/root/workspace/gmock/gtest/lib/.lib/libgtest.a
This post dosnt give an answer and not explain how you define differently linked against static vs shared.
Thank you
In computer science, a static library or statically-linked library is a set of routines, external functions and variables which are resolved in a caller at compile-time and copied into a target application by a compiler, linker, or binder, producing an object file and a stand-alone executable.
Similarly, to add a library file to be linked in Eclipse CDT: Right-click on the project name in Project Explorer, choose Properties > C/C++ Build > Settings > Tool Settings. Go to Cross G++ Linker > Libraries > Libraries. Click the + button and add the name of the library file, omit the file extension.
On Property Pages, go to C/C++->General->Additional Include Directories and provide the path, where the header file of the library that you want to use is located. Then go to Linker->General->Additional Library Directories and specify the path, where your . lib file is located.
Linking is performed when the input file are object files " .o " (instead of source file " . cpp " or " . c "). GCC uses a separate linker program (called ld.exe ) to perform the linking.
After lot of research and not related answer. found it!!! I found it in this useful link for eclipse-cdt
Apparently the library need to exist in the workspace.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With