- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 Windows 10 64 位上工作,我正在尝试使用 Mingw-w64/32 编译器将 sfml 2.5.1 链接到最新版本的 vscode。我有 c/c++ 扩展,python 扩展,live安装了共享和实时共享聊天。我把所有东西都放在我的 USB key 上,这样我就可以在任何地方处理我的项目。但似乎我无法正确链接 sfml 库。我搜索了很多,但我能找到的所有答案都是针对 Code::Blocks 的,或者根本不起作用。当您因为链接问题甚至无法编码时,这真的很烦人。
这是我的main.cpp
:
#include <iostream>
#include <string>
#include "SFML/Graphics.hpp"
int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(shape);
window.display();
}
std::cin.get();
return 0;
}
我的launch.json
:
{
"version": "0.2.0",
"configurations": [
{
"name": "Build",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/a.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "F:/Compiler/mingw32/bin/gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "build"
}
]
}
我的tasks.json
:
{
"tasks": [
{
"type": "shell",
"label": "build",
"command": "F:/Compiler/mingw32/bin/g++.exe",
"args": [
"-Wall",
"-Wextra",
"-g",
"${workspaceFolder}/main.cpp",
"-I${workspaceFolder}/sources/SFML/include",
"-L${workspaceFolder}/sources/SFML/lib",
"-lsfml-audio",
"-lsfml-graphics",
"-lsfml-network",
"-lsfml-system",
"-lsfml-window"
],
"options": {
"cwd": "F:/Compiler/mingw32/bin"
}
}
],
"version": "2.0.0"
}
和我的c_cpp_properties.json
:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"F:/Compiler/mingw32/lib/gcc/i686-w64-mingw32/7.3.0/include/c++/**",
"${workspaceFolder}/sources/SFML/include/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.18362.0",
"compilerPath": "F:/Compiler/mingw32/bin/g++.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "msvc-x64"
}
],
"version": 4
}
我得到的错误是:
Executing task: F:/Compiler/mingw32/bin/g++.exe -Wall -Wextra -g
F:\Programmes\Projets\RPG/main.cpp -
IF:\Programmes\Projets\RPG/sources/SFML/include -
LF:\Programmes\Projets\RPG/sources/SFML/lib -lsfml-audio -lsfml-graphics -
lsfml-network -lsfml-system -lsfml-window <
C:\Users\willy\AppData\Local\Temp\ccpyJSRW.o: In function `main':
F:/Programmes/Projets/RPG/main.cpp:7: undefined reference to
`_imp___ZN2sf6StringC1EPKcRKSt6locale'
F:/Programmes/Projets/RPG/main.cpp:7: undefined reference to
`_imp___ZN2sf9VideoModeC1Ejjj'
F:/Programmes/Projets/RPG/main.cpp:7: undefined reference to
`_imp___ZN2sf12RenderWindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15
ContextSettingsE'
F:/Programmes/Projets/RPG/main.cpp:8: undefined reference to
`_imp___ZN2sf11CircleShapeC1Efj'
F:/Programmes/Projets/RPG/main.cpp:9: undefined reference to
`_imp___ZN2sf5Color5GreenE'
F:/Programmes/Projets/RPG/main.cpp:9: undefined reference to
`_imp___ZN2sf5Shape12setFillColorERKNS_5ColorE'
F:/Programmes/Projets/RPG/main.cpp:11: undefined reference to
`_imp___ZNK2sf6Window6isOpenEv'
F:/Programmes/Projets/RPG/main.cpp:14: undefined reference to
`_imp___ZN2sf6Window9pollEventERNS_5EventE'
F:/Programmes/Projets/RPG/main.cpp:17: undefined reference to
`_imp___ZN2sf6Window5closeEv'
F:/Programmes/Projets/RPG/main.cpp:20: undefined reference to
`_imp___ZN2sf5ColorC1Ehhhh'
F:/Programmes/Projets/RPG/main.cpp:20: undefined reference to
`_imp___ZN2sf12RenderTarget5clearERKNS_5ColorE'
F:/Programmes/Projets/RPG/main.cpp:21: undefined reference to
`_imp___ZN2sf12RenderStates7DefaultE'
F:/Programmes/Projets/RPG/main.cpp:21: undefined reference to
`_imp___ZN2sf12RenderTarget4drawERKNS_8DrawableERKNS_12RenderStatesE'
F:/Programmes/Projets/RPG/main.cpp:22: undefined reference to
`_imp___ZN2sf6Window7displayEv'
F:/Programmes/Projets/RPG/main.cpp:7: undefined reference to
`_imp___ZN2sf12RenderWindowD1Ev'
F:/Programmes/Projets/RPG/main.cpp:7: undefined reference to
`_imp___ZN2sf12RenderWindowD1Ev'
C:\Users\willy\AppData\Local\Temp\ccpyJSRW.o: In function
`ZN2sf11CircleShapeD1Ev':
F:/Programmes/Projets/RPG/sources/SFML/include/SFML/Graphics/
CircleShape.hpp:41: undefined reference to `_imp___ZTVN2sf11CircleShapeE'
F:/Programmes/Projets/RPG/sources/SFML/include/SFML/Graphics/
CircleShape.hpp:41: undefined reference to `_imp___ZTVN2sf11CircleShapeE'
F:/Programmes/Projets/RPG/sources/SFML/include/SFML/Graphics/
CircleShape.hpp:41: undefined reference to `_imp___ZN2sf5ShapeD2Ev'
collect2.exe: error: ld returned 1 exit status
The terminal process terminated with exit code: 1
Terminal will be reused by tasks, press any key to close it.
最佳答案
好吧,基本上我只是下载了错误版本的 SFML。我下载了 SFML Visual C++ 15 (2017) - 32 位
,但我应该下载的是 SFML GCC 7.3.0 MinGW (DW2) - 32 位
。我还必须在 tasks.json
中精确命名我的 .exe 文件:
"-o",
"${workspaceFolder}/a.exe",
关于c++ - 尝试将 sfml 和 c++ 与 Windows 10 上的可移植 vscode 链接起来,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58462355/
我有一个包含纹理的文件。我加载到 sf::Texture并用 setTextureRect 拆分成 Sprite . 现在假设一个 Sprite 包含 20 像素宽的纹理的一部分。如何渲染它以适应例如
一段时间以来,我一直在使用 SDL 来制作小东西的原型(prototype)并了解有关图形编程的更多信息。 然后我看到了SFML并想试一试,发现它更面向对象并修复了我认为 SDL 存在的一些问题。 但
我正在使用 rust-sfml ( rsfml::graphics ) 目前,将像素绘制到屏幕上。 (我只是从 Rust 和项目开始。)我将数据存储在 Image 中。 , 然后复制到 Texture
我试图在 SFML 2 中获取关键输入,在 SFML 1.6 im 中使用 while (App.GetEvent(Event)) { if (App.GetI
我做了一个非常简单的双人游戏,一个是水母,另一个是SFML中的鲨鱼。唯一的问题是一次只能有一个 Sprite 移动。这可能修复吗?我该如何修复? 编辑:我的尝试是这样的: if (event.type
我已经尝试了几个小时,但似乎无法做到我已经下载了扩展程序并寻求帮助,但此时一切都让我感到困惑。 我想在我的项目中包含 SFML 库,我正在尝试使用 Visual Studio Code 编辑器,但由于
下面链接中的图片包含 20 多张图片(每个 body 部位和盔甲类型都在单独的文件中)。这个角色在名为“Spriter”的软件中被动画化。该代码采用 spriter 的输出文件 (.scml),然后计
我的第一个问题是 C++ 是否: pTexture.getSize().x 等于 C#(因为这对我来说没有结果): pTexture.Size().X 第二个问题是关于C++代码的(如何在SFML.n
我正在尝试在 Windows 10 下用 sfml 构建游戏。它在构建时显示成功。每当我调试解决方案时,它都会显示如下错误消息: Unhandled exception at 0x00007FFA62
我开始使用 SFML 和 C++ 创建游戏。但是,我遇到了一个问题。我有基本的骨架类代码,但由于某种原因,当我创建一个窗口(sf::Window)时,我立即崩溃了!此代码不包含任何事件检查代码,但它包
我的项目中有 2 个 CMakeLists.txt 文件。 CMakeLists.txt cmake_minimum_required(VERSION 3.2) project(Game) set(C
所以我正在尝试编写一些与网络相关的代码,特别是使用 SFML 的端口扫描器。我正在运行 VS 2017 并下载了 2015 年的 SFML 版本,但是人们说这应该适用于 2017 年。 到目前为止,我
我刚刚开始使用 C++ 和 SFML,最终一切都运行良好。在出现 undefined reference 错误之前,我意识到我一直在下载错误类型的 SFML,得到的是 SJLJ 而不是 DW2。问题已
尝试将新的 C++ 项目与 SFML 链接,我执行了以下操作: 创建了一个空项目。 C/C++ >> 常规:附加包含目录:添加了 SFML 包含目录并从项目默认值继承。 链接器 >> 附加库目录:添加
当我运行代码时,除了不播放声音外,一切正常。链接很好,当我放置断点并查看声音对象时,它显示 .我在正确的位置添加了 sfml-audio-d.lib 和 sfml-audio.lib。欢迎提出任何建议
下面的代码给出了未捕获的异常(特别是 txtr.loadFromFile("C:/Users/kidz/Documents/Visual Studio 2012/Projects/SFML/Debug
Closed. This question needs to be more focused。它当前不接受答案。 想改善这个问题吗?更新问题,使其仅关注editing this post的一个问题。
我想知道是否可以使用 SFML 库在 C 中使用颜色设置碰撞?因为我使用的是带有图 block 的 map ,我不知道它是否可以一起工作。 谢谢! 最佳答案 据我所知,您使用具有两种颜色的图像来定义碰
我正在制作 Frogger 的 C++ SFML 版本,目前正在尝试实现 Frog 和其他物体(汽车、卡车、原木等)之间的碰撞检测。我为 Frog 和游戏对象有单独的类,并希望使用边界框来检测交叉点,
嗨,大家好 为了缩放我的 sfml 应用程序,我正在尝试解决这个问题,该程序最初使用 运行(640, 480) 方面 显示这样的窗口... 我的目标是以全屏模式执行程序并放置旧的 '窗口' (检查图像
我是一名优秀的程序员,十分优秀!