views:

46

answers:

1

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!

+1  A: 

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.

titanae
Thank you for your answer. It seems that whenever I build against a library, I should always specify the full path to that library as part of the build process, and only change the destination of the output based on which type of build I've created.
Nicholas Palko