In a cross-platform (Windows, FreeBSD) 开发者_运维百科C++ project I'm working on, I am making use of two external libraries, Protocol Buffers and ZeroMQ. In both projects, I am tracking the latest development branch, so these libraries are recompiled / replaced often.
For a development scenario, where is the best place to keep libprotobuf.{a,lib}
and zeromq.{so,dll}
? Should I have my build script copy them from their respective project directories into my local project's directory (say MyProjectRoot/lib
or MyProjectRoot/bin
) before I build my project? This seems preferable to tossing things into /usr/local/lib
, as I wouldn't want to replace a system-wide stable version with the latest experimental one.
Cmake warns me whenever I specify a relative path for linking, so I would suspect copying is a better solution then relative linking? Is this the best approach?
Thanks for your help!
I would suggest you don't copy files around in the source tree, and definitely not into the system folder, instead go for a defined target location -
- $BUILD_TARGET/bin - final binary destination (.exe/.so/.dll etc)
- $BUILD_TARGET/obj - object file destination (.obj etc)
- $BUILD_TARGET/lib - static library destination (.lib etc)
You can further develop this using optimization/debug targets -
DEBUG
- $BUILD_TARGET/binD - final binary destination (.exe/.so/.dll etc)
- $BUILD_TARGET/objD - object file destination (.obj etc)
- $BUILD_TARGET/libD - static library destination (.lib etc)
RELEASE (OPTIMIZED)
- $BUILD_TARGET/binO - final binary destination (.exe/.so/.dll etc)
- $BUILD_TARGET/objO - object file destination (.obj etc)
- $BUILD_TARGET/libO - static library destination (.lib etc)
The possibilities are endless, x86/x64 etc.
精彩评论