gcc如何找到-lglfw包?

gcc how find -lglfw packages?

当 cpp 代码链接时 vscode

必须像下面这样定义 json 文件。

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++ 활성 파일 빌드",
            "command": "/usr/bin/g++",
            "args": [
                "-g",
                "glad.c",
                "-pthread",
                "-o",
                "main",
                "main.cpp",
                "-lglfw",
                "-lGLU",
                "-lGL",
                "-lXrandr",
                "-lXxf86vm",
                "-lXinerama",
                "-lX11",
                "-lrt",
                "-ldl",
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "컴파일러: /usr/bin/g++"
        }
    ]
}

我的问题是 gcc 编译器如何检测 args 参数。

像-g这样的词...

因为编译器预先指定了单词,所以它查找单词并预先指定要做什么。

-lXrandr 单词是您安装的软件包的名称。 当这个名字被发现时, 编译器做什么?

编译器是否搜索预先指定的文件夹并检查包?

我想知道cpp编译器是如何连接Linux系统上的文件的。您是否有任何链接可以帮助您了解这些知识?

how gcc compiler detect args parameter.

Gcc 是一个非常 的老项目,有很多选项。它有 it's own command line options handling library.

The -lXrandr word is the name of the package you have installed

不,这不是包的名称。这是图书馆的名字。

What does the compiler do?

编译器searches for a library name libXrandr.so. In short, the file is searched in multiple directories, the standard library paths are searched and gcc installation path and additionally paths given with -L parameter and paths with LIBRARY_PATH environment variable. See also man ld.so and man ldconfig.

Does the compiler search for pre-specified folders

是的。

and check for packages?

不,“包裹”是另外一回事。 Gcc 是一个编译器,它不处理“包”。

how the cpp [*gcc] compiler connects files on the Linux system

“如何”是一个宽泛的问题,而 gcc 是一个非常复杂的程序。它打开文件,parses them 正确,查找符号,解析引用,生成最终可执行文件。

Do you have any links to help with this knowledge?

Gcc has extensive documentation 而且它是开源的。