简体   繁体   English

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

[英]Cannot specify additional link file for clang

I've successfully compiled my main.cpp with clang, specifying additional include path via the command line options as follows: clang++ -I ./Dependencies/GLFW/include/ -S .\\main.cpp .我已经成功地用 clang 编译了我的 main.cpp,通过命令行选项指定了额外的包含路径,如下所示: clang++ -I ./Dependencies/GLFW/include/ -S .\\main.cpp

However, when I try to link it by specifying the additional link library by the following command: clang++ -L ./Dependencies/GLFW/lib/glfw3.lib .\\main.s it gives me a linker error main-8b7c4e.o : error LNK2019: unresolved external symbol glfwInit referenced in function main .但是,当我尝试通过以下命令指定附加链接库来链接它时: clang++ -L ./Dependencies/GLFW/lib/glfw3.lib .\\main.s它给了我一个链接器错误main-8b7c4e.o : error LNK2019: unresolved external symbol glfwInit referenced in function main

Any suggestions on what might be wrong?关于可能出什么问题的任何建议? I'm sure that the relative path specified is correct, since the compile command gave me no issues.我确定指定的相对路径是正确的,因为编译命令没有给我任何问题。

main.cpp

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

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

  return 0;
}

-L is for specifying folders to search for libraries in. The compiler ignores directories that don't exist. -L用于指定要在其中搜索库的文件夹。编译器会忽略不存在的目录。

Your command line should be:你的命令行应该是:

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

Please find below link for more detail about glfw header inclusion.有关 glfw 标头包含的更多详细信息,请参阅以下链接。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法在同一解决方案中的 2 个项目之间链接,并且我没有用于其他依赖项的 .Lib 文件 - Cannot Link between 2 projects in the same solution, and i dont have a .Lib File for additional dependencies "链接:致命错误 LNK1104:无法打开文件 &#39;clang_rt.asan_dynamic_runtime_thunk-x86_64.lib&#39;" - LINK : fatal error LNK1104: cannot open file 'clang_rt.asan_dynamic_runtime_thunk-x86_64.lib' 如何指定 clang 格式的文件? - How do I specify a clang-format file? CMake OpenCV无法指定链接库 - CMake OpenCV Cannot Specify Link Libraries 无法为目标错误CMakeLists指定链接库 - Cannot specify link libraries for target error CMakeLists Clang编译:“无法执行二进制文件” - Clang compilation : "Cannot execute binary file" clang ++ link failure:错误:源文件无效UTF-8? - clang++ link failure: error: source file is not valid UTF-8? 如何使用额外的解析器扩展Clang? - How to extend Clang with an additional parser? 无法打开源文件,更改了其他目录 - Cannot open source file, additional directory changed 将Xcode 9.0与clang一起使用时发生编译错误(生成多个输出文件时无法指定-o) - Compilation error when using Xcode 9.0 with clang (cannot specify -o when generating multiple output files)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM