无法为clang指定其他链接文件

问题描述 投票:0回答:2

我已经成功地使用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

关于可能有什么问题的任何建议?我确信指定的相对路径是正确的,因为compile命令没有给我任何问题。main.cpp

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

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

  return 0;
}
c++ linker clang linker-errors clang++
2个回答
0
投票

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

您的命令行应该是:

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

0
投票

[请在下面的链接中找到有关glfw标头包含的更多详细信息。

https://www.glfw.org/docs/latest/build_guide.html

© www.soinside.com 2019 - 2024. All rights reserved.