简体   繁体   中英

Library linking using wxWidgets through Cygwin

I have been trying to get wxWidgets working on Cygwin. So far I have had success by using a mingw compiler available through the cygwin installer.
The build seemed to work fine. The configure message I used was:
configure --host=i686-w64-mingw32 --build=i686-pc-cygwin --enable-static --disable-shared
After that I ran a make and make install and got no errors.

Next I grabbed an example from a tutorial and ran:
i686-w64-mingw32-g++ -c -o hello_world.o hello_world.cpp CXX_FLAGS
i686-w64-mingw32-g++ -oa hello_world.o CXX_FLAGS LIBS
where CXX_FLAGS and LIBS are generated from wx-config -cxxflags and wx-config --libs . This works fine, but when I try to run the executable I get this error:
C:/Users/sam/Documents/cpp/wxwidgets_tutorial/a.exe: error while loading shared libraries: ?: cannot open shared object file: No such file or directory

The libraries I build should be static, so I'm not sure what to do with this message. Any help is greatly appreciated!


Some more info:

wx-config --cxxflags gives the output:
-I/usr/local/lib/wx/include/i686-w64-mingw32-msw-unicode-static-3.0 -I/usr/local/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -D__WXMSW__ -mthreads

wx-config --libs give the output:
-L/usr/local/lib -Wl,--subsystem,windows -mwindows /usr/local/lib/libwx_mswu_xrc-3.0-i686-w64-mingw32.a /usr/local/lib/libwx_mswu_webview-3.0-i686-w64-mingw32.a /usr/local/lib/libwx_mswu_qa-3.0-i686-w64-mingw32.a /usr/local/lib/libwx_baseu_net-3.0-i686-w64-mingw32.a /usr/local/lib/libwx_mswu_html-3.0-i686-w64-mingw32.a /usr/local/lib/libwx_mswu_adv-3.0-i686-w64-mingw32.a /usr/local/lib/libwx_mswu_core-3.0-i686-w64-mingw32.a /usr/local/lib/libwx_baseu_xml-3.0-i686-w64-mingw32.a /usr/local/lib/libwx_baseu-3.0-i686-w64-mingw32.a -lpng -ljpeg -ltiff -lexpat -lwxregexu-3.0-i686-w64-mingw32 -lz -lrpcrt4 -loleaut32 -lole32 -luuid -lwinspool -lwinmm -lshell32 -lcomctl32 -lcomdlg32 -ladvapi32 -lwsock32 -lgdi32

ls /usr/local/lib:
libwx_baseu_net-3.0-i686-w64-mingw32.a libwx_baseu_xml-3.0-i686-w64-mingw32.a libwx_baseu-3.0-i686-w64-mingw32.a libwx_mswu_adv-3.0-i686-w64-mingw32.a libwx_mswu_aui-3.0-i686-w64-mingw32.a libwx_mswu_core-3.0-i686-w64-mingw32.a libwx_mswu_gl-3.0-i686-w64-mingw32.a libwx_mswu_html-3.0-i686-w64-mingw32.a libwx_mswu_media-3.0-i686-w64-mingw32.a libwx_mswu_propgrid-3.0-i686-w64-mingw32.a libwx_mswu_qa-3.0-i686-w64-mingw32.a libwx_mswu_ribbon-3.0-i686-w64-mingw32.a libwx_mswu_richtext-3.0-i686-w64-mingw32.a libwx_mswu_stc-3.0-i686-w64-mingw32.a libwx_mswu_webview-3.0-i686-w64-mingw32.a libwx_mswu_xrc-3.0-i686-w64-mingw32.a libwxregexu-3.0-i686-w64-mingw32.a libwxscintilla-3.0-i686-w64-mingw32.a wx

EDIT:

Following VZ's advise, I added /usr/i686-w64-mingw32/sys-root/mingw/bin to my path... It compiles!
However when run, the program does not open any window, just exits immediately. Is this still a library problem?

You need to copy the required DLLs (at least libstdc++-6.dll and libgcc_s_sjlj-1.dll ) from /usr/i686-w64-mingw32/sys-root/mingw/bin to a directory in your PATH or the application directory (or add this directory itself to your PATH , of course).

You can use cygcheck or (native) dependency walker tool to find which DLL is actually missing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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