Linking statically to 3rd party libraries (on linux) [message #765016] |
Tue, 13 December 2011 09:08 |
ben Messages: 7 Registered: December 2011 |
Junior Member |
|
|
It feels like I'm fighting my tools, so if my workflow is completely wrong, please let me know.
Here is my plan:
I find a 3rd party library, could be anything, let's say Google Protobufs, so I do this:
- Download it
- Check it into SVN
- Using Eclipse, check it out of SVN as a new autotools project
- Check it builds.
Then what I want to do is set it up so that it exports a bunch of stuff for dependent projects:
- Go into C/C++ General -> Export Settings
- Export the include directory (relative to workspace)
Now I get stuck.
I want to export something to tell the linker that any project that depends on this project must link to the libprotobuf.a I just built.
It's easy enough to specify a search directory and specify that I want to export protobuf as the library, but how I can be sure that it will link statically to that library? How can I be sure it will link to the library I just built rather than finding it in /usr/lib or whatever?
Instead of having a command line that looks like:
g++ -L"/pathToWorkspace/ptotobuf/lib" -lprotobuf
I want:
g++ /pathToWorkspace/ptotobuf/lib/libprotobuf.a
Now, the reason I want to statically link everything is so that I know what I'm dealing with and to ease deployment and development across multiple machines. I don't want to be writing .rpms or .debs or whatever and managing dependencies like that, I just want it all linked into my binary. Am I doing it wrong?
I'm a bit new to developing on linux and frankly I don't know what will happen if I decide to build my project with gcc 4.6.2 with -std=c++0x and link against a 3rd party library that could be built with gcc 4.4 and with no C++11 support. I guess it's fine if the library interface is C, but perhaps not if it's C++? Anyway, I'd rather avoid the whole issue by building and linking everything myself. Again, I might just be doing it wrong(TM).
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03623 seconds