0

I have written a small HTTPServer application using Poco and I get the following error during runtime:

factoryProject> ./httpServer ./httpServer: error while loading shared libraries: libPocoNet.so.16: cannot open shared object file: No such file or directory

My libraries successfully linked during compilation because they were located in a specific directory that I pointed to in my make file using a -L/some/path.

I have read up on the ldconfig command and it stated that it usually looks for libraries in /usr/lib, but I do not have admin privee to add the Poco libraries into that directory.

How do I point to that a custom library directory so that ld will load it during runtime?

Jake88
  • 955
  • 1
  • 19
  • 39

1 Answers1

0

I have looked into a few possible solutions with the most popular being to add a config file for ldconfig to pickup, but this solution seems complicated and I do not want to add a config file to this common server.

The solution that was the simplest for me was to update the following environment variable:

echo $LD_LIBRARY_PATH

The LD_LIBRARY_PATH environment variable can list directories where libraries are searched for first during runtime and after setenv command I have a working HTTP server!

Jake88
  • 955
  • 1
  • 19
  • 39
  • 1
    You're better off also passing in: `-Wl,-rpath,/some/path` to the link line of the program so it looks in that location when running rather than relying on the environment variable. the `-L` option does link time, the `-Wl,-rpath` embeds it into the binary for run-time – Anya Shenanigans Jun 16 '14 at 17:32
  • @Petesh Great suggestion. I actually prefer this since it brings the definition of the path into the makefile. After reading the following [link](http://blog.tremily.us/posts/rpath/) I updated my LDFLAGS to the following: `LDFLAGS=-lPocoNet -lPocoUtil -lPocoFoundation -lPocoXML -Wl,-rpath=$(LIB_DIR),--enable-new-dtags` – Jake88 Jun 16 '14 at 20:06