[Jellyfish] successfully compiled on Mac, but linking error on Ubuntu
1
0
Entering edit mode
8.1 years ago
CodeRush • 0

Hi all,

I tried to use Jellyfish. Everything went well in [make] and [make install]. The executable bin file also works. What I want is to compile my own code against the Jellyfish include files and the shared libraries.

I tried to compile the following simple code, which is very simple, with only one declaration of hash_counter.

#include <iostream>    
#include <jellyfish/mer_dna.hpp>
#include <jellyfish/thread_exec.hpp>
#include <jellyfish/hash_counter.hpp>
#include <jellyfish/stream_manager.hpp>
#include <jellyfish/mer_overlap_sequence_parser.hpp>
#include <jellyfish/mer_iterator.hpp>

typedef jellyfish::cooperative::hash_counter<jellyfish::mer_dna>  mer_hash_type;

int main(int argc, char *argv[]) {
  jellyfish::mer_dna::k(25); // Set length of mers (k=25)
  const uint64_t hash_size    = 10000000; // Initial size of hash.
  const uint32_t num_reprobes = 126;
  const uint32_t num_threads  = 16; // Number of concurrent threads
  const uint32_t counter_len  = 7;  // Minimum length of counting field
  const bool     canonical    = true; // Use canonical representation

  // create the hash
  mer_hash_type mer_hash(hash_size, jellyfish::mer_dna::k()*2, counter_len, num_threads, num_reprobes);

  return 0;
}

This code can be successfully compiled on Mac with the command below,

$g++ -std=c++11 -I/home/jellyfish_lib/include/jellyfish-2.2.5  -L/home/jellyfish_lib/lib -lpthread -ljellyfish-2.0 test.c -o test

but failed when compiled on Ubuntu (with g++ 4.9), with the following errors:

/tmp/ccKzjmVq.o: In function `main':
test.c:(.text+0x56): undefined reference to `jellyfish::quadratic_reprobes'
/tmp/ccKzjmVq.o: In function `jellyfish::random_bits()':
test.c:(.text._ZN9jellyfish11random_bitsEv[_ZN9jellyfish11random_bitsEv]+0xa): undefined reference to `jellyfish::random_bits(int)'
/tmp/ccKzjmVq.o: In function `allocators::mmap::~mmap()':
test.c:(.text._ZN10allocators4mmapD2Ev[_ZN10allocators4mmapD5Ev]+0x14): undefined reference to `allocators::mmap::free()'
/tmp/ccKzjmVq.o: In function `jellyfish::RectangularBinaryMatrix::RectangularBinaryMatrix(unsigned int, unsigned int)':
test.c:(.text._ZN9jellyfish23RectangularBinaryMatrixC2Ejj[_ZN9jellyfish23RectangularBinaryMatrixC5Ejj]+0x1d): undefined reference to `jellyfish::RectangularBinaryMatrix::alloc(unsigned int, unsigned int)'
/tmp/ccKzjmVq.o: In function `jellyfish::RectangularBinaryMatrix::RectangularBinaryMatrix(jellyfish::RectangularBinaryMatrix const&)':
test.c:(.text._ZN9jellyfish23RectangularBinaryMatrixC2ERKS0_[_ZN9jellyfish23RectangularBinaryMatrixC5ERKS0_]+0x23): undefined reference to `jellyfish::RectangularBinaryMatrix::alloc(unsigned int, unsigned int)'
/tmp/ccKzjmVq.o: In function `jellyfish::RectangularBinaryMatrix::randomize_pseudo_inverse()':
test.c:(.text._ZN9jellyfish23RectangularBinaryMatrix24randomize_pseudo_inverseEv[_ZN9jellyfish23RectangularBinaryMatrix24randomize_pseudo_inverseEv]+0x24): undefined reference to `jellyfish::RectangularBinaryMatrix::randomize_pseudo_inverse(unsigned long (*)())'
/tmp/ccKzjmVq.o: In function `jellyfish::locks::pthread::barrier::barrier(unsigned int)':
test.c:(.text._ZN9jellyfish5locks7pthread7barrierC2Ej[_ZN9jellyfish5locks7pthread7barrierC5Ej]+0x1f): undefined reference to `pthread_barrier_init'
/tmp/ccKzjmVq.o: In function `jellyfish::locks::pthread::barrier::~barrier()':
test.c:(.text._ZN9jellyfish5locks7pthread7barrierD2Ev[_ZN9jellyfish5locks7pthread7barrierD5Ev]+0x14): undefined reference to `pthread_barrier_destroy'
/tmp/ccKzjmVq.o: In function `jellyfish::large_hash::array_base<jellyfish::mer_dna_ns::mer_base_static<unsigned long, 0>, unsigned long, atomic::gcc, jellyfish::large_hash::array<jellyfish::mer_dna_ns::mer_base_static<unsigned long, 0>, unsigned long, atomic::gcc, allocators::mmap> >::array_base(unsigned long, unsigned short, unsigned short, unsigned short, jellyfish::RectangularBinaryMatrix, unsigned long const*)':
test.c:(.text._ZN9jellyfish10large_hash10array_baseINS_10mer_dna_ns15mer_base_staticImLi0EEEmN6atomic3gccENS0_5arrayIS4_mS6_N10allocators4mmapEEEEC2EmtttNS_23RectangularBinaryMatrixEPKm[_ZN9jellyfish10large_hash10array_baseINS_10mer_dna_ns15mer_base_staticImLi0EEEmN6atomic3gccENS0_5arrayIS4_mS6_N10allocators4mmapEEEEC5EmtttNS_23RectangularBinaryMatrixEPKm]+0x269): undefined reference to `jellyfish::RectangularBinaryMatrix::pseudo_inverse() const'
/tmp/ccKzjmVq.o: In function `jellyfish::large_hash::array<jellyfish::mer_dna_ns::mer_base_static<unsigned long, 0>, unsigned long, atomic::gcc, allocators::mmap>::alloc_data(unsigned long)':
test.c:(.text._ZN9jellyfish10large_hash5arrayINS_10mer_dna_ns15mer_base_staticImLi0EEEmN6atomic3gccEN10allocators4mmapEE10alloc_dataEm[_ZN9jellyfish10large_hash5arrayINS_10mer_dna_ns15mer_base_staticImLi0EEEmN6atomic3gccEN10allocators4mmapEE10alloc_dataEm]+0x1f): undefined reference to `allocators::mmap::realloc(unsigned long)'
collect2: error: ld returned 1 exit status

It seems something went wrong during linking. Does anyone have experience about this?

software error sequence • 2.1k views
ADD COMMENT
0
Entering edit mode
8.1 years ago
kloetzl ★ 1.1k

During linking, the order of your parameters is important. Try this:

g++ -std=c++11 -I/home/jellyfish_lib/include/jellyfish-2.2.5  -L/home/jellyfish_lib/lib test.c -o test -lpthread -ljellyfish-2.0

Hope that's it.

ADD COMMENT
0
Entering edit mode

Great! It seems work! At least no error appeared and the executable file got generated. Let me check further. I just explictly translated the command into the compile command I posted and didn't noted the order of parameters. Do you know why it works on Mac but not on Ubuntu? Maybe due to the compiler? Thank you so much

ADD REPLY
0
Entering edit mode

I am unsure why it works on Mac. Maybe clang does things differently. Also the order in with you define the libraries -lfoo -lbar matters.

ADD REPLY

Login before adding your answer.

Traffic: 2996 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6