繁体   English   中英

缺少 DLL 交叉编译 ubuntu 上的 wxWidgets 共享库

[英]Missing DLLs cross-compile wxWidgets shared library on ubuntu

我尝试使用共享库在 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

我在 out.exe 所在的文件夹中添加了丢失的 DLL(它们位于 /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 文件夹中?

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

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

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

暂无
暂无

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

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