medvedevgroup/TwoPaCo

Linking twopaco to TBB fails

Closed this issue · 4 comments

Hi @IlyaMinkin,

I am trying to build TwoPaCo on RedHat-7-x86_64. Compilation and linking of graphdump proceeds without error but during linking of twopaco the following error occurs:

CMakeFiles/twopaco.dir/vertexenumerator.cpp.o: In function TwoPaCo::VertexEnumeratorImpl<1ul>::DistributeTasks(std::vector<std::string, std::allocator<std::string> > const&, unsigned long, std::vector<std::unique_ptr<tbb::concurrent_bounded_queue<TwoPaCo::Task, tbb::cache_aligned_allocator<TwoPaCo::Task> >, std::default_delete<tbb::concurrent_bounded_queue<TwoPaCo::Task, tbb::cache_aligned_allocator<TwoPaCo::Task> > > >, std::allocator<std::unique_ptr<tbb::concurrent_bounded_queue<TwoPaCo::Task, tbb::cache_aligned_allocator<TwoPaCo::Task> >, std::default_delete<tbb::concurrent_bounded_queue<TwoPaCo::Task, tbb::cache_aligned_allocator<TwoPaCo::Task> > > > > >&, std::unique_ptr<std::runtime_error, std::default_delete<std::runtime_error> >&, tbb::mutex&, std::ostream&) [clone .constprop.2154]: vertexenumerator.cpp:(.text+0x160d): undefined reference to tbb::internal::concurrent_queue_base_v8::internal_push_move(void const*) vertexenumerator.cpp:(.text+0x1aa8): undefined reference to tbb::internal::concurrent_queue_base_v8::internal_push_move_if_not_full(void const*)'

I have tried three different TBB releases: 43_20150209, tbb2017_20170412 and tbb2018_20170919. They all produce the error posted above. The 2018 release produces an additional error:

CMakeFiles/twopaco.dir/constructor.cpp.o: In function tbb::flow::interface10::graph::~graph()': constructor.cpp:(.text._ZN3tbb4flow11interface105graphD2Ev[_ZN3tbb4flow11interface105graphD5Ev]+0x4c): undefined reference to tbb::interface7::internal::task_arena_base::internal_execute(tbb::interface7::internal::delegate_base&) const constructor.cpp:(.text._ZN3tbb4flow11interface105graphD2Ev[_ZN3tbb4flow11interface105graphD5Ev]+0x104): undefined reference to tbb::interface7::internal::task_arena_base::internal_initialize() constructor.cpp:(.text._ZN3tbb4flow11interface105graphD2Ev[_ZN3tbb4flow11interface105graphD5Ev]+0x11c): undefined reference to tbb::interface7::internal::task_arena_base::internal_terminate()

The ldd command shows that graphdump is linked to the correct TBB library. Am I using the wrong TBB version or am I missing any additional libraries?

Thank you for your help!

Hi @OliverS87,

How did you install TBB? By hand or using a package manager? Both grahpdump and twopaco themselves get linked to TBB using the same commands.

Hi @IlyaMinkin,
I am working on a server environment, so I don't have full access to the systems package manager. Instead, I am using the Environment Modules system. I have downloaded the TBB library from https://github.com/01org/tbb/releases/download/2017_U6/tbb2017_20170412oss_lin.tgz. Files from this release were put into these folders:

lib/intel64/gcc4.7/* -> $LOCAL_TBB/lib/
include/* -> $LOCAL_TBB/include/

Upon loading the modulefile, the following changes to the environmental variables are done:
CPATH = $LOCAL_TBB/include:$CPATH
LIBRARY_PATH=$LOCAL_TBB/lib:$LIBRARY_PATH
LD_RUN_PATH=$LOCAL_TBB/lib:$LD_RUN_PATH
TBB_BASE=$LOCAL_TBB

I ran the graphdump linker command manually with added -Wl,--verbose flag:
/usr/bin/c++ -Wl,--verbose -std=c++0x -O3 -DNDEBUG CMakeFiles/graphdump.dir/graphdump.cpp.o CMakeFiles/graphdump.dir/__/common/dnachar.cpp.o CMakeFiles/graphdump.dir/__/common/streamfastaparser.cpp.o -o graphdump -rdynamic -ltbb

The output shows that ld does not use the tbb library in $LOCAL_TBB but a system-wide, older tbb version:
attempt to open /usr/lib64/libtbb.so succeeded
ldd however shows that graphdump is linked to the newer, local tbb library:
libtbb.so.2 => $LOCAL_TBB/lib/libtbb.so.2 (0x00007f70c5200000)
I guess the problem is that ld does not find the tbb library in $LOCAL_TBB?

@OliverS87 it is hard to say, maybe you are right. TwoPaCo uses CMAKE variables TBB_LIB_DIR and TBB_INCLUDE_DIR to find the libs. You may try to override them with the local installation to enforce the version. I will take a closer look soon.

Hi @IlyaMinkin,
thank you for your feedback! Unfortunately, setting these variables didn't solve the issue. But I think I've found a workaround solution for this issue: I have added the path to the libtbb.so file to the linker command:
/usr/bin/c++ -std=c++0x -O3 -DNDEBUG CMakeFiles/twopaco.dir/__/common/dnachar.cpp.o CMakeFiles/twopaco.dir/constructor.cpp.o CMakeFiles/twopaco.dir/concurrentbitvector.cpp.o CMakeFiles/twopaco.dir/compressedstring.cpp.o CMakeFiles/twopaco.dir/__/common/streamfastaparser.cpp.o CMakeFiles/twopaco.dir/test.cpp.o CMakeFiles/twopaco.dir/vertexenumerator.cpp.o CMakeFiles/twopaco.dir/__/common/spooky/SpookyV2.cpp.o CMakeFiles/twopaco.dir/common.cpp.o $LOCAL_TBB/lib/libtbb.so -o twopaco -rdynamic -ltbb
Now linking runs without error. ldd shows that twopaco links to the desired, local TBB installation so everything should be fine now!