Useful GCC options: -Print-search-DIRS

xiaoxiao2021-03-05  27

GCC's option "-l" is used to specify the library that needs to be connected, and GCC looks for a specified library in the system's standard directory. What is these standard directories?

Generally, it should be / usr / lib and / lib, but different systems may be different; sometimes we want to know the order of these standard catalogs,

At this time, you can use the GCC's option -Print-search-DIRS, below is the result of the execution under my Debian:

$ GCC -PRINT-Search-DIRS

Install: /usr/lib/gcc-lib/i486-linux/3.3.5

Programs: = / usr / lib / gcc-lib / i486-linux / 3.3.5 /: / usr / lib / gcc-lib / i486-linux / 3.3.5 /: / usr / lib / gcc-lib / i486- Linux /: / usr / liB / gcc / i486-linux / 3.3.5 /: / usr / lib / gcc / i486-linux /: / usr / lib / gcc-lib / i486-linux / 3.3.5 /. /../..../i486-linux/bin/i486-linux/3.3.5/:/usr/lib/gcc-lib/i486-linux/3.3.5/../ .. /../i486-linux/bin/

Libraries: = / usr / lib / gcc-lib / i486-linux / 3.3.5 /: / usr / lib / gcc / i486-linux / 3.3.5 /: / usr / lib / gcc-lib / i486-linux / 3.3.5 /../../../../ i486-linux / lib / i486-linux / 3.3.5 /: / usr / liB / GCC-LIB / I486-Linux / 3.3.5 / .. /../../../i486-linux/lib/:/usr/lib/gcc-lib/i486-linux/3.3.5/../../../i486-linux/3.3.5 /:/oss/lib/gcc-lib/i486-linux/3.3.5/../../..:/lib/i486-linux/3.3.5/:/lib/:/usr/lib/ I486-Linux / 3.3.5 /: / usr / lib /

It can be seen that on my system, the search order of the standard directory is / lib, / usr / lib, and this also outputs the GCC installation directory and program search directory, which may also be helpful for GCC troubleshooting.

转载请注明原文地址:https://www.9cbs.com/read-32220.html

New Post(0)