statgen / METAL

Meta-analysis of genomewide association scans
Other
39 stars 12 forks source link

#include <zlib.h> in libsrc/InputFile.h throwing compilation error & possible solution #31

Open pjawinski opened 1 year ago

pjawinski commented 1 year ago

Hi there,

for some reason, METAL didn't compile successfully on our linux cluster (although it did on another linux cluster and on my own mac), throwing the following error:

[ 80%] Building CXX object libsrc/CMakeFiles/goncalo.dir/StringArray.cpp.o                                                                                                                                                                                                                
[ 82%] Building CXX object libsrc/CMakeFiles/goncalo.dir/StringBasics.cpp.o                                                                                                                                                                                                               
[ 84%] Building CXX object libsrc/CMakeFiles/goncalo.dir/StringHash.cpp.o                                                                                                                                                                                                                 
[ 86%] Building CXX object libsrc/CMakeFiles/goncalo.dir/StringMap.cpp.o                                                                                                                                                                                                                  
[ 89%] Building CXX object libsrc/CMakeFiles/goncalo.dir/TraitTransformations.cpp.o                                                                                                                                                                                                       
[ 91%] Linking CXX static library libgoncalo.a                                                                                                                                                                                                                                            
make[2]: Leaving directory '/fast/software/METAL/build'                                                                                                                                                                                                                                   
[ 91%] Built target goncalo                                                                                                                                                                                                                                                               
make[2]: Entering directory '/fast/software/METAL/build'                                                                                                                                                                                                                                  
Scanning dependencies of target metal                                                                                                                                                                                                                                                     
make[2]: Leaving directory '/fast/software/METAL/build'                                                                                                                                                                                                                                   
make[2]: Entering directory '/fast/software/METAL/build'                                                                                                                                                                                                                                  
[ 93%] Building CXX object metal/CMakeFiles/metal.dir/Main.cpp.o                                                                                                                                                                                                                          
In file included from /fast/software/METAL/metal/Main.h:25,                                                                                                                                                                                                                               
                 from /fast/software/METAL/metal/Main.cpp:18:                                                                                                                                                                                                                             
/fast/software/METAL/libsrc/InputFile.h:31:10: fatal error: zlib.h: No such file or directory                                                                                                                                                                                             
   31 | #include <zlib.h>                                                                                                                                                                                                                                                                 
      |          ^~~~~~~~                                                                                                                                                                                                                                                                 
compilation terminated.                                                                                                                                                                                                                                                                   
make[2]: *** [metal/CMakeFiles/metal.dir/build.make:63: metal/CMakeFiles/metal.dir/Main.cpp.o] Error 1                                                                                                                                                                                    
make[2]: Leaving directory '/fast/software/METAL/build'                                                                                                                                                                                                                                   
make[1]: *** [CMakeFiles/Makefile2:146: metal/CMakeFiles/metal.dir/all] Error 2                                                                                                                                                                                                           
make[1]: Leaving directory '/fast/software/METAL/build'                                                                                                                                                                                                                                   
make: *** [Makefile:141: all] Error 2  

I've been using a conda environment, but received the same error without conda. In advance, cmake -DCMAKE_BUILD_TYPE=Release .. showed the correct ZLIB header directory and ZLIB library path (within the conda environment). Moreover, all build files written to ../build contained correct references to zlib.h in the activated conda environment. Still, #include <zlib.h> in libsrc/InputFile.h produced an error.

In my case, I solved this problem by manually changing #include <zlib.h> in line 31 of libsrc/InputFile.h to #include </path/to/my/conda/environment/include/zlib.h>. Hope this helps someone else who's experiencing the same issue. Maybe there's a more elegant solution or anything you can do to prevent this error.

Best wishes, Philippe

jonathonl commented 1 year ago

Try adding include_directories(${ZLIB_INCLUDE_DIR}) to line 14 of CMakeLists.txt (https://github.com/statgen/METAL/blob/master/CMakeLists.txt#L14).

pjawinski commented 1 year ago

Many thanks, that also worked out!