Visual Studio Code - 找不到 SFML 库 [英] Visual Studio Code - SFML libraries not found

查看:58
本文介绍了Visual Studio Code - 找不到 SFML 库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 VScode 中使用 SFML,但是我找不到这些库.

I'm trying to experiment with SFML in VScode, but the libraries aren't being found for me.

我已尝试更改 c_cpp_properties.json 文件以将库添加到 includePath,但仍未找到它们.

I've tried changing the c_cpp_properties.json file to add the libraries to the includePath, but they're still not being found.

这是主类:

#include <iostream>
#include <Window.hpp>
#include <Graphics.hpp>



int main()
{
    // create the window
    sf::RenderWindow window(sf::VideoMode(800, 600), "My window");

    // run the program as long as the window is open
    while (window.isOpen())
    {
        // check all the window's events that were triggered since the last iteration of the loop
        sf::Event event;
        while (window.pollEvent(event))
        {
            // "close requested" event: we close the window
            if (event.type == sf::Event::Closed)
                window.close();
        }

        // clear the window with black color
        window.clear(sf::Color::Black);

        // draw everything here...
        // window.draw(...);

        // end the current frame
        window.display();
    }

    return 0;
}

这是属性文件:

{
    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "/Users/arnavchandra/Desktop/tic/SFML-2.5.1-macos-clang/include/SFML/"
            ],
            "defines": [],
            "macFrameworkPath": [
                "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks"
            ],
            "compilerPath": "/usr/bin/clang",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "clang-x64"
        }
    ],
    "version": 4
}

对于 #include ,我收到此错误:

For #include <iostream>, I'm getting this error:

#include 检测到错误.请更新您的包含路径.此翻译单元 (/Users/arnavchandra/Desktop/tic/main.cpp) 禁用 Squiggles.

对于 #include ,我收到此错误:

For #include <Graphics.hpp>, I'm getting this error:

无法打开源文件SFML/Window.hpp"(Graphics.hpp"的依赖)

当我运行它时,我收到此错误:

When I run it, I get this error:

main.cpp:2:10: 致命错误:找不到Window.hpp"文件产生了 1 个错误.

推荐答案

你应该尝试把 SFML-2.5.1-macos-clang/include/** 而不是 SFML-includePath 中的 2.5.1-macos-clang/include/SFML/.

You should try to put SFML-2.5.1-macos-clang/include/** instead of SFML-2.5.1-macos-clang/include/SFML/ in includePath.

这篇关于Visual Studio Code - 找不到 SFML 库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆