我是新的clang,因为我以前使用msvc,但我希望我的项目是跨平台。当我试图构建我的项目时,链接器由于某些原因不能链接到glfw。
对于其他函数,我还会收到一些类似这样的错误。
error LNK2019: unresolved external symbol glfwInit referenced in function main
项目结构:

Build.bat:
@echo关闭
set headerFiles=-Ilibs/headers -Isrc
set libraryFiles=-Llibs/lib/glfw3
set cppFiles=src/*.cpp
set outPutName=LearningVulkan
call clang++ %cppFiles% %headerFiles% %libraryFiles% -o bin/%outPutName%.exe发布于 2022-01-29 17:32:17
经过进一步研究,我发现我必须将文件路径与-L放在一起,然后使用-l作为实际的库名。
我的意思是
@echo off
set headerFiles=-I libs/headers -Isrc
rem add the file path with -L and then add the library with -l
set libraryFiles=-Llibs/libs -lopengl32 -lglfw3
set cppFiles=src/*.cpp
set outPutName=LearningVulkan
call clang++ %cppFiles% -DMD %headerFiles% %libraryFiles% -o bin/%outPutName%.exe
start bin/%outPutName%.exehttps://stackoverflow.com/questions/70907708
复制相似问题