2

I have installed thrift 0.9.1 using the git repository. After building thrift I started the precompiled cpp Server and and the php client. This precompiled examples worked fine.

Now I am trying to compile my own cpp Server by following this tutorial (http://wiki.apache.org/thrift/ThriftUsageC++). I used:

g++ -DHAVE_INTTYPES_H -DHAVE_NETINET_IN_H -Wall -I/usr/local/include/thrift *.cpp -L/usr/local/lib -lthrift -o something

to compile the server which worked without errors.

When I execute the server by typing ./something I get error while loading shared libraries: libthrift-0.9.1.so: cannot open shared object file: No such file or directory.

In the lib directory are the following files:

  • libthrift.a
  • libtrift.la
  • libthrift.so
  • libtthrift-0.9.0.so
  • libtthrift-0.9.1.so

There are also libthrift_c.glib.a, libthriftnb.a and libthriftz.a and the files which belong to them, but I think they are not important for this error.

Somebody knows what's the fault?

Thx for any help

Mansuro
  • 4,558
  • 4
  • 36
  • 76
TruckerCat
  • 1,437
  • 2
  • 16
  • 39

2 Answers2

3

When a dynamic library is used (-lthrift), Linux searches for the directory containing libthrift.so in the directories within the environment variable LD_LIBRARY_PATH, you must make sure that the directory containing libthrift.so is setup correctly in the environment variable LD_LIBRARY_PATH.

Mansuro
  • 4,558
  • 4
  • 36
  • 76
  • Thanks, I set the LD_LIBRARY_PATH by following this "http://stackoverflow.com/questions/13428910/how-to-set-the-environmental-variable-ld-library-path-in-linux" – TruckerCat Jun 02 '14 at 11:39
3
Set env_var as follows,
$vim ~/.bashrc
export LD_LIBRARY_PATH=/usr/local/lib/:${LD_LIBRARY_PATH}
$source ~/.bashrc
$echo $LD_LIBRARY_PATH
$thrift -version
Hemant Thorat
  • 2,386
  • 20
  • 14