0

I think this is a generic problem not specifically related to Cap'n Proto.

My project's build succeeds but on run I get:

error while loading shared libraries: libcapnp-0.5.3.so: cannot open shared object file: No such file or directory

Maybe I am missing something in CMake?

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lcapnp -lkj")

I verified libcapnp-0.5.3.so exists in /usr/local/lib

I also tried adding:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -L/usr/local/lib/libcapnp-0.5.3.so")
BAR
  • 15,909
  • 27
  • 97
  • 185
  • i am not sure. did you try to make a symbolic link to it and name it `libcapnp.so`? – Jason Hu Aug 13 '15 at 02:51
  • @HuStmpHrrr When I run `ls -l` in `/usr/local/lib` I see that `libcapnp.so -> libcapnp-0.5.3.so` so I guess this has already been done by the installer. – BAR Aug 13 '15 at 02:53
  • another explanation is this folder is not in the search path of rt linker. – Jason Hu Aug 13 '15 at 02:54
  • 1
    `echo $LD_LIBRARY_PATH` what do you have? – Jason Hu Aug 13 '15 at 02:55
  • @HuStmpHrrr nothing is there... should I add `/usr/local/lib`? – BAR Aug 13 '15 at 02:56
  • @HuStmpHrrr Erm.. no, he should not. That's the nuclear option. – Pradhan Aug 13 '15 at 02:59
  • @Pradhan i think it's ok. since op is in dev env and doing this helps to try out where the problem locates. it's bad only if, say, an installer silently exports this variable to environment and put it somewhere in autorun script. – Jason Hu Aug 13 '15 at 03:02
  • @HuStmpHrrr Added it to `LB_LIBRARY_PATH` and restarted (because it wasn't working) but it disappeared. Researching this now. – BAR Aug 13 '15 at 03:06
  • @HuStmpHrrr If you are suggesting that he use it as a quick check to ascertain the viability of his `libcapnp.so`, yes, that isn't a problem. For the OP's benefit, please note that you almost never want to use `LD_LIBRARY_PATH` as the final solution - see [here](http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html). – Pradhan Aug 13 '15 at 03:07
  • Got it working, thanks for your help guys. – BAR Aug 13 '15 at 03:09
  • @BAR no restart is required. I take that as not working too? – Jason Hu Aug 13 '15 at 03:10
  • @HuStmpHrrr I had not run `ldconfig` so that is probably why it did not work. – BAR Aug 13 '15 at 03:12
  • If that's the problem after setting LD_LIBRARY_PATH you should see your program working. That's a little bit weird. Anyways, good to know problem solved. – Jason Hu Aug 13 '15 at 03:15
  • @Pradhan Agreed. But nonetheless it's very convenient probe with little side effect. – Jason Hu Aug 13 '15 at 03:20

1 Answers1

3

/usr/local/lib needs to be added to /etc/ld.so.conf

then run sudo ldconfig to load the changes.

BAR
  • 15,909
  • 27
  • 97
  • 185