How to help cmake find boost library


#1

I try to install Manta which is an awesome bioinformatics tool. It uses cmake, and it fails when searching for boost dependencies with following debug printout:

<snip>
 [ /nix/store/5whgp9dvpyzgj5mm0avhgf10kddl0nqm-cmake-3.10.2/share/cmake-3.10/Modules/FindBoost.cmake:1641 ] Searching for DATE_TIME_LIBRARY_RELEASE: boost_date_time-gcc73-1_59;boost_date_time-gcc73;boost_date_time-1_59;boost_date_time;boost_date_time
-- [ /nix/store/5whgp9dvpyzgj5mm0avhgf10kddl0nqm-cmake-3.10.2/share/cmake-3.10/Modules/FindBoost.cmake:1692 ] Searching for DATE_TIME_LIBRARY_DEBUG: boost_date_time-gcc73-d-1_59;boost_date_time-gcc73-d;boost_date_time-d-1_59;boost_date_time-d;boost_date_time;boost_date_time
-- [ /nix/store/5whgp9dvpyzgj5mm0avhgf10kddl0nqm-cmake-3.10.2/share/cmake-3.10/Modules/FindBoost.cmake:1641 ] Searching for FILESYSTEM_LIBRARY_RELEASE: boost_filesystem-gcc73-1_59;boost_filesystem-gcc73;boost_filesystem-1_59;boost_filesystem;boost_filesystem
<snip>

The strange thing is that it finds some of them:

-- Boost component: date_time   status: STATIC LIBRARY NOT FOUND
-- Boost component: filesystem  status: STATIC LIBRARY NOT FOUND
-- Boost component: program_options     status: STATIC LIBRARY NOT FOUND
-- Boost component: regex       status: STATIC LIBRARY NOT FOUND
-- Boost component: serialization       status: STATIC LIBRARY NOT FOUND
-- Boost component: system      status: found
-- Boost component: timer       status: found
-- Boost component: chrono      status: found
-- Boost component: unit_test_framework status: STATIC LIBRARY NOT FOUND

I have tried a lot of things, what concerns me is that it seems it tries to look for boost_date_time instead of the actual name that is located in ${boost}/lib which is libboost_date_time. The libs it finds also have the lib prefix, so don’t know if that actually is the reason …

Currently the default.nix looks like this:

The boost.cmake file that is being used looks like this (I’ve patched it to 1.59.0 that should be ok)

Any idea how to move from here? I am pretty new to nix, but I have a lot of bionformatic tools I’d like to add (as you can see in the project, some of them compile already! ). Any help would be highly appreciated.


#2

You posted the cmake file twice. Can you post the nix file? Are you using nixos?


#3

Sorry don’t know what happened … The link gets changed by itself it seems, I’ll add it again here:

Yes I’m using nixos, 18.03 :slight_smile:


#4
  1. Try adding pkgconfig package to nativeBuildInputs.

  2. Normally, libraries shouldn’t go to nativeBuildInputs—it is for
    tools used on your host during the build. (i.e., boost and zlib should
    go to buildInputs.)


#5

Thanks a lot @rasendubi, I’ve fixed the wrong usage between nativeBuildInputs and buildInputs I hope. I’ve also found what seems to be the error. For the libraries it finds, i.e. system, timer and chrono. There is a .a file in the lib folder, we have system.a etc. These are missing for the other ones. There is only the .so lib files.

How could I solve this? The easy but dirty way I know of, would be to override the boost derivation to also emit these libs with a .a file. However, is there a more nix idiomatic way of doing this? Also, the boost derivation looks a bit messy, I guess that is because of boost it self …


#6

Tried to just convert the .so libs to .a archives with ar. That did not work it seems, I get the following error:

/nix/store/hwwqshlmazzjzj7yhrkyjydxamvvkfd3-glibc-2.26-131/lib/crt1.o: In function `_start':
/build/glibc-2.26/csu/../sysdeps/x86_64/start.S:110: undefined reference to `main'
collect2: error: ld returned 1 exit status
make[2]: *** [src/c++/lib/applications/GenerateSVCandidates/test/CMakeFiles/manta_unit_test_GenerateSVCandidates.dir/build.make:221: src/c++/lib/applications/GenerateSVCandidates/test/manta_unit_test_GenerateSVCandidates] Error 1
make[1]: *** [CMakeFiles/Makefile2:2030: src/c++/lib/applications/GenerateSVCandidates/test/CMakeFiles/manta_unit_test_GenerateSVCandidates.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
builder for '/nix/store/kpzalas741aiafsakzjsf8zlndbpmg2z-manta.drv' failed with exit code 2
error: build of '/nix/store/kpzalas741aiafsakzjsf8zlndbpmg2z-manta.drv' failed

Since it seems it compiles the tests to run, I suspect that the generated .a files does not contain whats needed. It is kind of expected though, .a files and .so files are not exactly the same …


#7

Try using

pkgs.boost.override { enableShared = false; enabledStatic = true; }

This should build static version of the boost library.


#8

Thanks again :slight_smile: I am learning a lot of new things here, and the boost library was a good thing to look at. I’ve been able to build it now, just a few more polishing steps I hope !

:slight_smile: