Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Problem with Ifort and drand48()

James_B_14
Beginner
633 Views

I have C code like such:

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
main(){
    double x[10000];
    int i;
    srand48(123);
    for (i - 0; i<10000; i++){
       x = tan(3.0*drand48());
    }
}

I compile it with icc:

icc -c rand.c

I link it with ifort:

ifort -nofor-main rand.o -lm

This works with the older ifort 12.0.4 and with gcc 4.4.7, but does not work with ifort 13.0.1

0 Kudos
4 Replies
James_B_14
Beginner
633 Views

I get the error "undefined reference to 'simd_drand48_pd64x2'

0 Kudos
Steven_L_Intel1
Employee
633 Views

You probably need to specify some icc libraries that ifort doesn't link to. I am moving this to the Intel C++ forum where C++ experts can advise you.

0 Kudos
Casey
Beginner
633 Views

The library you need is libirng.so.  You can link your code with ifrort using the command line:

$ ifort -nofor-main rand.o -lirng

(I tracked this down looking at the symbol table of the binary linked with icc.)

0 Kudos
James_B_14
Beginner
633 Views

That worked Casey.  Thank you for your help!

0 Kudos
Reply