首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Mac Os Visual Studio Code C++ Opengl Glew Glew

Mac Os Visual Studio Code C++ Opengl Glew Glew
EN

Stack Overflow用户
提问于 2020-11-13 19:11:42
回答 1查看 423关注 0票数 0

链接项目https://github.com/nio74/templateGLad

您好,我尝试在Visual Studio代码中使用glew和glad运行Opengl应用程序(我想使用此Ide,因为它是多平台的,但如果您有任何好的建议,欢迎使用),但出现以下错误:

代码语言:javascript
复制
 > 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 

我的tasks.json:

代码语言:javascript
复制
{
    "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++"
        }
    ]
}
EN

回答 1

Stack Overflow用户

发布于 2020-11-15 15:55:16

更新,做各种研究,我设法让它工作,但我有一些事情要理解:

我无法理解tasks.Json中的变量

代码语言:javascript
复制
(

"--include-directory = include /",
"--include-directory = build /",
"--include = include / glad.c",

)

我试图将它们替换为官方指南中建议的那些(

代码语言:javascript
复制
"$ {workspaceFolder} / include",
"$ {workspaceFolder} / build",
"$ {fileDirname} /include/glad.c",

),但它们不起作用。

tasks.json:

代码语言:javascript
复制
{
    "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": []
        }
    ]

}

launch.json

代码语言:javascript
复制
    "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

代码语言:javascript
复制
    "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
}

Git:

https://github.com/nio74/templateGLad

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64819868

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档