2

I declared a function foo() in a header file imp.h and implemented it in imp.c. Then I generated a shared library named libimp.so and in my Pin tool I called foo().

In order to link the tool with this new library I added the following definitions to makefile.rules in its directory:

TOOL_CXXFLAGS += -I/path/to/imp.h
TOOL_LPATHS += -L/path/to/libimp.so
TOOL_LIBS += -limp

I also set LD_LIBRARY_PATH to the /path/to/libimp.so. But, at runtime, if I use foo(), the following error will be received:

dlopen failed. library "libimp.so" not found.

The library is OK when I call it from a simple test program. Any ideas?

TheAhmad
  • 810
  • 1
  • 9
  • 21

1 Answers1

0

I also set LD_LIBRARY_PATH to the /path/to/libimp.so

If the full path to libimp.so is literally /path/to/libimp.so, then the correct value for LD_LIBRARY_PATH is /path/to, and not /path/to/libimp.so.

(It isn't clear from your question whether you understand this.)

You may wish to link your pintool with -Wl,--rpath=/path/to so you don't have to set LD_LIBRARY_PATH at all.

Employed Russian
  • 199,314
  • 34
  • 295
  • 362
  • The path is OK. I also used -Wl,--rpath=/path/to, but the error exists. There is a similar problem here: https://stackoverflow.com/questions/37707344/how-to-link-dramsim2-library-interface-with-a-pintool. – TheAhmad Dec 11 '17 at 22:15