Linking problem with libitm

Linking problem with libitm

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

5 posts / 0 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels 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

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

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

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.

Connectez-vous pour laisser un commentaire.