Linking problem with libitm

Linking problem with libitm

Imagen de iddqd

Hi,

I am trying to create a shared library that uses some functions defined in itmuser.h If I use _ITM_getThreadnum function following error occurs:

relocation R_X86_64_32S against `_ITM_nvFunctions' can not be used when making a shared object; recompile with -fPIC

way to reproduce:

#include 


void foo()
{
  int thread_num = _ITM_getThreadnum();
}

and then compile with icc -shared -Qtm_enabled -fbuiltin

Is this expected behavior?

Thanks,
Dennis

publicaciones de 5 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.
Imagen de Ravi Narayanaswamy (Intel)
Quoting - iddqd Hi,

I am trying to create a shared library that uses some functions defined in itmuser.h If I use _ITM_getThreadnum function following error occurs:

relocation R_X86_64_32S against `_ITM_nvFunctions' can not be used when making a shared object; recompile with -fPIC

way to reproduce:

#include 


void foo()
{
  int thread_num = _ITM_getThreadnum();
}

and then compile with icc -shared -Qtm_enabled -fbuiltin

Is this expected behavior?

Thanks,
Dennis

Yes, this is the expected behavior. Use -fPIC when created shared objects

Imagen de iddqd
Quoting - Ravi Narayanaswamy (Intel)
Yes, this is the expected behavior. Use -fPIC when created shared objects

sorry, I just forget to mention -fPIC option in previous post. it does not work with -fPIC too

icc -shared -Qtm_enabled -fbuiltin -fPIC test.c
ld: /opt/intel/Compiler/11.0/606/lib/intel64/libitm.a(dynamic_linkage.o): relocation R_X86_64_32S against `_ITM_nvFunctions' can not be used when making a shared object; recompile with -fPIC
/opt/intel/Compiler/11.0/606/lib/intel64/libitm.a: could not read symbols: Bad value

Imagen de Ravi Narayanaswamy (Intel)
Quoting - iddqd

sorry, I just forget to mention -fPIC option in previous post. it does not work with -fPIC too

icc -shared -Qtm_enabled -fbuiltin -fPIC test.c
ld: /opt/intel/Compiler/11.0/606/lib/intel64/libitm.a(dynamic_linkage.o): relocation R_X86_64_32S against `_ITM_nvFunctions' can not be used when making a shared object; recompile with -fPIC
/opt/intel/Compiler/11.0/606/lib/intel64/libitm.a: could not read symbols: Bad value

Unfortunately the libitm.a was not built with -fPIC so you will not be able to create shared objects with libitm.a

Imagen de rsch
what worked for me was to link the shared itm lib explicitly: icc -shared -Qtm_enabled -fbuiltin -litmdyn i'm not sure whether things work afterwards for you but compilation and execution seems to work.

Inicie sesión para dejar un comentario.