- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm trying to compile a very simple example from the reference guide under msys2/mingw-w64:
#include "tbb/concurrent_queue.h" #include <iostream> using namespace std; using namespace tbb; int main() { concurrent_queue<int> queue; for ( int i=0; i<10; ++i ) queue.push(i); typedef concurrent_queue<int>::iterator iter; for ( iter i(queue.unsafe_begin()); i!=queue.unsafe_end(); ++i ) cout << *i << " "; cout << endl; return 0; }
I'm using the tbb package available through msys2's pacman package manager (i.e. "pacman -S mingw64/mingw-w64-x86_64-intel-tbb"), and gcc 5.2.0. When I try to compile the example above with "g++ -ltbb silly.cpp" I get a number of linking errors:
C:\msys64\tmp\ccpUMraJ.o:silly.cpp:(.text$_ZN3tbb8internal15throw_exceptionENS0_12exception_idE[_ZN3tbb8internal15throw_exceptionENS0_12exception_idE]+0xf): undefined reference to `tbb::internal::throw_exception_v4(tbb::internal::exception_id)'
C:\msys64\tmp\ccpUMraJ.o:silly.cpp:(.text$_ZN3tbb23cache_aligned_allocatorINS_10strict_ppl8internal29concurrent_queue_iterator_repIiEEE10deallocateEPS4_y[_ZN3tbb23cache_aligned_allocatorINS_10strict_ppl8internal29concurrent_queue_iterator_repIiEEE10deallocateEPS4_y]+0x1c): undefined reference to `tbb::internal::NFS_Free(void*)'
C:\msys64\tmp\ccpUMraJ.o:silly.cpp:(.text$_ZN3tbb23cache_aligned_allocatorINS_10strict_ppl8internal20concurrent_queue_repIiEEE8allocateEyPKv[_ZN3tbb23cache_aligned_allocatorINS_10strict_ppl8internal20concurrent_queue_repIiEEE8allocateEyPKv]+0x28): undefined reference to `tbb::internal::NFS_Allocate(unsigned long long, unsigned long long, void*)'
C:\msys64\tmp\ccpUMraJ.o:silly.cpp:(.text$_ZN3tbb23cache_aligned_allocatorINS_10strict_ppl8internal20concurrent_queue_repIiEEE10deallocateEPS4_y[_ZN3tbb23cache_aligned_allocatorINS_10strict_ppl8internal20concurrent_queue_repIiEEE10deallocateEPS4_y]+0x1c): undefined reference to `tbb::internal::NFS_Free(void*)'
C:\msys64\tmp\ccpUMraJ.o:silly.cpp:(.text$_ZN3tbb23cache_aligned_allocatorINS_10strict_ppl8internal29concurrent_queue_iterator_repIiEEE8allocateEyPKv[_ZN3tbb23cache_aligned_allocatorINS_10strict_ppl8internal29concurrent_queue_iterator_repIiEEE8allocateEyPKv]+0x28): undefined reference to `tbb::internal::NFS_Allocate(unsigned long long, unsigned long long, void*)'
C:\msys64\tmp\ccpUMraJ.o:silly.cpp:(.text$_ZN3tbb23cache_aligned_allocatorIcE8allocateEyPKv[_ZN3tbb23cache_aligned_allocatorIcE8allocateEyPKv]+0x28): undefined reference to `tbb::internal::NFS_Allocate(unsigned long long, unsigned long long, void*)'
C:\msys64\tmp\ccpUMraJ.o:silly.cpp:(.text$_ZN3tbb23cache_aligned_allocatorIcE10deallocateEPcy[_ZN3tbb23cache_aligned_allocatorIcE10deallocateEPcy]+0x1c): undefined reference to `tbb::internal::NFS_Free(void*)'
collect2.exe: error: ld returned 1 exit status
Any thoughts on what could be going wrong?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
That errors mean that you link to wrong tbb library. it looks that the library was compiled by visual studio but test was compiled by g++.
--Vladimir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I just tried compiling it myself with gcc rather than using the pacman version, and I get the same errors when linking to that. There are some visual studio versions of tbb on the machine, but I checked that they are not on the path by renaming the tbb I am trying to link to and ensuring that I then get an error because ld cannot find the tbb library.
For reference, my build process was:
sed -i "s|OUTPUT_KEY = -o #|OUTPUT_KEY = -Wl,--out-implib,lib\$(BUILDING_LIBRARY).a -o #|g" build/windows.gcc.inc echo "CPLUS_FLAGS += -mrtm" >> build/windows.gcc.inc mingw32-make compiler=gcc arch=intel64 runtime=mingw tbb_os=windows cpp0x=1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Why do you need importlib? Isn't enough to link with directly with tbb.dll?
//does not work g++ -Wall tbb.dll.a test2.cpp test2.cpp:(.text$_ZN3tbb8internal15throw_exceptionENS0_12exception_idE[_ZN3tbb8internal15throw_exceptionENS0_12exception_idE]+0xf): undefined reference to `tbb::internal::throw_exception_v4(tbb::internal::exception_id)' test2.cpp:(.text$_ZN3tbb23cache_aligned_allocatorINS_10strict_ppl8internal29concurrent_queue_iterator_repIiEEE10deallocateEPS4_y[_ZN3tbb23cache_aligned_allocatorINS_10strict_ppl8internal29concurrent_queue_iterator_repIiEEE10deallocateEPS4_y]+0x1c): undefined reference to `tbb::internal::NFS_Free(void*)' test2.cpp:(.text$_ZN3tbb23cache_aligned_allocatorINS_10strict_ppl8internal20concurrent_queue_repIiEEE8allocateEyPKv[_ZN3tbb23cache_aligned_allocatorINS_10strict_ppl8internal20concurrent_queue_repIiEEE8allocateEyPKv]+0x28): undefined reference to `tbb::internal::NFS_Allocate(unsigned long long, unsigned long long, void*)' test2.cpp:(.text$_ZN3tbb23cache_aligned_allocatorINS_10strict_ppl8internal20concurrent_queue_repIiEEE10deallocateEPS4_y[_ZN3tbb23cache_aligned_allocatorINS_10strict_ppl8internal20concurrent_queue_repIiEEE10deallocateEPS4_y]+0x1c): undefined reference to `tbb::internal::NFS_Free(void*)' test2.cpp:(.text$_ZN3tbb23cache_aligned_allocatorINS_10strict_ppl8internal29concurrent_queue_iterator_repIiEEE8allocateEyPKv[_ZN3tbb23cache_aligned_allocatorINS_10strict_ppl8internal29concurrent_queue_iterator_repIiEEE8allocateEyPKv]+0x28): undefined reference to `tbb::internal::NFS_Allocate(unsigned long long, unsigned long long, void*)' test2.cpp:(.text$_ZN3tbb23cache_aligned_allocatorIcE8allocateEyPKv[_ZN3tbb23cache_aligned_allocatorIcE8allocateEyPKv]+0x28): undefined reference to `tbb::internal::NFS_Allocate(unsigned long long, unsigned long long, void*)' test2.cpp:(.text$_ZN3tbb23cache_aligned_allocatorIcE10deallocateEPcy[_ZN3tbb23cache_aligned_allocatorIcE10deallocateEPcy]+0x1c): undefined reference to `tbb::internal::NFS_Free(void*)' collect2.exe: error: ld returned 1 exit status //works g++ -Wall tbb.dll.a test2.cpp tbb.dll //works if tbb.dll.a does not exits g++ -Wall -ltbb test2.cpp
-Vladimir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, that worked. Thanks!
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page