Intel® Moderncode for Parallel Architectures
Support for developing parallel programming applications on Intel® Architecture.

Undefined reference to sync_fetch_and_add_4

smallb
Beginner
929 Views

Guys, I've build tbb with gcc 4.6.1 and when I'm trying to compile project in Qt where I've included tbb.h and parallel_for I'm getting following errors:

c:\\mingw32\\bin\\..\\lib\\gcc\\mingw32\\4.6.1\\include\\c++\\ext\\atomicity.h:48: error: undefined reference to `__sync_fetch_and_add_4'

Does anyone knows what to do about it?

0 Kudos
5 Replies
Vladimir_P_1234567890
929 Views
Hello,
Which gcc distribution do you use?
Could you try to set a define TBB_USE_GCC_BUILTINS=0
--Vladimir
0 Kudos
smallb
Beginner
929 Views

Hi Vladimir,

I'm using gcc 4.6.1.

I #define'edTBB_USE_GCC_BUILTINS 0 but I'm still getting those errors. And this is so frustrating because I've already had this working. Unfortunately I've reinstalled Windows and since then I cannot compile it. Previously (in the old Windows installation) I've had the same problem but then I remember I've defined in c++config.h this

#define _GLIBCXX_ATOMIC_BUILTINS_4

and it went through. (without this I was getting error c:\...\include\tbb\tbb_exception.h:340: error: 'exception_ptr' in namespace 'std' does not name a type)

But now it seems to be stack on this not defined reference to sync_fetch_and_add_4 and it seems that there is no way to overcome it.

Any ideas?

P.S. The Windows system is same, the qt is same there are just reinstalled.

Also, I've env vars set to:
INCLUDE = C:\Downloads\libraries\tbb40_297oss\include\tbb
LIB = C:\Downloads\libraries\tbb40_297oss\build\windows_ia32_gcc_mingw_debug
PATH= C:\Downloads\libraries\tbb40_297oss\build\windows_ia32_gcc_mingw_debug
0 Kudos
Anton_P_Intel
Employee
929 Views

smallb,

adding CXXFLAGS="-march=i686" to the make command most likely will help.
i.e.
make compiler=gcc CXXFLAGS="-march=i686"

PS: asking at TBB devoted forum (http://software.intel.com/en-us/forums/intel-threading-building-blocks/) will most likely increase chances of getting help :)

0 Kudos
TimP
Honored Contributor III
929 Views
march=i686 would be the minimum architecture to enable use of that instruction, assuming you use the 32-bit compiler. You would probably want a choice more appropriate to your CPU, if it supports SSE2 or SSE3. If you used the 64-bit compiler previously, you wouldn't encounter such an issue, as the default architecture would be opteron SSE2.
0 Kudos
smallb
Beginner
929 Views

Hi Anton,
Thank you for your reply. I'm affraid that it didn't help unfortunately.
At the end I fixed that but:

this was terrible (3 days, 2 full system reinstallations, numberous reinstallations of boost (I had to because I'm using it in my project), numerous different reinstallation of tbb (with different options)), in the end I had to:

a) add in ORIGINAL header from tbb (tbb_exception)#include

b) in exception_ptr.h had to #define _GLIBCXX_ATOMIC_BUILTINS_4

and this fortunately works.

Thank you and all people who tried to help me.
Thank you and regards.

0 Kudos
Reply