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

问题描述 投票:0回答:1

我尝试使用共享库在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,例如在我的应用程序文件夹中?

c++ shared-libraries cross-compiling wxwidgets mingw-w64
1个回答
0
投票

这并不是真正的wxWidgets特定的,而只是DLL的工作方式:它们需要在程序执行期间找到,这意味着它与程序本身位于同一目录中,或者位于[ C0]环境变量。

您无法“告诉编译器”有关DLL所在路径的任何信息,因为该路径必须在run时间而不是compile时间使用。

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

© www.soinside.com 2019 - 2024. All rights reserved.