DerrickWood / kraken2

The second version of the Kraken taxonomic sequence classification system
MIT License
734 stars 274 forks source link

Linking executable "classify" fails #438

Open rekado opened 3 years ago

rekado commented 3 years ago

Hi there,

I'm attempting to package kraken2 for GNU Guix, a bit-reproducible package manager.

Unfortunately, I cannot seem to link the "classify" executable. There are undefined references to murmurhash and HyperLogLog, which I assumed should be satisfied by the code in hyperloglogplus.cc and others. Could it be that some objects are missing from the linker invocation?

Here's the relevant snippet from the build log:

[ 68%] Linking CXX executable classify
cd /tmp/guix-build-kraken2-2.1.1.drv-0/build/src && /gnu/store/3dsl2jalrcyldkrsqab1hc6sv8pyag9z-cmake-minimal-3.16.5/bin/cmake -E cmake_link_script CMakeFiles/classify.dir/link.txt --verbose=1
/gnu/store/rn75fm7adgx3pw5j8pg3bczfqq1y17lk-gcc-7.5.0/bin/c++   -fopenmp -O2 -g -DNDEBUG    -rdynamic CMakeFiles/classify.dir/classify.cc.o CMakeFiles/classify.dir/reports.cc.o CMakeFiles/classify.dir/mmap_file.cc.o CMakeFiles/classify.dir/compact_hash.cc.o CMakeFiles/classify.dir/taxonomy.cc.o CMakeFiles/classify.dir/seqreader.cc.o CMakeFiles/classify.dir/mmscanner.cc.o CMakeFiles/classify.dir/omp_hack.cc.o CMakeFiles/classify.dir/aa_translate.cc.o CMakeFiles/classify.dir/utilities.cc.o  -o classify 
ld: CMakeFiles/classify.dir/classify.cc.o: in function `kraken2::ReadCounts<HyperLogLogPlusMinus<unsigned long> >::add_kmer(unsigned long)':
/tmp/guix-build-kraken2-2.1.1.drv-0/source/src/readcounts.h:57: undefined reference to `HyperLogLogPlusMinus<unsigned long>::insert(unsigned long)'
ld: CMakeFiles/classify.dir/classify.cc.o: in function `kraken2::ReadCounts<HyperLogLogPlusMinus<unsigned long> >::operator+=(kraken2::ReadCounts<HyperLogLogPlusMinus<unsigned long> >&&)':
/tmp/guix-build-kraken2-2.1.1.drv-0/source/src/readcounts.h:70: undefined reference to `HyperLogLogPlusMinus<unsigned long>::operator+=(HyperLogLogPlusMinus<unsigned long>&&)'
ld: CMakeFiles/classify.dir/classify.cc.o: in function `kraken2::ReadCounts<HyperLogLogPlusMinus<unsigned long> >::ReadCounts()':
/tmp/guix-build-kraken2-2.1.1.drv-0/source/src/readcounts.h:28: undefined reference to `murmurhash3_finalizer(unsigned long)'
ld: /tmp/guix-build-kraken2-2.1.1.drv-0/source/src/readcounts.h:28: undefined reference to `HyperLogLogPlusMinus<unsigned long>::HyperLogLogPlusMinus(unsigned char, bool, unsigned long (*)(unsigned long))'
ld: CMakeFiles/classify.dir/reports.cc.o: in function `kraken2::ReadCounts<HyperLogLogPlusMinus<unsigned long> >::distinctKmerCount() const':
/tmp/guix-build-kraken2-2.1.1.drv-0/source/src/readcounts.h:106: undefined reference to `HyperLogLogPlusMinus<unsigned long>::size() const'
ld: CMakeFiles/classify.dir/reports.cc.o: in function `kraken2::ReadCounts<HyperLogLogPlusMinus<unsigned long> >::ReadCounts(kraken2::ReadCounts<HyperLogLogPlusMinus<unsigned long> > const&)':
/tmp/guix-build-kraken2-2.1.1.drv-0/source/src/readcounts.h:34: undefined reference to `HyperLogLogPlusMinus<unsigned long>::HyperLogLogPlusMinus(HyperLogLogPlusMinus<unsigned long> const&)'
ld: CMakeFiles/classify.dir/reports.cc.o: in function `kraken2::ReadCounts<HyperLogLogPlusMinus<unsigned long> >::operator+=(kraken2::ReadCounts<HyperLogLogPlusMinus<unsigned long> > const&)':
/tmp/guix-build-kraken2-2.1.1.drv-0/source/src/readcounts.h:63: undefined reference to `HyperLogLogPlusMinus<unsigned long>::operator+=(HyperLogLogPlusMinus<unsigned long> const&)'
ld: CMakeFiles/classify.dir/reports.cc.o: in function `kraken2::ReadCounts<HyperLogLogPlusMinus<unsigned long> >::ReadCounts(kraken2::ReadCounts<HyperLogLogPlusMinus<unsigned long> > const&)':
/tmp/guix-build-kraken2-2.1.1.drv-0/source/src/readcounts.h:34: undefined reference to `HyperLogLogPlusMinus<unsigned long>::HyperLogLogPlusMinus(HyperLogLogPlusMinus<unsigned long> const&)'
ld: /tmp/guix-build-kraken2-2.1.1.drv-0/source/src/readcounts.h:34: undefined reference to `HyperLogLogPlusMinus<unsigned long>::HyperLogLogPlusMinus(HyperLogLogPlusMinus<unsigned long> const&)'
ld: CMakeFiles/classify.dir/reports.cc.o: in function `kraken2::ReadCounts<HyperLogLogPlusMinus<unsigned long> >::ReadCounts(unsigned long, unsigned long)':
/tmp/guix-build-kraken2-2.1.1.drv-0/source/src/readcounts.h:31: undefined reference to `murmurhash3_finalizer(unsigned long)'
ld: /tmp/guix-build-kraken2-2.1.1.drv-0/source/src/readcounts.h:31: undefined reference to `HyperLogLogPlusMinus<unsigned long>::HyperLogLogPlusMinus(unsigned char, bool, unsigned long (*)(unsigned long))'
ld: CMakeFiles/classify.dir/reports.cc.o: in function `kraken2::ReadCounts<HyperLogLogPlusMinus<unsigned long> >::ReadCounts(kraken2::ReadCounts<HyperLogLogPlusMinus<unsigned long> > const&)':
/tmp/guix-build-kraken2-2.1.1.drv-0/source/src/readcounts.h:34: undefined reference to `HyperLogLogPlusMinus<unsigned long>::HyperLogLogPlusMinus(HyperLogLogPlusMinus<unsigned long> const&)'
ld: /tmp/guix-build-kraken2-2.1.1.drv-0/source/src/readcounts.h:34: undefined reference to `HyperLogLogPlusMinus<unsigned long>::HyperLogLogPlusMinus(HyperLogLogPlusMinus<unsigned long> const&)'
ld: CMakeFiles/classify.dir/reports.cc.o: in function `kraken2::ReadCounts<HyperLogLogPlusMinus<unsigned long> >::ReadCounts()':
/tmp/guix-build-kraken2-2.1.1.drv-0/source/src/readcounts.h:28: undefined reference to `murmurhash3_finalizer(unsigned long)'
ld: /tmp/guix-build-kraken2-2.1.1.drv-0/source/src/readcounts.h:28: undefined reference to `HyperLogLogPlusMinus<unsigned long>::HyperLogLogPlusMinus(unsigned char, bool, unsigned long (*)(unsigned long))'
collect2: error: ld returned 1 exit status

Thanks for working on kraken2!

rekado commented 3 years ago

I forgot to mention that I'm using cmake here. I see that you're also providing Makefiles, and the installer script refers to them, so I'll try that next.

rekado commented 3 years ago

...and indeed, running make -C src does result in a successful build.

So I guess the only problem is that the CMakeLists.txt isn't quite working as intended.

rekado commented 3 years ago

This patch fixes the cmake problems:

https://github.com/guix-science/guix-science/blob/2687c5da2493515fbd6d93f9de2d1b772678f66a/kraken2-fix-link-error.patch