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

ICPC link problem (pthread_atfork undefined reference) libiomp5.so

fbash1
Beginner
732 Views
Hi, i'm testing a small program that i've created. it compiles using icpc without any flags and pragmas, but when i want use the OpenMP (with the -openmp flag) i'm getting this error:
[bash] . . . clean done
 . . . build ltpar.cpp done : ltpar.o
 . . . building the library libltpar.so done
ld: warning: cannot find entry symbol _start; not setting start address
/opt/intel/composerxe-2011.2.137/compiler/lib/ia32/libiomp5.so: undefined reference to `pthread_atfork'[/bash]
Also i dont know is related but here is the ld and ldd info of iomp5:
[bash]ldd /opt/intel/composerxe-2011.2.137/compiler/lib/ia32/libiomp5.so
        linux-gate.so.1 =>  (0x00528000)
        libc.so.6 => /lib/libc.so.6 (0x00110000)
        libdl.so.2 => /lib/libdl.so.2 (0x0052a000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x003c5000)
        /lib/ld-linux.so.2 (0x00be1000)[/bash]
[bash]ld /opt/intel/composerxe-2011.2.137/compiler/lib/ia32/libiomp5.so[/bash]
[bash]
ld: warning: cannot find entry symbol _start; not setting start address
/opt/intel/composerxe-2011.2.137/compiler/lib/ia32/libiomp5.so: undefined reference to `__umoddi3'
/opt/intel/composerxe-2011.2.137/compiler/lib/ia32/libiomp5.so: undefined reference to `__moddi3'
/opt/intel/composerxe-2011.2.137/compiler/lib/ia32/libiomp5.so: undefined reference to `pthread_atfork'[/bash]
I've done and test everything (see at the bottom) that i've found on this forum and internet, but the problem stills...
I'm using :
icpc (ICC) 12.0.2 20110112
Copyright (C) 1985-2011 Intel Corporation. All rights reserved.
icpc (ICC) 12.0.2 20110112Copyright (C) 1985-2011 Intel Corporation. All rights reserved.
Environment:
    • gcc (GCC) 4.5.1 20100924 (Red Hat 4.5.1-4)
    • RHEL 5.5
This is the Makefile:
[bash]CXX=icpc
CC=icc
LD=icpc
CFLAGS=-openmp -liomp5 -pthread
LDFLAGS=-openmp -liomp5 -pthread

LTPAR_LIB=ltpar
OBJFILES := $(patsubst %.cpp,%.o,$(wildcard *.cpp))

all: lib

lib: $(OBJFILES)
	@$(LD) -shared -o lib$(LTPAR_LIB).so $(OBJFILES) $(LDFLAGS)
	@echo " . . . building the library lib$(LTPAR_LIB).so done"
	@ld lib$(LTPAR_LIB).so 

%.o: %.cpp
	@$(CXX) -c $< $(CFLAGS)
	@echo " . . . build $< done : $@"

clean:
	@rm -rf *.o
	@rm -rf *.so
	@rm -rf *~
	@rm -rf *.out
	@echo " . . . clean done"[/bash]
This is the cpp code (i've not put the .h file ( void corest() ) ):
[cpp]#define ASIZE 2000000

#include 
#include 
#include 

void corest()
{
  float *rowsA = new float[ASIZE];
  float *columnsA = new float[ASIZE];
	
  float *rowsB = new float[ASIZE];
  float *columnsB = new float[ASIZE];
	
  float *rowsC = new float[ASIZE];
  float *columnsC = new float[ASIZE];
	
  for(int i=0; i = (float)rand()* (float)rand();
      columnsA = (float)rand() * (float)rand();
    }
	
  for(int i=0; i = (float)rand()* (float)rand();
      columnsB = (float)rand() * (float)rand();
    }

  int procn = omp_get_num_procs();	
  #pragma omp parallel for num_threads(4) shared(rowsC,columnsC,rowsA,columnsB)
  for(int i=0; i = rowsA * columnsB;
	}
		
      for(int j=0; j = rowsA / columnsB;
	}
    }
	
  delete [] rowsA;
  delete [] columnsA;
	
  delete [] rowsB;
  delete [] columnsB;
	
  delete [] rowsC;
  delete [] columnsC;

}[/cpp]
Any ideas? something wrong on the linking? i've done everything using -lpthread, -pthread, changing the order of libs, adding the mkl libs, -lpthread_nonshared... Maybe there's something on the linking or the compilation that im not doing.
Is the same behavior using the -parallel flag instead of using the -openmp flag.
Thanks in advance.,
p.s.: the files are attached as a tar.gz.
0 Kudos
1 Reply
Om_S_Intel
Employee
732 Views

You need to supply Cruntime libraries to ld to link. Unless you are expert, it is safer to use "icpc" or g++ in place of "ld" to make life easier.

0 Kudos
Reply