Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling graphtyper. Problem with include(-I) paths when compiling. /usr/include is ignored. #126

Open
lindenb opened this issue Mar 3, 2023 · 1 comment

Comments

@lindenb
Copy link

lindenb commented Mar 3, 2023

Hi again,

after #125 I'm trying to compile graphtyper . I got two problems when htslib was compiled.

  1. For a strange reason /usr/include ( where there zlib.h is found) was not included in the -I path. So I got a zlib.h not found

  2. I added -I/usr/include to the paths (see below) but then, as I've got a very old version of the htslib headers under /usr/include/htslib, so this old library was used before the graphtyper's htslib..

All in one, the problem was fixed by changing graphtyper/CMakeLists.txt

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ad1cd4e..ebbcc5e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -114,7 +114,7 @@ ExternalProject_Add(
     SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/htslib
     PREFIX ${CMAKE_CURRENT_BINARY_DIR}/htslib
     CONFIGURE_COMMAND cp -a ${CMAKE_CURRENT_SOURCE_DIR}/htslib ${CMAKE_CURRENT_BINARY_DIR}/ COMMAND autoheader COMMAND autoconf COMMAND ${CMAKE_CURRENT_BINARY
-        "CFLAGS=${MYCFLAGS} -g -Wall -O3 ${CMAKE_C_FLAGS} -I${CMAKE_CURRENT_BINARY_DIR}/libdeflate"
+        "CFLAGS=${MYCFLAGS} -g -Wall -O3 ${CMAKE_C_FLAGS} -I${CMAKE_CURRENT_BINARY_DIR}/htslib -I/usr/include -I${CMAKE_CURRENT_BINARY_DIR}/libdeflate"
         "LDFLAGS=${MYLDFLAGS} -L${CMAKE_CURRENT_BINARY_DIR}/libdeflate"
         "CC=${CMAKE_C_COMPILER}"
     BUILD_COMMAND $(MAKE) -C ${CMAKE_CURRENT_BINARY_DIR}/htslib libhts.a

ok. The compilation, went on.... and then Cmake raised the following error:

[ 24%] Built target project_paw
make  -f src/CMakeFiles/graphtyper_objects.dir/build.make src/CMakeFiles/graphtyper_objects.dir/depend
make[3]: Entering directory '/LAB-DATA/BiRD/users/lindenbaum-p/TMP/graphtyper/release-build'
cd /LAB-DATA/BiRD/users/lindenbaum-p/TMP/graphtyper/release-build && /CONDAS/users/lindenbaum-p/GRAPHTYPER/bin/cmake -E cmake_depends "Unix Makefiles" /LAB-DATA/BiRD/users/lindenbaum-p/TMP/graphtyper /LAB-DATA/BiRD/users/lindenbaum-p/TMP/graphtyper/src /LAB-DATA/BiRD/users/lindenbaum-p/TMP/graphtyper/release-build /LAB-DATA/BiRD/users/lindenbaum-p/TMP/graphtyper/release-build/src /LAB-DATA/BiRD/users/lindenbaum-p/TMP/graphtyper/release-build/src/CMakeFiles/graphtyper_objects.dir/DependInfo.cmake --color=
Dependencies file "src/CMakeFiles/graphtyper_objects.dir/graph/absolute_position.cpp.o.d" is newer than depends file "/LAB-DATA/BiRD/users/lindenbaum-p/TMP/graphtyper/release-build/src/CMakeFiles/graphtyper_objects.dir/compiler_depend.internal".
Dependencies file "src/CMakeFiles/graphtyper_objects.dir/graph/alt.cpp.o.d" is newer than depends file "/LAB-DATA/BiRD/users/lindenbaum-p/TMP/graphtyper/release-build/src/CMakeFiles/graphtyper_objects.dir/compiler_depend.internal".
Consolidate compiler generated dependencies of target graphtyper_objects
make[3]: Leaving directory '/LAB-DATA/BiRD/users/lindenbaum-p/TMP/graphtyper/release-build'
make  -f src/CMakeFiles/graphtyper_objects.dir/build.make src/CMakeFiles/graphtyper_objects.dir/build
make[3]: Entering directory '/LAB-DATA/BiRD/users/lindenbaum-p/TMP/graphtyper/release-build'
[ 25%] Building CXX object src/CMakeFiles/graphtyper_objects.dir/graph/constructor.cpp.o
cd /LAB-DATA/BiRD/users/lindenbaum-p/TMP/graphtyper/release-build/src && /CONDAS/users/ifb-tools/miniconda3/envs/gcc-9.3.0/bin/c++  -I/LAB-DATA/BiRD/users/lindenbaum-p/TMP/graphtyper/include -I/LAB-DATA/BiRD/users/lindenbaum-p/TMP/graphtyper/release-build/include -isystem /LAB-DATA/BiRD/users/lindenbaum-p/TMP/graphtyper/release-build/htslib -isystem /LAB-DATA/BiRD/users/lindenbaum-p/TMP/graphtyper/release-build/htslib/htslib -isystem /LAB-DATA/BiRD/users/lindenbaum-p/TMP/graphtyper/release-build/paw/include -isystem /LAB-DATA/BiRD/users/lindenbaum-p/TMP/graphtyper/paw/include -isystem /LAB-DATA/BiRD/users/lindenbaum-p/TMP/graphtyper/parallel-hashmap -isystem /LAB-DATA/BiRD/users/lindenbaum-p/TMP/graphtyper/seqan/include -isystem /LAB-DATA/BiRD/users/lindenbaum-p/TMP/graphtyper/cereal/include -O3 -DNDEBUG  -Wall -Wextra -Wfatal-errors -pedantic -Wno-variadic-macros -std=c++17 -DSEQAN_HAS_ZLIB=1 -DSEQAN_USE_HTSLIB=1 -DSEQAN_ENABLE_TESTING=0 -DSEQAN_ENABLE_DEBUG=0 -MD -MT src/CMakeFiles/graphtyper_objects.dir/graph/constructor.cpp.o -MF CMakeFiles/graphtyper_objects.dir/graph/constructor.cpp.o.d -o CMakeFiles/graphtyper_objects.dir/graph/constructor.cpp.o -c /LAB-DATA/BiRD/users/lindenbaum-p/TMP/graphtyper/src/graph/constructor.cpp
In file included from /LAB-DATA/BiRD/users/lindenbaum-p/TMP/graphtyper/seqan/include/seqan/stream.h:89,
                 from /LAB-DATA/BiRD/users/lindenbaum-p/TMP/graphtyper/seqan/include/seqan/seq_io.h:45,
                 from /LAB-DATA/BiRD/users/lindenbaum-p/TMP/graphtyper/src/graph/constructor.cpp:8:
/LAB-DATA/BiRD/users/lindenbaum-p/TMP/graphtyper/seqan/include/seqan/stream/stream_compressor.h:41:10: fatal error: zlib.h: No such file or directory
   41 | #include <zlib.h>
      |          ^~~~~~~~
compilation terminated.
make[3]: *** [src/CMakeFiles/graphtyper_objects.dir/build.make:107: src/CMakeFiles/graphtyper_objects.dir/graph/constructor.cpp.o] Error 1
make[3]: Leaving directory '/LAB-DATA/BiRD/users/lindenbaum-p/TMP/graphtyper/release-build'
make[2]: *** [CMakeFiles/Makefile2:241: src/CMakeFiles/graphtyper_objects.dir/all] Error 2
make[2]: Leaving directory '/LAB-DATA/BiRD/users/lindenbaum-p/TMP/graphtyper/release-build'
make[1]: *** [Makefile:149: all] Error 2
make[1]: Leaving directory '/LAB-DATA/BiRD/users/lindenbaum-p/TMP/graphtyper/release-build'
make: *** [Makefile:9: all] Error 2

again, zlib.h was not found while it's in /usr/include.

$ file /usr/include/zlib.h 
/usr/include/zlib.h: C source, ASCII text

I'm familiar with make but not with cmake.

So my question is: where should I add /usr/include for compiling graph/constructor.cpp.o ? Or is there any env variable to add at the beginning to set the include paths.

current version: 5b01f1e

@hannespetur
Copy link
Member

Hi,

I have limited knowledge of GCC but my understanding is that the system headers in /usr/include should already be searched by default. The system headers are included in a very specific manner and with -I/usr/include you are changing the search order which can lead to weird behavior.

The zlib.h not found is from CMake right? It is very odd that both CMake and GCC cannot see zlib.h... Maybe make sure that you have permission to read the file? Maybe it is easier to test around with a simple program that does nothing except include "zlib.h".

Since you are not familiar with CMake I'll point out that with every change of CMakeLists.txt you make you need to delete and redo the CMakeFiles directory and CMakeCache.txt since values are cached.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants