在 Mac M1 上找不到“GLFW/glfw3.h”文件

时间:2021-06-02 21:43:47

标签: c++ visual-studio-code homebrew glfw apple-m1

我在一个 C++ 项目中使用 GLFW。我使用自制软件下载了 glfw3,并且在 vs 代码的 c++ 配置 json 文件的“includePath”字段中有“/opt/homebrew/include”。按照这篇文章提供的解决方案(MacOS M1 -> fatal error: 'GLFW/glfw3.h' file not found),我还使用终端命令将两个路径添加到 .zshrc 文件中:

echo -n 'export CPATH=/opt/homebrew/include' >> ~/.zshrc (I also added export CPPPATH=...)

echo -n 'export LIBRARY_PATH=/opt/homebrew/lib' >> ~/.zshrc

,分别。但是,在编译时它仍然说找不到“GLFW/glfw3.h”,即使语句完成功能正确识别了成员列表中的 GLFW 文件夹和 glfw3.h 文件。感谢您的帮助!

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1",
                "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/include",
                "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include",
                "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include",
                "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks",
                "/opt/homebrew/include",
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "macFrameworkPath": [],
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "macos-clang-arm"
        }
    ],
    "version": 4
}

tasks.json

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: clang++ build active file",
            "command": "/usr/bin/clang++",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}

launch.json

{
    "version": "0.2.0",
    "configurations": [
        
        
        {
            "name": "clang++ - Build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "lldb",
            "preLaunchTask": "C/C++: clang++ build active file"
        }
    ]
}

0 个答案:

没有答案