SFML 游戏未在 Windows 上编译
SFML game not compiling on Windows
我使用 SFML 开发游戏已有一段时间了,并且在我的 Linux 和 Mac 机器上运行得很好。最近,我尝试将 Windows 和 运行 上的游戏编译成许多问题。
我正在使用 g++ 和一个 makefile。
g++ -std=c++17 -g -O2 -Wall -Wno-reorder -LSFML-2.5.1/lib -ISFML-2.5.1/include -o dungy Animation.o Camera.o Dust.o DustParticle.o Entity.o Game.o main.o Player.o PlayerTrail.o Room.o Textures.o Tile.o -lsfml-graphics -lsfml-audio -lsfml-window -lsfml-system
当我 运行 进行(link 到下面的完整输出)时,我得到了大量未定义的引用:
Animation.o: In function `Animation::Animation(sf::Sprite*, int, bool)':
C:\Users\foxhu\Documents\Programming\C++\dungy/Animation.cpp:9: undefined reference to `__imp__ZNK2sf6Sprite15getGlobalBoundsEv'
C:\Users\foxhu\Documents\Programming\C++\dungy/SFML-2.5.1/include/SFML/Graphics/RectangleShape.hpp:41: undefined reference to `__imp__ZN2sf5ShapeD2Ev'
使用 Visual Studio [完全按照 SFML 网站的教程] 时会输出类似的错误,但它主要由 运行dom 字符组成。
Here's a link to the full output including the g++ command
我正在使用最新的 SFML 版本,并且过去曾使用 g++ 使用几乎完全相同的 makefile 编译游戏,所以我很困惑为什么这不起作用并且在网上找不到任何东西经过数小时的寻找和尝试解决此问题后,请帮助我。该游戏使用 g++ 和相同的 makefile
在 Mac 和 Linux 上完美运行
最后一件事是 SFML 的网站说 确保 编译器版本 100% 匹配,我下载了他们为 MinGW 7.3.0(32 位)提供的版本并下载了正确的 SFML 版本以匹配它。
编辑:
Here's 如果出于某种原因需要完整的 makefile
显然,我必须使用调试库,我不必在 任何 其他平台上使用它。
我现在使用的 makefile 具有以下标志:
LDFLAGS = -lsfml-graphics-d -lsfml-audio-d -lsfml-window-d -lsfml-system-d
之前,我有这些 LDFLAGS
,最后没有 -d
。
不确定为什么 Windows 与 Mac 或 Linux 不同,但这继续了我在编程时对使用 Windows 的蔑视。
我使用 SFML 开发游戏已有一段时间了,并且在我的 Linux 和 Mac 机器上运行得很好。最近,我尝试将 Windows 和 运行 上的游戏编译成许多问题。
我正在使用 g++ 和一个 makefile。
g++ -std=c++17 -g -O2 -Wall -Wno-reorder -LSFML-2.5.1/lib -ISFML-2.5.1/include -o dungy Animation.o Camera.o Dust.o DustParticle.o Entity.o Game.o main.o Player.o PlayerTrail.o Room.o Textures.o Tile.o -lsfml-graphics -lsfml-audio -lsfml-window -lsfml-system
当我 运行 进行(link 到下面的完整输出)时,我得到了大量未定义的引用:
Animation.o: In function `Animation::Animation(sf::Sprite*, int, bool)':
C:\Users\foxhu\Documents\Programming\C++\dungy/Animation.cpp:9: undefined reference to `__imp__ZNK2sf6Sprite15getGlobalBoundsEv'
C:\Users\foxhu\Documents\Programming\C++\dungy/SFML-2.5.1/include/SFML/Graphics/RectangleShape.hpp:41: undefined reference to `__imp__ZN2sf5ShapeD2Ev'
使用 Visual Studio [完全按照 SFML 网站的教程] 时会输出类似的错误,但它主要由 运行dom 字符组成。
Here's a link to the full output including the g++ command
我正在使用最新的 SFML 版本,并且过去曾使用 g++ 使用几乎完全相同的 makefile 编译游戏,所以我很困惑为什么这不起作用并且在网上找不到任何东西经过数小时的寻找和尝试解决此问题后,请帮助我。该游戏使用 g++ 和相同的 makefile
在 Mac 和 Linux 上完美运行最后一件事是 SFML 的网站说 确保 编译器版本 100% 匹配,我下载了他们为 MinGW 7.3.0(32 位)提供的版本并下载了正确的 SFML 版本以匹配它。
编辑:
Here's 如果出于某种原因需要完整的 makefile
显然,我必须使用调试库,我不必在 任何 其他平台上使用它。
我现在使用的 makefile 具有以下标志:
LDFLAGS = -lsfml-graphics-d -lsfml-audio-d -lsfml-window-d -lsfml-system-d
之前,我有这些 LDFLAGS
,最后没有 -d
。
不确定为什么 Windows 与 Mac 或 Linux 不同,但这继续了我在编程时对使用 Windows 的蔑视。