Visual Studio代码-找不到SFML库

问题描述 投票:1回答:1

我正在尝试在VScode中尝试SFML,但是找不到适合我的库。

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

这是主要课程:

#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 <iostream>,出现此错误:

#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (/Users/arnavchandra/Desktop/tic/main.cpp).

对于#include <Graphics.hpp>,出现此错误:

cannot open source file "SFML/Window.hpp" (dependency of "Graphics.hpp")

运行时,出现此错误:

main.cpp:2:10: fatal error: 'Window.hpp' file not found 1 error generated.

c++ visual-studio-code sfml
1个回答
0
投票

您应该尝试在SFML-2.5.1-macos-clang/include/**中放置SFML-2.5.1-macos-clang/include/SFML/而不是includePath

© www.soinside.com 2019 - 2024. All rights reserved.