0

My Problem

I want to use restbed on my C++ project, and I follow the instruction to install it on my ubuntu machine. I installed the include file to /usr/local/include and library file to /usr/local/library.

Problem is:

@ubuntu:~/test$ g++ test.cpp -o test -lrestbed -std=c++11
/usr/bin/ld: cannot find -lrestbed
collect2: error: ld returned 1 exit status

It means ubuntu knows where my include files are, but has no idea where the link files are or link files are damaged. And things are getting weird, see last section.

What I've done

I have searched many solutions for this problem, including this. I follow the guild and added /usr/local/lib and /usr/local/library to /etc/ld.so.conf, so basically my linker knows where to find link files.

@ubuntu:~/test$ cat /etc/ld.so.conf
include /etc/ld.so.conf.d/*.conf
/usr/loacl/lib
/usr/local/library

And when I g++ again I failed, same error message. I've even tried export LD_LIBRARY_PATH="/usr/local/library", and I also ran sudo ldconfig but still no luck.

Weird Solution

So I found that I can compile it with this command:

g++ -L /usr/local/library test.cpp -o test -lrestbed -std=c++11

And everything works like charm. So my link files are fine, and I am confused ... why the system PATH is not working? And how do I solve this? (I don't want to type the long path every time and it gets verbose when I use more third-party libraries).

My system:

ubuntu 16.04 LTS running on parallel desktop

g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609

Community
  • 1
  • 1
catq
  • 127
  • 1
  • 6
  • 1
    `LD_LIBRARY_PATH` is used a runtime. `LIBRARY_PATH` at link time. Consider using a Makefile where you specify the `-L` options though. Then you only type `make`. http://stackoverflow.com/a/4250666/1116364 – Daniel Jour May 10 '17 at 07:57
  • @DanielJour Thanks a lot, your answer reminds me my searching key words are wrong. Problem solved when I typed in `LD_LIBRARY_PATH vs LIBRARY_PATH `. – catq May 11 '17 at 23:32

0 Answers0