【问题标题】:Missing DLLs cross-compile wxWidgets shared library on ubuntu缺少 DLL 在 ubuntu 上交叉编译 wxWidgets 共享库
【发布时间】:2020-03-01 17:37:50
【问题描述】:

我尝试使用共享库在 Linux 下交叉编译到 Windows。 我按照 wxWidgets wiki 上的说明进行操作,但是在执行 main out.exe 时,我得到了很多丢失的 DLL 错误。

这是我构建库的方式:

../configure --disable-debug_flag --host=x86_64-w64-mingw32 --build=x86_64-linux-gnu -with-msw

这是我的编译和链接方式:

First : x86_64-w64-mingw32-g++ -c  *.cpp  *.h  $(/wxWidgets/build_win/wx-config --cxxflags)

Second : x86_64-w64-mingw32-g++ -o out.exe *.o  $(/wxWidgets/build_win/wx-config --libs) -static-libgcc -static-libstdc++

当我使用 wine out.exe 时出现以下错误:

002a:err:module:import_dll Library wxbase313u_gcc_custom.dll (which is needed by L"Z:\\home\\ubuntu\\test.exe") not found
002a:err:module:import_dll Library wxmsw313u_core_gcc_custom.dll (which is needed by L"Z:\\home\\ubuntu\\test.exe") not found
002a:err:module:attach_dlls Importing dlls for L"Z:\\home\\ubuntu\\test.exe" failed, status c0000135

我已将丢失的 DLL 添加到与 out.exe 相同的文件夹中(它们位于 /wxWidgets/build_win/lib/ 中),这样做会增加更多错误:

wine out.exe 
0028:err:module:import_dll Library libgcc_s_seh-1.dll (which is needed by L"Z:\\home\\ubuntu\\Bureau\\test\\wxbase313u_gcc_custom.dll") not found
0028:err:module:import_dll Library libstdc++-6.dll (which is needed by L"Z:\\home\\ubuntu\\Bureau\\test\\wxbase313u_gcc_custom.dll") not found
0028:err:module:import_dll Library wxbase313u_gcc_custom.dll (which is needed by L"Z:\\home\\ubuntu\\Bureau\\test\\out.exe") not found
0028:err:module:import_dll Library libgcc_s_seh-1.dll (which is needed by L"Z:\\home\\ubuntu\\Bureau\\test\\wxbase313u_gcc_custom.dll") not found
0028:err:module:import_dll Library libstdc++-6.dll (which is needed by L"Z:\\home\\ubuntu\\Bureau\\test\\wxbase313u_gcc_custom.dll") not found
0028:err:module:import_dll Library wxbase313u_gcc_custom.dll (which is needed by L"Z:\\home\\ubuntu\\Bureau\\test\\wxmsw313u_core_gcc_custom.dll") not found
0028:err:module:import_dll Library libgcc_s_seh-1.dll (which is needed by L"Z:\\home\\ubuntu\\Bureau\\test\\wxmsw313u_core_gcc_custom.dll") not found
0028:err:module:import_dll Library libstdc++-6.dll (which is needed by L"Z:\\home\\ubuntu\\Bureau\\test\\wxmsw313u_core_gcc_custom.dll") not found
0028:err:module:import_dll Library wxmsw313u_core_gcc_custom.dll (which is needed by L"Z:\\home\\ubuntu\\Bureau\\test\\out.exe") not found
0028:err:module:attach_dlls Importing dlls for L"Z:\\home\\ubuntu\\Bureau\\test\\out.exe" failed, status c0000135

这是我的文件夹内容:

ChildPanels.o                  wxmsw313u_gl_gcc_custom.dll
main.o                         wxmsw313u_html_gcc_custom.dll
MainPanel.o                    wxmsw313u_media_gcc_custom.dll
out.exe                        wxmsw313u_propgrid_gcc_custom.dll
wxbase313u_gcc_custom.dll      wxmsw313u_qa_gcc_custom.dll
wxbase313u_net_gcc_custom.dll  wxmsw313u_ribbon_gcc_custom.dll
wxbase313u_xml_gcc_custom.dll  wxmsw313u_richtext_gcc_custom.dll
wxmsw313u_adv_gcc_custom.dll   wxmsw313u_stc_gcc_custom.dll
wxmsw313u_aui_gcc_custom.dll   wxmsw313u_webview_gcc_custom.dll
wxmsw313u_core_gcc_custom.dll  wxmsw313u_xrc_gcc_custom.dll

谁能帮我解决这个问题?

编辑:

它可以将所有这些 DLL 复制到我的文件夹中:

libgcc_s_seh-1.dll  libstdc++-6.dll  libwinpthread-1.dll wxmsw313u_core_gcc_custom.dll  wxbase313u_gcc_custom.dll

我不明白为什么我需要将 libgcc 和 libstdc++ 复制到我的文件夹中,因为我静态链接了它们。是不是不能链接静态的 libgcc 和 libstdc++ 和共享的 wxWidgets ?

另外,我如何告诉编译器我希望从名为 /lib 的文件夹中加载我的 DLL,例如在我的 app 文件夹中?

【问题讨论】:

    标签: c++ shared-libraries cross-compiling wxwidgets mingw-w64


    【解决方案1】:

    这并不是 wxWidgets 特定的,而只是 DLL 的工作方式:需要在程序执行期间找到它们,这意味着要么在与程序本身相同的目录中,要么在PATH 环境变量。

    您不能“告诉编译器”关于找到 DLL 的路径的任何信息,因为该路径必须在 运行 时使用,而不是在编译 时使用。

    如果您真的非常想将 DLL 放在另一个目录中,最简单的解决方法是使用包装器(它可以是脚本或另一个已编译的程序),在启动真正的应用程序之前将此目录添加到 PATH .或者,只需静态链接,根本不用担心 DLL。

    【讨论】:

    • 嗨@VZ。感谢您的解释,我更了解我现在应该做什么。但是我不明白为什么我需要将 libgcc 和 libstdc++ DLLS 放在同一个文件夹中,因为我在编译时使用 -static-libgcc -static-libstdc++ 静态链接了它们
    • 要不依赖于编译器运行时 DLL,您需要使用与在您自己的应用程序中静态链接它们相同的选项来链接 wx DLL。
    猜你喜欢
    • 1970-01-01
    • 2020-01-04
    • 1970-01-01
    • 1970-01-01
    • 2013-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多