intel - TBB concurrent_queue errors -
can't seem compile program mention of concurrent_queue.
code contains this
#include <tbb/concurrent_queue.h>
and second add anywhere in code
concurrent_queue<int> tbbqueue;
this error on compile. able compile other tbb related code using tasks etc, reason not working.
g++ -o3 -wall -pthread -std=c++11 -ltbb -o tbbqueue.o tbbqueue.cpp tbbqueue.cpp: in function ‘void* agent(void*)’: tbbqueue.cpp:46:10: warning: unused variable ‘elements’ [-wunused-variable] tbbqueue.cpp:47:9: warning: unused variable ‘elementssize’ [-wunused-variable] /tmp/ccqg8okz.o: in function `tbb::strict_ppl::internal::concurrent_queue_base_v3<int>::~concurrent_queue_base_v3()': tbbqueue.cpp:(.text._zn3tbb10strict_ppl8internal24concurrent_queue_base_v3iied2ev[_zn3tbb10strict_ppl8internal24concurrent_queue_base_v3iied5ev]+0x10): undefined reference `tbb::internal::nfs_free(void*)' /tmp/ccqg8okz.o: in function `tbb::strict_ppl::concurrent_queue<int, tbb::cache_aligned_allocator<int> >::deallocate_block(void*, unsigned long)': tbbqueue.cpp:(.text._zn3tbb10strict_ppl16concurrent_queueiins_23cache_aligned_allocatoriieee16deallocate_blockepvm[_zn3tbb10strict_ppl16concurrent_queueiins_23cache_aligned_allocatoriieee16deallocate_blockepvm]+0x4): undefined reference `tbb::internal::nfs_free(void*)' /tmp/ccqg8okz.o: in function `tbb::strict_ppl::concurrent_queue<int, tbb::cache_aligned_allocator<int> >::allocate_block(unsigned long)': tbbqueue.cpp:(.text._zn3tbb10strict_ppl16concurrent_queueiins_23cache_aligned_allocatoriieee14allocate_blockem[_zn3tbb10strict_ppl16concurrent_queueiins_23cache_aligned_allocatoriieee14allocate_blockem]+0xf): undefined reference `tbb::internal::nfs_allocate(unsigned long, unsigned long, void*)' tbbqueue.cpp:(.text._zn3tbb10strict_ppl16concurrent_queueiins_23cache_aligned_allocatoriieee14allocate_blockem[_zn3tbb10strict_ppl16concurrent_queueiins_23cache_aligned_allocatoriieee14allocate_blockem]+0x2b): undefined reference `tbb::internal::throw_exception_v4(tbb::internal::exception_id)' /tmp/ccqg8okz.o: in function `tbb::strict_ppl::internal::concurrent_queue_base_v3<int>::~concurrent_queue_base_v3()': tbbqueue.cpp:(.text._zn3tbb10strict_ppl8internal24concurrent_queue_base_v3iied0ev[_zn3tbb10strict_ppl8internal24concurrent_queue_base_v3iied0ev]+0x10): undefined reference `tbb::internal::nfs_free(void*)' /tmp/ccqg8okz.o: in function `tbb::strict_ppl::concurrent_queue<int, tbb::cache_aligned_allocator<int> >::~concurrent_queue()': tbbqueue.cpp:(.text._zn3tbb10strict_ppl16concurrent_queueiins_23cache_aligned_allocatoriieeed2ev[_zn3tbb10strict_ppl16concurrent_queueiins_23cache_aligned_allocatoriieeed5ev]+0x12d): undefined reference `tbb::internal::nfs_free(void*)' /tmp/ccqg8okz.o: in function `tbb::strict_ppl::concurrent_queue<int, tbb::cache_aligned_allocator<int> >::~concurrent_queue()': tbbqueue.cpp:(.text._zn3tbb10strict_ppl16concurrent_queueiins_23cache_aligned_allocatoriieeed0ev[_zn3tbb10strict_ppl16concurrent_queueiins_23cache_aligned_allocatoriieeed0ev]+0x12d): undefined reference `tbb::internal::nfs_free(void*)' /tmp/ccqg8okz.o: in function `main': tbbqueue.cpp:(.text.startup+0x32): undefined reference `tbb::internal::nfs_allocate(unsigned long, unsigned long, void*)' collect2: error: ld returned 1 exit status make: *** [tbbqueue.o] error 1
the order, in specify libraries , source/object files linking, matters. see more details here: why order in libraries linked cause errors in gcc?
in case, flag link tbb (-ltbb
) specified in command line prior program source file (tbbqueue.cpp
). when linker processed tbb library had seen no code uses it, decided unnecessary, , removed symbols consideration. then, saw external symbols in object file compiled tbbqueue.cpp
, not libraries these symbols found.
if order of options changed this:
g++ -o3 -wall -pthread -std=c++11 -o tbbqueue.o tbbqueue.cpp -ltbb
the compilation should succeed.
Comments
Post a Comment