2

When using a library outside of the project, e.g. boost or Guidelines Support Library, how should we specify the paths related to that library?

  • add the paths to the LIBRARY_PATH and CPLUS_INCLUDE_PATH environment variables used by the compiler.

  • define a environment variable (e.g. GSL_PATH) and then
    add -L and -isystem flags in the makefile of each project.

Is there a best practice for this? What are the advantages and disadvantages of each approach? Consider the need to compile and use the project on other systems.

For various reasons the libraries are installed in a custom path

bolov
  • 72,283
  • 15
  • 145
  • 224
  • 1
    This is subjective, but—I strongly suggest using flags. Flags are explicit, and environment variables are more annoying to debug. If you use flags, you can copy a command out of a make invocation and run it in your terminal window. With environment variables, you can't. I'm currently working with a build system that uses lots of environment variables at work, and it's a total pain. – Dietrich Epp Feb 17 '16 at 11:06

1 Answers1

0

You can use cmake for configuring your project

And find boost and gsl with cmake

https://cmake.org/cmake/help/v3.2/module/FindGSL.html https://cmake.org/cmake/help/v3.0/module/FindBoost.html

Example for boost

Community
  • 1
  • 1