uni-halle / gerbil

A fast and memory-efficient k-mer counter with GPU-support
MIT License
34 stars 14 forks source link

static compiling #9

Closed bjoardar closed 6 years ago

bjoardar commented 6 years ago

Hi, I would like to statically compile the gerbil code. I made a few changes in the "CMakeLists.txt" file (attached). The code compiles successfully. However, it ends with a segmentation fault during the input read stage. I get the same error with a separate "Makefile" I made to statically compile the code. The fault seems to come from FastReader.cpp but I can't figure it out. On the other hand, the non-static compiled version runs fine. Please take a look. CMakeLists.txt Thanks

srechner commented 6 years ago

Sorry for this late response. Could you figure out what caused the problem? I would be interested in seeing a working CMakeLists.txt file that statically compiles the code.

bjoardar commented 6 years ago

The segmentation fault was due to a gnu bug. I fixed it using a few extra flags "-Wl,--whole-archive -Wl,--no-whole-archive". However, I ended up using a Makefile instead of the CMakeLists.txt file.

mhorlacher commented 4 years ago

@bjoardar Can you provide me with your final Makefile or CMakeLists.txt file? Thanks!

bjoardar commented 4 years ago

@mhorlacher EXECUTABLE := gerbil

CXXFILES := Application.cpp Bundle.cpp debug.cpp FastFile.cpp FastParser.cpp FastReader.cpp gerbil.cpp global.cpp KmcWriter.cpp KmerDistributor.cpp SequenceSplitter.cpp SuperReader.cpp SuperWriter.cpp TempFile.cpp OBJ := Application.o Bundle.o debug.o FastFile.o FastParser.o FastReader.o gerbil.o global.o KmcWriter.o KmerDistributor.o SequenceSplitter.o SuperReader.o SuperWriter.o TempFile.o LIBDIR := -L{path to dependencies}/lib/ -lboost_regex -lbz2 -lm -lz -lboost_filesystem -lboost_system -lrt -lboost_thread -Wl,--whole-archive -lpthread -Wl,--no-whole-archive

CXXFLAGS := -I{path to dependencies}/include -std=c++11 -static DEPS := Application.h Bundle.h config.h CpuHasher.h debug.h FailureBuffer.h FastFile.h FastParser.h FastReader.h global.h KmcWriter.h Kmer.h KmerCountingHashTable.h KmerDistributer.h KmerHasher.h SequenceSplitter.h SuperReader.h SuperWriter.h SyncQueue.h TempFile.h TempFileStatistic.h ThreadBarrier.h types.h

CXX = g++

%.o: %.cpp $(DEPS) $(CXX) -o $@ $< $(LIBDIR) $(CXXFLAGS)

$(EXECUTABLE): $(OBJ) g++ -o $@ $^ $(LIBDIR) $(CXXFLAGS)

clean: rm -f *.o $(TARGET)

mhorlacher commented 4 years ago

@bjoardar Sorry, I'm not very versed with make / cmake or aot compiled languages for that matter - after fixing the leading TABs, I still get make: *** No rule to make target 'Application.o', needed by 'gerbil'. Stop.. Do you have a different directory structure for Gerbil? Would you mind attaching your complete Makefile? Thanks a lot and best regards

bjoardar commented 4 years ago

@mhorlacher To use this makefile, you need to place all .cpp and .h files in same directory as the makefile (a redundant change I did to my local copy of the code).

mhorlacher commented 4 years ago

@bjoardar thanks for taking your time

I followed the instructions but are still prompted with:

g++ -I /usr/include -std=c++11 -static   -c -o Application.o Application.cpp
Application.cpp:8:46: fatal error: ../../include/gerbil/Application.h: No such file or directory
compilation terminated.
<builtin>: recipe for target 'Application.o' failed
make: *** [Application.o] Error 1

Is the directory structure hard-coded in the *.cpp files? The Application.cpp has the following include statement #include "../../include/gerbil/Application.h".

bjoardar commented 4 years ago

@mhorlacher Yes, the path to the .h files need to be changed due to the change in directory structure.

mhorlacher commented 4 years ago

Hello @bjoardar , thanks for the detailed instructions, I've managed to statically compile Gerbil!