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