Compiling and running applications on Linux involves more than just writing code. Developers must also understand the intricacies of environment variables and command-line tools that dictate where compilers and runtime environments look for necessary files. In this post, we will cover some of them.
Default Search Paths
- Header Files: Compilers like
gccandg++typically look for header files in standard directories such as/usr/includeor/usr/local/include. These are the places where most system and third-party libraries install their header files. - Libraries: For libraries, the linker (
ld) searches in directories like/usr/lib,/usr/local/lib, and sometimes in more specific directories that depend on the machine’s architecture (like/usr/lib/x86_64-linux-gnuon 64-bit systems).
