c++ - Mac OS Visual Studio Code C++ Opengl Glad Glew
问题描述
链接项目 https://github.com/nio74/templateGLad
美好的一天,我尝试在 Visual Studio Code 中使用 glew 和高兴的方式运行 Opengl 应用程序(我想使用这个 Ide,因为它是多平台的,但如果您有任何好的建议,欢迎您),但是有这个错误:
> Executing task: C/C++: clang++ build active file <
Starting build...
Build finished with error:
Undefined symbols for architecture x86_64:
"_gladLoadGLLoader", referenced from:
_main in HelloWorld-22d65f.o
我的任务.json:
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: clang++ build active file",
"command": "/usr/bin/clang++",
"args": [
"-g",
"${workspaceFolder}/src/HelloWorld.cpp",
"-o",
"${workspaceFolder}",
"-I", "${workspaceFolder}/include/",
//"${workspaceFolder}/glad.c",
"-lglfw",
"-lglew"
],
"options": {
"cwd": "/usr/bin"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "compiler: /usr/bin/clang++"
}
]
}
解决方案
更新,做各种研究我设法使它工作,但我有一些事情要理解:
我无法理解 tasks.Json 中的变量
(
"--include-directory = include /",
"--include-directory = build /",
"--include = include / glad.c",
)
我试图用官方指南建议的替换它们(
"$ {workspaceFolder} / include",
"$ {workspaceFolder} / build",
"$ {fileDirname} /include/glad.c",
) 但它们不起作用。
任务.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "HelloWorld",
"type": "che",
"command": "clang++",
"args": [
"-std=c++17",
"-stdlib=libc++",
"-lglfw",
"-lglew",
"--include-directory=include/",
"--include-directory=build/",
"--include=include/glad.c",
//"${workspaceFolder}/include",
//"${workspaceFolder}/build",
//"${fileDirname}/include/glad.c",
"-framework",
"OpenGL",
"-framework",
"IOKit",
"-framework",
"Cocoa",
"src/helloworld.cpp",
"-o",
"build/helloworld",
"--debug"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
}
]
}
启动.json
"version": "0.2.0",
"configurations": [
{
"name": "(lldb) Launch",
"preLaunchTask": "HelloWorld",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/helloworld",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "lldb",
}
]
}
c_cpp_properties.json
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/src/",
"${workspaceFolder}/include/",
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1",
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include"
],
"defines": [],
"macFrameworkPath": [
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x86",
"browse": {
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"compilerArgs": [
"-lglfw",
"-lglew"
]
}
],
"version": 4
}
吉特:
推荐阅读
- postgresql - postgreSQL pg_dump 通过局域网
- python - 查看 UrlGatewayLogin 未返回 HttpResponse 对象。它返回 None 而不是
- database - 如何从独立工具生成实体类
- python - MySql、python、Visual Studio 代码:没有要从中获取的结果集
- javascript - 如何在退出时关闭温泉 ui 应用程序?
- r - R无法根据公式生成倾向得分;没有错误还没有计算
- javascript - jQuery Array.find() 不工作
- java - 在 AlertDialog 中更改按钮的文本
- kubernetes - 如何从 Weave Net 清单重新创建所有资源?
- c# - Newtonsoft.Json 许多项目针对不同的 .net 框架