lczech / gappa

A toolkit for analyzing and visualizing phylogenetic (placement) data
GNU General Public License v3.0
56 stars 7 forks source link

Compiling error: cannot find -lgomp #1

Closed ewenewen closed 6 years ago

ewenewen commented 6 years ago

Hi and first of all thanks for your work :)

I'm having troubles compiling Gappa on my personal GNU/Linux laptop, though it works on a computer cluster I have access to. After building/installing the necessary libraries (CLI11, genesis, sparsepp), the make command gives me that output:

$ make
Running CMake...
-- The CXX compiler identification is GNU 7.3.1
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Gappa build type: RELEASE
-- Static linking of system libraries: ON
-- Configuring Genesis
-- CMake version 3.10.3
-- The C compiler identification is GNU 7.3.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Genesis version: v0.19.0
-- Building Genesis as a dependency
-- Build type: RELEASE
-- Unity build: FULL
-- C++ compiler: GNU 7.3.1 at /usr/bin/c++
-- C compiler  : GNU 7.3.1 at /usr/bin/cc
-- Check if the system is big endian
-- Searching 16 bit integer
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of unsigned short
-- Check size of unsigned short - done
-- Using unsigned short
-- Check if the system is big endian - little endian
-- Looking for Threads
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE  
-- Found Threads: -pthread
-- Using Threads
-- Looking for OpenMP
-- Found OpenMP_C: -fopenmp (found version "4.5") 
-- Found OpenMP_CXX: -fopenmp (found version "4.5") 
-- Found OpenMP: TRUE (found version "4.5")  
-- Found OpenMP: -fopenmp
-- Using OpenMP
-- Building static lib
-- Finished configuring Genesis
-- CMAKE_EXE_LINKER_FLAGS  -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -static -static-libgcc -static-libstdc++  
-- GENESIS_LINK_LIBRARIES -pthread;genesis_lib_static
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    BUILD_STATIC

-- Build files have been written to: /home/ewen/bin/gappa/build
Running make...
make -s -C build
Scanning dependencies of target genesis_lib_static
[  4%] Building CXX object libs/genesis/lib/genesis/CMakeFiles/genesis_lib_static.dir/__/__/__/__/genesis_unity_sources/lib/all.cpp.o
[  8%] Linking CXX static library ../../../../../libs/genesis/bin/libgenesis.a
[  8%] Built target genesis_lib_static
Scanning dependencies of target gappa
[ 12%] Building CXX object CMakeFiles/gappa.dir/src/commands/analyze/krd.cpp.o
[ 16%] Building CXX object CMakeFiles/gappa.dir/src/commands/analyze/nhd.cpp.o
[ 20%] Building CXX object CMakeFiles/gappa.dir/src/commands/analyze/squash.cpp.o
[ 25%] Building CXX object CMakeFiles/gappa.dir/src/commands/analyze/tog.cpp.o
[ 29%] Building CXX object CMakeFiles/gappa.dir/src/commands/analyze/visualize_color.cpp.o
[ 33%] Building CXX object CMakeFiles/gappa.dir/src/commands/pre/art.cpp.o
[ 37%] Building CXX object CMakeFiles/gappa.dir/src/commands/pre/chunkify.cpp.o
[ 41%] Building CXX object CMakeFiles/gappa.dir/src/commands/pre/extract.cpp.o
[ 45%] Building CXX object CMakeFiles/gappa.dir/src/commands/pre/unchunkify.cpp.o
[ 50%] Building CXX object CMakeFiles/gappa.dir/src/main.cpp.o
[ 54%] Building CXX object CMakeFiles/gappa.dir/src/options/color/color_map.cpp.o
[ 58%] Building CXX object CMakeFiles/gappa.dir/src/options/color/color_norm.cpp.o
[ 62%] Building CXX object CMakeFiles/gappa.dir/src/options/color/single_color.cpp.o
[ 66%] Building CXX object CMakeFiles/gappa.dir/src/options/file_input.cpp.o
[ 70%] Building CXX object CMakeFiles/gappa.dir/src/options/file_output.cpp.o
[ 75%] Building CXX object CMakeFiles/gappa.dir/src/options/global.cpp.o
[ 79%] Building CXX object CMakeFiles/gappa.dir/src/options/jplace_input.cpp.o
[ 83%] Building CXX object CMakeFiles/gappa.dir/src/options/matrix_output.cpp.o
[ 87%] Building CXX object CMakeFiles/gappa.dir/src/options/sequence_input.cpp.o
[ 91%] Building CXX object CMakeFiles/gappa.dir/src/options/tree_output.cpp.o
[ 95%] Building CXX object CMakeFiles/gappa.dir/src/options/tree_output/svg.cpp.o
[100%] Linking CXX executable ../bin/gappa
/usr/bin/ld: cannot find -lgomp
collect2: error: ld returned 1 exit status
make[3]: *** [CMakeFiles/gappa.dir/build.make:616: ../bin/gappa] Error 1
make[2]: *** [CMakeFiles/Makefile2:68: CMakeFiles/gappa.dir/all] Error 2
make[1]: *** [Makefile:84: all] Error 2
make: *** [Makefile:44: build] Error 2

The issue seems related to the OpenMP library, that I installed, and it seems to be detected. I am using Archlinux, with kernel 4.15.11

Any ideas? Thanks! Ewen

lczech commented 6 years ago

Hi Ewen,

very courageous of you to use gappa at this early stage! ;-)

OpenMP is a constant troublemaker in genesis and gappa... There are a couple of reasons that could be the culprit here:

  1. It might be that the OpenMP library is actually missing. Try sudo apt-get install libgomp1, and then try to compile gappa again: make clean && make.

  2. By default, gappa compiles system libraries statically in order to get a portable binary. This can cause issues with OpenMP. You can try to build the non-static version:

    make clean
    mkdir build
    cd build/
    cmake -DGAPPA_BUILD_STATIC=OFF ..
    make

    This way, the binary will only work on your system, but that should be okay for now, I guess ;-)

  3. In the beginning of the CMake output, it says that the compiler is GNU 7.3.1, and found at /usr/bin/c++. I've seen cases were CMake was mismatching these, and instead used Clang...

    Can you run this please and report the output:

    $ ls -l /usr/bin/c++

    In my case for example, this leads to another symlink, which then links to clang. So, follow the link chain until you reach something that tells you what hides behind c++:

    $ ls -l /usr/bin/c++
    lrwxrwxrwx 1 root root 21 Sep 19  2014 /usr/bin/c++ -> /etc/alternatives/c++
    $ ls -l /etc/alternatives/c++
    lrwxrwxrwx 1 root root 20 Aug 23  2017 /etc/alternatives/c++ -> /usr/bin/clang++-3.9

As a side note, you said that you build and installed the needed libraries beforehand. That should actually not be needed if you use git clone --recursive https://github.com/lczech/gappa.git. This will also pull all three (CLI11, genesis and sparsepp).

Lastly, if you are using gappa now (without documentation and with just a few of the planned features), may I ask what you want to use it for? Always good to now which features to concentrate on!

So long Lucas

ewenewen commented 6 years ago

Thanks a lot for your detailed answer and kind help.

  1. I'm not running a Ubuntu-like distribution, so I cannot apt-get packages. But it seems I have the library installed:

    $ find /usr/ -name "libgomp*"  
    /usr/lib/libgomp.so
    /usr/lib/libgomp.so.1
    /usr/lib/libgomp.so.1.0.0
    /usr/lib/libgomp.spec
    /usr/lib32/libgomp.so
    /usr/lib32/libgomp.so.1
    /usr/lib32/libgomp.so.1.0.0
    /usr/lib32/libgomp.spec
    /usr/share/info/libgomp.info.gz
  2. I tried to build the non-static version, following your advice, it worked! (the first try was not lucky, but after a reboot or some action I don't recall, it was)

  3. /usr/bin/c++ is not a link:

    $ ls -l /usr/bin/c++  
    -rwxr-xr-x 4 root root 1002688 Mar 13 20:33 /usr/bin/c++

So option 2 works, many thanks for that!

As for my usage of gappa, for now I'd be interested in visualization (visualize-color) and also at some point Squash clustering. Usually, as soon as I have a jplace file, I tend to import it in R and perform my analyses/visualization. But doing so has some downsides (tree manipulation and visualization in R is a bit tedious). I welcome any other alternatives. :)

lczech commented 6 years ago

Nice! I think I will then deactivate the static linking by default. It's the second time this has caused trouble, and most users won't need the static binary if they want to build on their own.

  1. For Arch Linux, this might work in the future: https://stackoverflow.com/a/35343944/4184258 However, I never worked with Arch, so no guarantee ;-)
  2. Glad to hear, good to know!
  3. Hm okay, if you want, you can try c++ --version just to make sure that you are actually using the correct GCC. But as it works now, this is not needed.

The issue with placement data is that as of now, there are only a few standard methods for working with these data, e.g., squash, or simple heat tree visualizations. The data are quite useful for many purposes, but this usually requires coding. Thus, I know what you are going through...

So, gappa is meant as a simple command line tool for the standard methods. But it uses genesis as the backend for all functionality. Thus, if you want to learn some C++, you can start coding your analyses with genesis, which already offers many useful functions for working with placement data.

Alternatively, there is ggtree for R, which you might find useful. It can read jplace files (as far as I know), but I don't know what else it can do with them.

I'm going to close this issue now. If there is anything else, don't hesitate to ask. Lucas

ewenewen commented 6 years ago

For Archlinux, this is a little more complicated than that :P Here's a first (old) lead if someone comes upon this current issue: https://bbs.archlinux.org/viewtopic.php?id=182444

I am already using ggtree, which I find really convenient, except for plotting exactly what I want, in a circular way. For now I managed not to dive into genesis, but eventually I might do it anyway, it looks cool! :)

Thanks again! Ewen

lczech commented 6 years ago

Okay, thanks for the link.

I had another thought about what might have cause the issue: It is possible that the gcc version on Arch does not provide a static version of the OpenMP library (.a), but only the dynamic one (.so). I had that issue with Clang before, and hence couldn't build a static version of gappa with Clang.

Anyway, I now changed the default to compiling with dynamic linking, so now it should work for more compilers and OSs.