简体   繁体   English

适用于 Windows 的 Linux mingw32 sfml 交叉编译 - 缺少 dll 文件

[英]Linux mingw32 sfml cross compile for windows - missing dll files

I am compiling my C++ project in the following way:我正在按以下方式编译我的 C++ 项目:

/usr/bin/i686-w64-mingw32-g++ -g -std=c++0x -Wall -I /home/bluszcz/dev/win64/SFML-2.1/include -L /home/bluszcz/dev/win64/SFML-2.1/lib -static-libgcc -static-libstdc++ -static -O4 -c src/game.cpp -o src/game.a -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio

However, when I try to run my exe file I am getting an error about missing DLL files:但是,当我尝试运行我的 exe 文件时,我收到一个关于缺少 DLL 文件的错误:

bluszcz@zendo ~/dev/win32/builds/magicwizard $ wine mw.exe 
err:module:import_dll Library libgcc_s_dw2-1.dll (which is needed by L"Z:\\home\\bluszcz\\dev\\win32\\builds\\magicwizard\\sfml-system-2.dll") not found
err:module:import_dll Library libgcc_s_sjlj-1.dll (which is needed by L"Z:\\home\\bluszcz\\dev\\win32\\builds\\magicwizard\\libstdc++-6.dll") not found
err:module:import_dll Library libwinpthread-1.dll (which is needed by L"Z:\\home\\bluszcz\\dev\\win32\\builds\\magicwizard\\libstdc++-6.dll") not found
err:module:import_dll Library libstdc++-6.dll (which is needed by L"Z:\\home\\bluszcz\\dev\\win32\\builds\\magicwizard\\sfml-system-2.dll") not found
err:module:import_dll Library sfml-system-2.dll (which is needed by L"Z:\\home\\bluszcz\\dev\\win32\\builds\\magicwizard\\sfml-audio-2.dll") not found
err:module:import_dll Library libgcc_s_dw2-1.dll (which is needed by L"Z:\\home\\bluszcz\\dev\\win32\\builds\\magicwizard\\sfml-audio-2.dll") not found
err:module:import_dll Library libgcc_s_sjlj-1.dll (which is needed by L"Z:\\home\\bluszcz\\dev\\win32\\builds\\magicwizard\\libstdc++-6.dll") not found
err:module:import_dll Library libwinpthread-1.dll (which is needed by L"Z:\\home\\bluszcz\\dev\\win32\\builds\\magicwizard\\libstdc++-6.dll") not found
err:module:import_dll Library libstdc++-6.dll (which is needed by L"Z:\\home\\bluszcz\\dev\\win32\\builds\\magicwizard\\sfml-audio-2.dll") not found

I have compiled using static options - so why it asks for libgcc_s_dw2-1.dll for example?我已经使用静态选项进行编译 - 那么为什么它要求libgcc_s_dw2-1.dll例如?

Also, I copied some files there, but the application still doesn't see them.另外,我在那里复制了一些文件,但应用程序仍然看不到它们。

bluszcz@zendo ~/dev/win32/builds/magicwizard $ ls *dll
libsndfile-1.dll  sfml-audio-2.dll     sfml-graphics-d-2.dll  sfml-system-2.dll    sfml-window-d-2.dll
libstdc++-6.dll   sfml-audio-d-2.dll   sfml-network-2.dll     sfml-system-d-2.dll
openal32.dll      sfml-graphics-2.dll  sfml-network-d-2.dll   sfml-window-2.dll
bluszcz@zendo ~/dev/win32/builds/magicwizard $

And some files, like libgcc_s_dw2-1.dll , don't exist on my file system at all...还有一些文件,比如libgcc_s_dw2-1.dll ,在我的文件系统中根本不存在......

To summarize:总结一下:

  1. Why does my application not see the missing files?为什么我的应用程序看不到丢失的文件?
  2. How to compile in static way with mingw32?如何使用mingw32以静态方式编译?
  3. How to get the missing files?如何获取丢失的文件?

I use this version of sfml library to compile it: http://www.sfml-dev.org/download/sfml/2.1/SFML-2.1-windows-gcc-4.7-mingw-32bits.zip我使用这个版本的 sfml 库来编译它: http ://www.sfml-dev.org/download/sfml/2.1/SFML-2.1-windows-gcc-4.7-mingw-32bits.zip

Answering only the last of the three question:仅回答三个问题中的最后一个:

About the standards libraries, it worked for me to copy them from the mingw folder:关于标准库,我可以从 mingw 文件夹中复制它们:

cp /usr/lib/gcc/i686-w64-mingw32/5.3-win32/libstdc++-6.dll ./

However, when I copied from the wrong directory according to my build (eg /usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/libstdc++-6.dll ) I still had the same error while the file with the exact same name was here.但是,当我根据我的构建(例如/usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/libstdc++-6.dll )从错误的目录中复制时,我仍然遇到相同的错误,而具有确切同名在这里。

On my Fedora 26 after installing mingw64-gcc and mingw64-gcc-g++ :在安装mingw64-gccmingw64-gcc-g++后,在我的 Fedora 26 上:

[leo@pc]$ locate libgcc_s_seh-1.dll
/usr/x86_64-w64-mingw32/sys-root/mingw/bin/libgcc_s_seh-1.dll
[leo@pc]$ locate libstdc++-6.dll
/usr/x86_64-w64-mingw32/sys-root/mingw/bin/libstdc++-6.dll
[leo@pc]$ 

If I copy dll's and run wine with generated a.out.exe it works.如果我复制 dll 并使用生成的 a.out.exe 运行 wine,它就可以工作。

Probably your application isn't seeing the files because it's configured like that, and you don't need to add tags like -static to the command.可能您的应用程序没有看到这些文件,因为它是这样配置的,并且您不需要向命令添加-static之类的标签。

For compiling static libraries, you must add -s , like -lsfml-window-s -lsfml-system-s要编译静态库,您必须添加-s ,例如-lsfml-window-s -lsfml-system-s

libgcc_s_dw2-1.dll is just inside bin folder, on latest MinGW releases . libgcc_s_dw2-1.dll就在bin文件夹内,在最新的MinGW 版本中

If there are missing dlls, there's probably a version incompatibility.如果缺少 dll,则可能是版本不兼容。

The missing dll's can simply be added to your WINEPATH before running your program with wine, ie在使用 wine 运行程序之前,可以简单地将丢失的 dll 添加到 WINEPATH 中,即

export WINEPATH="/usr/x86_64-w64-mingw32/lib;/usr/lib/gcc/x86_64-w64-mingw32/7.3-posix"

!Note, your paths might be slightly different depending on the mingw version you are using. !注意,根据您使用的 mingw 版本,您的路径可能略有不同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM