Question

I'm trying to compile code with ICC and facing an error:

/opt/intel/composer_xe_2013.2.146/compiler/include/xmmintrin.h(82): error:
linkage specification is incompatible with previous "_mm_malloc" (declared at
line 38 of "/usr/lib/gcc/x86_64-redhat-linux/4.4.7/include/mm_malloc.h")
extern void* __ICL_INTRINCC _mm_malloc(size_t, size_t);

Looks like ICC and GCC conflict. But I can't exclude GCC from $PATH. How to fix this confusion?

Was it helpful?

Solution

The problem was in the code I compile. We include malloc header, which is different for ICC and GCC. And there was the GCC header name.

The solution is:

#if defined(__INTEL_COMPILER)
#include <malloc.h>
#else
#include <mm_malloc.h>
#endif // defined(__GNUC__)

OTHER TIPS

I had the same problem, with the Intel compiler getting confused by the declarations in the gcc header <mm_malloc.h>, but in my case that header was getting dragged in by a library header I didn't want to change.

What worked for me was to globally disable mm_malloc.h by triggering its own include guard with a #define, like:

icc -D_MM_MALLOC_H_INCLUDED=1    main.cpp -o main

You could also disable it in a single file or header using the same #define:

#ifdef __INTEL_COMPILER
#  define _MM_MALLOC_H_INCLUDED 1 /* disables gcc's <mm_malloc.h>, for Intel */
#endif

The Intel compiler picks up its own definitions of mm_malloc from xmmintrin (or the other SSE/AVX headers), so this works even if somebody's calling mm_malloc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top