Reputation: 11
So I'm currently using Lubuntu 18.4 32bit and was trying to get the GLFW library up and going. I noticed that when you compile a program using GLFW you need to link many libraries and was wondering where exactly does g++ look in the filesystem when you type g++ main.cpp -lglfw
?
Upvotes: 1
Views: 2837
Reputation: 1451
echo | g++ -x c++ -E -Wp,-v - >/dev/null
echo |
prints empty "source code" and closes stdin-x c++
to specify the language (with this option it prints more detailed info)-E
says g++
to stop after preprocessing stage-
at the end means read code from stdin-Wp,-v
to pass -v
directly to preprocessor>/dev/null
to redirect extra output to /dev/null
(void)Example output:
ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../include/c++/10.2.0
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../include/c++/10.2.0/x86_64-pc-linux-gnu
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../include/c++/10.2.0/backward
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/include
/usr/local/include
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/include-fixed
/usr/include
End of search list.
ld --verbose | grep SEARCH_DIR | tr -s ' ;' \\012
--verbose
tells ld
to print settings info| grep SEARCH_DIR
select lib directory info| tr -s ' ;' \\012
makes output pretty (replace ;
with new line)Example output:
SEARCH_DIR("/usr/x86_64-pc-linux-gnu/lib64")
SEARCH_DIR("/usr/lib")
SEARCH_DIR("/usr/local/lib")
SEARCH_DIR("/usr/x86_64-pc-linux-gnu/lib")
So the GLFW library should be in one of those directories.
Source: https://transang.me/library-path-in-gcc/
Upvotes: 4