静态链接 SFML 库时 MinGW 中的问题
我有一个程序在 Linux 下编译没有错误,但是当我使用 MinGW 在 Windows 上编译它时,它无法运行,因为它说它需要一些 DLL。所以我决定静态链接它,但它输出一些错误:
/usr/i586-mingw32msvc/lib/libsfml-window-s.a(WindowImplWin32.o):WindowImplWin32.cpp:(.text+0x146e): undefined reference to `__Unwind_Resume'
/usr/i586-mingw32msvc/lib/libsfml-window-s.a(WindowImplWin32.o):WindowImplWin32.cpp:(.text+0x17d0): more undefined references to `__Unwind_Resume' follow
/usr/i586-mingw32msvc/lib/libsfml-window-s.a(WindowImplWin32.o):WindowImplWin32.cpp:(.eh_frame+0x12): undefined reference to `___gxx_personality_v0'
/usr/i586-mingw32msvc/lib/libsfml-window-s.a(Joystick.o):Joystick.cpp:(.eh_frame+0x11): undefined reference to `___gxx_personality_v0'
collect2: ld returned 1 exit status
它似乎有一些外部依赖项。它们是什么?如何链接它们?
编辑:
这是我在命令行中输入的内容:
i586-mingw32msvc-g++“./main.cpp”-o“./win32.exe”/usr/i586-mingw32msvc/lib/libsfml-graphics-sa /usr/i586-mingw32msvc/lib/libsfml-window -sa /usr/i586-mingw32msvc/lib/libm.a /usr/i586-mingw32msvc/lib/libmsvcr90.a
将不胜感激。
I have a program that compiles with no errors under Linux, but when I compile it for Windows using MinGW it can't run as it says that it requires some DLL's next to it. So I decided to statically link it, but it outputs some errors:
/usr/i586-mingw32msvc/lib/libsfml-window-s.a(WindowImplWin32.o):WindowImplWin32.cpp:(.text+0x146e): undefined reference to `__Unwind_Resume'
/usr/i586-mingw32msvc/lib/libsfml-window-s.a(WindowImplWin32.o):WindowImplWin32.cpp:(.text+0x17d0): more undefined references to `__Unwind_Resume' follow
/usr/i586-mingw32msvc/lib/libsfml-window-s.a(WindowImplWin32.o):WindowImplWin32.cpp:(.eh_frame+0x12): undefined reference to `___gxx_personality_v0'
/usr/i586-mingw32msvc/lib/libsfml-window-s.a(Joystick.o):Joystick.cpp:(.eh_frame+0x11): undefined reference to `___gxx_personality_v0'
collect2: ld returned 1 exit status
It seems like it has some external dependencies. What are those, and how do I link them?
Edit:
Here's what I put in the command line:
i586-mingw32msvc-g++ "./main.cpp" -o "./win32.exe" /usr/i586-mingw32msvc/lib/libsfml-graphics-s.a /usr/i586-mingw32msvc/lib/libsfml-window-s.a /usr/i586-mingw32msvc/lib/libm.a /usr/i586-mingw32msvc/lib/libmsvcr90.a
Help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我最近也遇到了这个问题。
SFML 是使用 DW2 异常处理进行编译的,但默认的 MinGW 交叉编译器(在 Debain 和 Ubuntu 存储库中)使用的是 SJLJ,并且这些彼此不兼容。我必须使用 DW2 异常处理来构建自己的交叉编译器,并且它可以完美地工作。或者,您可以使用现有的 SJLJ 编译器构建 SFML 本身,因此 SFML 也将是 SJLJ。
我决定构建一个 DW2 编译器,因为它是更现代的方法,而且也是一个很好的练习。
I had this problem too recently.
It's that SFML is compiled with DW2 exception handling, but the default MinGW cross-compiler (in the Debain and Ubuntu repos) uses SJLJ, and these are not compatible with each other. I had to build my own cross-compiler with DW2 exception handling, and that works flawlessly. Alternatively, you can build SFML itself with your existing SJLJ compiler, so SFML will be SJLJ too.
I decided to build a DW2 compiler, because it is the more modern method, and it was a good exercise too.
确保您使用 g++ 而不是 gcc,应该修复它。从头开始(重建之前清理所有内容)。另一种选择可能是此处中描述的内容,假设您已经使用 g++ 并且仍然得到它。
Make sure you use g++ instead of gcc, should fix it. Start from scratch (clean all before rebuilding). Another option might be what's described in here, assuming you already use g++ and still get it.