【发布时间】: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