【问题标题】:Linux mingw32 sfml cross compile for windows - missing dll files适用于 Windows 的 Linux mingw32 sfml 交叉编译 - 缺少 dll 文件
【发布时间】:2014-08-11 12:15:57
【问题描述】:

我正在按以下方式编译我的 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

但是,当我尝试运行我的 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

我已使用 static 选项进行编译 - 那么为什么它要求例如 libgcc_s_dw2-1.dll

另外,我在那里复制了一些文件,但应用程序仍然看不到它们。

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 $

还有一些文件,比如libgcc_s_dw2-1.dll,在我的文件系统上根本不存在...

总结一下:

  1. 为什么我的应用程序看不到丢失的文件?
  2. 如何用mingw32静态编译?
  3. 如何获取丢失的文件?

我用这个版本的sfml库编译:http://www.sfml-dev.org/download/sfml/2.1/SFML-2.1-windows-gcc-4.7-mingw-32bits.zip

【问题讨论】:

  • 您可以设置WINEPATH 指向包含DLL 的文件夹。例如:WINEPATH=/usr/local/x86_64-w64-mingw32/bin/;/usr/lib/gcc/x86_64-w64-mingw32/10-win32/

标签: c++ command-line mingw sfml


【解决方案1】:

在使用 wine 运行程序之前,可以简单地将丢失的 dll 添加到 WINEPATH,即

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

!请注意,根据您使用的 mingw 版本,您的路径可能会略有不同。

【讨论】:

    【解决方案2】:

    可能您的应用程序没有看到这些文件,因为它是这样配置的,并且您不需要在命令中添加像 -static 这样的标签。

    编译静态库,必须加上-s,如-lsfml-window-s -lsfml-system-s

    libgcc_s_dw2-1.dll 就在 bin 文件夹中,最新的MinGW releases

    如果缺少 dll,则可能是版本不兼容。

    【讨论】:

      【解决方案3】:

      在我的 Fedora 26 上安装 mingw64-gccmingw64-gcc-g++:

      [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]$ 
      

      如果我复制 dll 并使用生成的 a.out.exe 运行 wine,它就可以工作。

      【讨论】:

        【解决方案4】:

        只回答三个问题中的最后一个:

        关于标准库,我可以从 mingw 文件夹中复制它们:

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

        但是,当我根据我的构建从错误的目录复制时(例如 /usr/lib/gcc/x86_64-w64-mingw32/5.3-posix/libstdc++-6.dll)我仍然有相同名称的文件在此处时出现相同的错误。

        【讨论】:

          猜你喜欢
          • 2023-04-02
          • 2021-08-26
          • 2018-10-28
          • 2022-06-12
          • 2015-07-21
          • 2020-03-18
          • 2014-01-05
          • 1970-01-01
          • 2016-12-08
          相关资源
          最近更新 更多