0

I need to vectorize a loop with a call to the exp-function in math.h. However, compiling a file with this

#include <math.h>
#include <omp.h>

#pragma omp declare simd
extern double __cdecl exp(double);

seems not to be possible, as I get the following error

D:\Dropbox\OpenMP>gcc -O3 -fopenmp testSIMD.c
C:\Users\JEPPED~1\AppData\Local\Temp\ccfKxQRJ.o:testSIMD.c:(.text+0x198): undefi
ned reference to `_ZGVcN4v_exp'
C:\Users\JEPPED~1\AppData\Local\Temp\ccfKxQRJ.o:testSIMD.c:(.text+0x348): undefi
ned reference to `_ZGVdN4v_exp'
C:\Users\JEPPED~1\AppData\Local\Temp\ccfKxQRJ.o:testSIMD.c:(.text.startup+0x26f)
: undefined reference to `_ZGVbN2v_exp'
C:\Users\JEPPED~1\AppData\Local\Temp\ccfKxQRJ.o:testSIMD.c:(.text.startup+0x286)
: undefined reference to `_ZGVbN2v_exp'
C:\Users\JEPPED~1\AppData\Local\Temp\ccfKxQRJ.o:testSIMD.c:(.text.startup+0x3af)
: undefined reference to `_ZGVbN2v_exp'
C:\Users\JEPPED~1\AppData\Local\Temp\ccfKxQRJ.o:testSIMD.c:(.text.startup+0x3c6)
: undefined reference to `_ZGVbN2v_exp'
collect2.exe: error: ld returned 1 exit status

I am using TDM-GCC 4.9.2 on a Windows 7 machine.

What is the problem? Any solutions?

  • possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Ivan Aksamentov - Drop Apr 11 '15 at 13:29

1 Answers1

0

You need to add the math library to the list of libraries to link with:

gcc -O3 -fopenmp testSIMD.c -lm

Unlike other libraries, this is not added by default.

But I don't think it will help you. The #pragma omp declare simd applies to new function declarations, not existing library functions. You may need to write your own version of exp().

mcleod_ideafix
  • 11,128
  • 2
  • 24
  • 32