6

I'm trying to compile and install boost 1.54 from source in CentOS.

The documentation is pretty straight forward and there are plenty of tutorials in the internet available (1) (2) (3). This is what I did:

wget http://sourceforge.net/projects/boost/files/boost/1.54.0/boost_1_54_0.tar.gz
tar -xzvf boost_1_54_0.tar.gz
cd boost_1_54_0
./bootstrap.sh --prefix=/usr/local
./b2 install --with=all

This is compiling and installing boost correctly to /usr/local/lib and everything looks fine.

Now I compile other software that requires boost using gcc and everything works fine. From my understanding everything should be OK as long as gcc finds the required libs.

But now the problem: If I run my compiled binaries I get the following error:

./myProgram
  ./myProgramm: error while loading shared libraries: libboost_system.so.1.54.0: cannot open shared object file: No such file or directory

Why can the libraries not be found?

In addition I tried:

ldconfig
locate boost
  [...]

But boost libraries can not be found. I've looked for the path manually, it is:

/usr/local/lib/libboost_system.so.1.54.0

I also tried to create symlinks to /usr/lib but this doesn't fix this either.

Any ideas? What can I do?

3
  • 1
    I'd generally recommend building from a suitably chosen source RPM. What CentOS version are you using? Nov 5, 2013 at 8:34
  • CentOS 6.4, I'm not used to this environment, I'm more the Debian/Gentoo guy. I might have a look into the RPMs too.
    – q9f
    Nov 5, 2013 at 8:37
  • I use Debian myself. But rebuilding an RPM is not hard. My recommendation is to find a source rpm for boost 1.54 for some version of CentOS. Presumably a more recent version than you are using. Then adjust for your version as necessary. Nov 5, 2013 at 9:05

3 Answers 3

6

You have to add -Wl,-R/usr/local/lib to the LDFLAGS when compiling your program.

-R is a linker option (for specifying a runtime linker path) - -Wl instructs gcc to pass it to ld.

With shared libraries you have to make sure that they are found by the linker during compile and during runtime (cf. flags -L and -R).

You can use

$ ldd myProgramm

to verify if the runtime-linker path was set correctly, i.e. if it can find the needed shared libraries on program start/which shared libraries it will load.

1
  • Setting LDFLAGS at compile time is just working great, thanks!
    – q9f
    Nov 5, 2013 at 8:36
1

As a workaround, I believe you can prefix the running of the executable with the environment variable LD_LIBRRAY_PATH and give it the path to the directory which contains the .so library.

Example

$ LD_LIBRARY_PATH=/usr/local/lib ./myProgram

But it sounds like the method you've used to compile the application in question is not correct. I'd need to see your compilation method for myProgram to be more specific.

2
  • Yeah that works indeed, thanks. But I guess I will have to recompile it with adjusted LDFLAGS.
    – q9f
    Nov 5, 2013 at 8:35
  • @qdoe - yes max's answer shows howto accomplish that!
    – slm
    Nov 5, 2013 at 8:44
0

Got boost 1.54 version installed in CentOS 7 with the below commands:

sudo wget http://repo.enetres.net/enetres.repo -O /etc/yum.repos.d/enetres.repo

Download the lib64icu42-4.2.1-1mdv2010.0.x86_64.rpm from the below link: ftp://fr2.rpmfind.net/linux/Mandriva/official/2010.0/x86_64/media/main/release/lib64icu42-4.2.1-1mdv2010.0.x86_64.rpm

Install the RPM:

sudo rpm -ivh lib64icu42-4.2.1-1mdv2010.0.x86_64.rpm

Install the required boost library version:

sudo yum install boost-devel-1.54.0

That's it. Have a great day!

rpm link: https://www.rpmfind.net/linux/rpm2html/search.php?query=libicuuc.so.42()(64bit)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .