I have some difficulty to cross compile tbb on my linux machine. My aim is to compile tbb on linux but for use on windows. The cross compiler is mingw-w64: x86_64-w64-mingw32-g++-5.2.0.
For other libraries, I normally just set CC, CXX, CFLAGS and CXXFLAGS and run configure, make, make install:
CC=x86_64-w64-mingw32-gcc-5.2.0 CXX=x86_64-w64-mingw32-g++-5.2.0 ./configure; make; make install
However for tbb, there is no such configure procedure and I was not able to modify the .inc files in build to do the same.
Has anybody already tried that? Could anybody give me some clue on how to do that?
Also I normally link statically. Any possibility to build a static library of tbb to link with my programs?
I have made progresses. I can now build tbb on linux using a cross-compiler targetting windows.
For this, I first apply the attached patch to TBB 4.4.2.
Then I run the following command:
CC=x86_64-w64-mingw32-gcc-5.2.0 CXX=x86_64-w64-mingw32-g++-5.2.0 CFLAGS="-ffloat-store" CXXFLAGS="-ffloat-store" make -j 16 tbb_build_dir=../ target=windows arch=intel64 runtime=mingw64 compiler=gcc cpp0x=1 tbb
or (32 bits) :
CC=i686-w64-mingw32-gcc-5.2.0 CXX=i686-w64-mingw32-g++-5.2.0 CFLAGS="-ffloat-store" CXXFLAGS="-ffloat-store" make -j 16 tbb_build_dir=../ target=windows arch=ia32 runtime=mingw32 compiler=gcc cpp0x=1 tbb
The only issue is this warning while building the dll:
x86_64-w64-mingw32-g++-5.2.0 -o tbb.dll concurrent_hash_map.o concurrent_queue.o concurrent_vector.o dynamic_link.o itt_notify.o cache_aligned_allocator.o pipeline.o queuing_mutex.o queuing_rw_mutex.o reader_writer_lock.o spin_rw_mutex.o x86_rtm_rw_mutex.o spin_mutex.o critical_section.o mutex.o recursive_mutex.o condition_variable.o tbb_thread.o concurrent_monitor.o semaphore.o private_server.o rml_tbb.o tbb_misc.o tbb_misc_ex.o task.o task_group_context.o governor.o market.o arena.o scheduler.o observer_proxy.o tbb_statistics.o tbb_main.o concurrent_vector_v2.o concurrent_queue_v2.o spin_rw_mutex_v2.o task_v2.o -lpsapi -shared -m64 -Wl,--version-script,tbb.def
task.o: duplicate section `.rdata$_ZTIN3tbb4taskE[_ZTIN3tbb4taskE]' has different size
arena.o: duplicate section `.rdata$_ZTIN3tbb4taskE[_ZTIN3tbb4taskE]' has different size
scheduler.o: duplicate section `.rdata$_ZTIN3tbb4taskE[_ZTIN3tbb4taskE]' has different size
Any idea why? I do not get that with native gcc compiler.
hello you need to make sure that you use the same -march and optimization options for all object files.
I see similar warning in gcc mail thread where different optimization options are used.