提问人:Mason Cooreman 提问时间:11/7/2023 最后编辑:Mason Cooreman 更新时间:11/7/2023 访问量:55
vscode GLFW/GLAD 拒绝编译
vscode GLFW/GLAD refusing to compile
问:
我正在尝试获得运行 opengl 程序的环境,我遵循了以下教程: https://medium.com/@vivekjha92/setup-opengl-with-vs-code-82852c653c43 据我所知,我已经正确地完成了所有操作,但是当我点击运行按钮时,编译器说有一堆未定义的引用,谁能帮我运行它?
tasks.json文件:
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe build active file",
"command": "C:\\MinGW\\bin\\g++.exe",
"args": [
"-g",
"-std=c++17",
"-I${workspaceFolder}/include",
"-L${workspaceFolder}/lib",
"${workspaceFolder}/src/\\*.cpp",
"${workspaceFolder}/src/glad.c",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"-lglfw3dll"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
launch.json文件:
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++: g++.exe build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/myprogram.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe build active file"
}
]
}
错误:
C:\Users\176542\AppData\Local\Temp\ccl505PU.o: In function `main':
C:/Users/176542/Desktop/Physics_OpenGL/src/main.cpp:17: undefined reference to `glfwInit'
C:/Users/176542/Desktop/Physics_OpenGL/src/main.cpp:18: undefined reference to `glfwWindowHint'
C:/Users/176542/Desktop/Physics_OpenGL/src/main.cpp:19: undefined reference to `glfwWindowHint'
C:/Users/176542/Desktop/Physics_OpenGL/src/main.cpp:20: undefined reference to `glfwWindowHint'
C:/Users/176542/Desktop/Physics_OpenGL/src/main.cpp:28: undefined reference to `glfwCreateWindow'
C:/Users/176542/Desktop/Physics_OpenGL/src/main.cpp:32: undefined reference to `glfwTerminate'
C:/Users/176542/Desktop/Physics_OpenGL/src/main.cpp:35: undefined reference to `glfwMakeContextCurrent'
C:/Users/176542/Desktop/Physics_OpenGL/src/main.cpp:36: undefined reference to `glfwSetFramebufferSizeCallback'
C:/Users/176542/Desktop/Physics_OpenGL/src/main.cpp:40: undefined reference to `glfwGetProcAddress'
C:/Users/176542/Desktop/Physics_OpenGL/src/main.cpp:48: undefined reference to `glfwWindowShouldClose'
C:/Users/176542/Desktop/Physics_OpenGL/src/main.cpp:61: undefined reference to `glfwSwapBuffers'
C:/Users/176542/Desktop/Physics_OpenGL/src/main.cpp:62: undefined reference to `glfwPollEvents'
C:/Users/176542/Desktop/Physics_OpenGL/src/main.cpp:67: undefined reference to `glfwTerminate'
C:\Users\176542\AppData\Local\Temp\ccl505PU.o: In function `Z12processInputP10GLFWwindow':
C:/Users/176542/Desktop/Physics_OpenGL/src/main.cpp:75: undefined reference to `glfwGetKey'
C:/Users/176542/Desktop/Physics_OpenGL/src/main.cpp:76: undefined reference to `glfwSetWindowShouldClose'
collect2.exe: error: ld returned 1 exit status
答: 暂无答案
评论
-lglfw3dll
-lglfw3