gpt4 book ai didi

c++ - 无法为 clang 指定额外的链接文件

转载 作者:行者123 更新时间:2023-11-28 08:34:44 29 4
gpt4 key购买 nike

我已经使用 clang 成功编译了我的 main.cpp,通过命令行选项指定了额外的包含路径,如下所示:clang++ -I ./Dependencies/GLFW/include/-S .\main.cpp.

但是,当我尝试通过以下命令指定附加链接库来链接它时:clang++ -L ./Dependencies/GLFW/lib/glfw3.lib .\main.s 它给我一个链接器错误 main-8b7c4e.o : error LNK2019: unresolved external symbol glfwInit referenced in function main

有什么可能出错的建议吗?我确信指定的相对路径是正确的,因为编译命令没有给我任何问题。

main.cpp

#include <iostream>
#include <GLFW/glfw3.h>

int main() {
glfwInit();
std::cout << "Hello world" << std::endl;

return 0;
}

最佳答案

-L 用于指定要在其中搜索库的文件夹。编译器会忽略不存在的目录。

你的命令行应该是:

clang++ ./Dependencies/GLFW/lib/glfw3.lib .\main.s

关于c++ - 无法为 clang 指定额外的链接文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59421193/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com