gpt4 book ai didi

c++ - Visual Studio Code - 未找到 SFML 库

转载 作者:太空宇宙 更新时间:2023-11-04 12:36:38 38 4
gpt4 key购买 nike

我正在尝试在 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.

最佳答案

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

关于c++ - Visual Studio Code - 未找到 SFML 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56157829/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com