3

I am trying to compile on a Ubuntu system where I have two different versions of boost instaled: 1.46.1 in /usr/lib/ and 1.61.0 in /usr/local/lib/.

I have stated that 1.61.0 is giving me some compilation issues, but I prefer not removing it to study the problem when I have more time. I supposed I could refer at the makefile to 1.46.1, using -I"/usr/include/boost" for 1.46.1 source, and then -L /usr/lib for the libraries. But still not working.

My suspicion is that the usage of -lboost_filesystem -lboost_system -lboost_date_time are somehow referencing to 1.61.0, even when used together with -L /usr/lib (which points to 1.46.1). But I have been unable to find information about this compilation flags for the linker.

How can I make sure those -l are referenced to the Boost version I want?

Here is an example of what the makefile is doing while linking (the part where it is failing):

Invoking: Cygwin C++ Linker
g++  -O0 -g3 -Wall -Wextra -o"../bin/MY_APP.exe" ../bin/objs/main.o ../bin/objs/FileLoad.o ../bin/objs/DatabaseLoad.o -L /usr/lib/mysql -L /usr/lib -lmysqlclient -lboost_filesystem -lboost_system -lboost_date_time  
Roman Rdgz
  • 12,836
  • 41
  • 131
  • 207
  • In CMake, you can ref to this [thick](https://stackoverflow.com/questions/3016448/how-can-i-get-cmake-to-find-my-alternative-boost-installation/62316896#62316896) – Kevin Chou Jun 11 '20 at 04:16

1 Answers1

1

You can confirm or disprove your suspicions by getting the linker to confess which libraries it is actually using. Add the option -Wl,--verbose to your g++ link command line (in the makefile or try this directly). The linker will then spit out which exact file was matched for everything it was trying to link, including your boost libraries.

If it turns out it is in fact linking the wrong versions, it also gives you a clue as to why exactly, by specifying the exact order of paths which the linker tries in locating a given library. This should give you some ammo should you need to change around some of your options (e.g. ordering and/or content of -L... and -l... options)

Should this fail, you can also use the option -l:/path/to/exact/libboost_whatever.so. This will force to use the linker the given version. I would try this last though.

Smeeheey
  • 9,906
  • 23
  • 39
  • They seem to be pointing to the right version, so my problem must be somewhere else. Nevertheless, this was all I wanted to know. Thanks for this piece of wisdom – Roman Rdgz Jun 03 '16 at 10:12