Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Joseph_A_
Beginner
1,581 Views

Linking gcc with MKL

Jump to solution

 have a sample C program that makes use of trigonometric functions. I want to compile it using GCC 6.2.0.

On using the following command, 

gcc -liomp5 -lmkl_core -lmkl_intel_thread -lmkl_intel_lp64 example_tignometry.c

I get,

example_tignometry.c:(.text+0x35): undefined reference to `sin'
example_tignometry.c:(.text+0x48): undefined reference to `cos'
example_tignometry.c:(.text+0x5b): undefined reference to `tan'
example_tignometry.c:(.text+0x6e): undefined reference to `sinh'
example_tignometry.c:(.text+0x81): undefined reference to `cosh'
example_tignometry.c:(.text+0x94): undefined reference to `tanh'
example_tignometry.c:(.text+0xa7): undefined reference to `log'
example_tignometry.c:(.text+0xba): undefined reference to `log10'
example_tignometry.c:(.text+0xcd): undefined reference to `exp'

The contents of example_tignometry.c are

#include <stdio.h>
#include <math.h>
int main(){
float i = 0.314;
       float j = 0.25;
       float k = 6.25;
       float sin_value = sin(i);
       float cos_value = cos(i);
       float tan_value = tan(i);
       float sinh_value = sinh(j);
       float cosh_value = cosh(j);
       float tanh_value = tanh(j);
       float log_value = log(k);
       float log10_value = log10(k);
       float exp_value = exp(k);

       printf("The value of sin(%f) : %f \n", i, sin_value);
       printf("The value of cos(%f) : %f \n", i, cos_value);
       printf("The value of tan(%f) : %f \n", i, tan_value);
       printf("The value of sinh(%f) : %f \n", j, sinh_value);
       printf("The value of cosh(%f) : %f \n", j, cosh_value);
       printf("The value of tanh(%f) : %f \n", j, tanh_value);
       printf("The value of log(%f) : %f \n", k, log_value);
       printf("The value of log10(%f) : %f \n",k,log10_value);
       printf("The value of exp(%f) : %f \n",k, exp_value);
       return 0;
}

Note: The operating system used is Ubuntu 14.04

 

0 Kudos
1 Solution
Gennady_F_Intel
Moderator
1,581 Views

Joseph, pls have a look what MKL Linker suggest in that case and try again. 

-L${MKLROOT}/lib/intel64 -Wl,--no-as-needed -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread -lm -ldl

View solution in original post

1 Reply
Gennady_F_Intel
Moderator
1,582 Views

Joseph, pls have a look what MKL Linker suggest in that case and try again. 

-L${MKLROOT}/lib/intel64 -Wl,--no-as-needed -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread -lm -ldl

View solution in original post

Reply