c++ - 我需要帮助在 VSCode 中使用 SFML (Mac) 创建一个窗口
问题描述
好的,我承认我不是最好的编码员,但我正在努力学习。我对 Java 有一点了解,并且想学习 C++ 来扩展我的技能。我想通过使用 SFML 库创建 Chess 来巩固我的 C++ 技能。我从https://github.com/andrew-r-king/sfml-vscode-boilerplate安装了 SFML,然后运行了样板文件附带的 main.cpp,它工作正常。但是我试图将它复制到一个单独的文件中,但是我无法编译它。我正在用 g++ 编译它,但它不起作用。我似乎不知道为什么。
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(512, 512), "Chess by Nabid Kabir", sf::Style::Titlebar | sf::Style::Close);
while (window.isOpen())
{
sf::Event e;
while(window.pollEvent(e))
{
if(e.type == e.Closed)
{
window.close();
}
}
}
return 0;
}
这是我尝试构建和运行时遇到的错误
Starting build...
Build finished with errors(s):
Undefined symbols for architecture x86_64:
"sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)", referenced from:
_main in chess-e62717.o
"sf::RenderWindow::~RenderWindow()", referenced from:
_main in chess-e62717.o
"sf::String::String(char const*, std::__1::locale const&)", referenced from:
_main in chess-e62717.o
"sf::Window::close()", referenced from:
_main in chess-e62717.o
"sf::Window::pollEvent(sf::Event&)", referenced from:
_main in chess-e62717.o
"sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)", referenced from:
_main in chess-e62717.o
"sf::Window::isOpen() const", referenced from:
_main in chess-e62717.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The terminal process terminated with exit code: -1.
谁能帮忙,我不太了解配置库,因为这是我的第一次。
解决方案
推荐阅读
- python - XML 换行符实体和 Python 编码
- apache - 如何在 Apache 中使用代理引擎重定向到映射到其他主机的其他子域?
- r - 使用双 for 循环创建新变量的函数
- c++ - 如何使用 WinRT 创建经典的 win32 应用程序窗口?
- ios - 如何使用 swift 链接实现 GPUImage 过滤器?
- r - 箱线图的倾斜 x 轴标签
- python - 无法通过传递环境变量从 .NET 客户端运行 docker 容器
- .net - Windows 身份验证 - 数据库中允许的用户而不是 web.config
- electron - 当我调用 win.loadFile(..) 时,Electron BrowserView 失去焦点
- javascript - await async - ESLint require-atomic-updates 中的竞争条件错误