Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
Announcements
The Intel sign-in experience has changed to support enhanced security controls. If you sign in, click here for more information.

Problem with Ifort and drand48()

James_B_14
Beginner
429 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
429 Views

I get the error "undefined reference to 'simd_drand48_pd64x2'

Steven_L_Intel1
Employee
429 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.

Casey
Beginner
429 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.)

James_B_14
Beginner
429 Views

That worked Casey.  Thank you for your help!

Reply