WxWidgets:Troubleshooting
lastmod 2016-03-24created 2014-09-047 edits
A summary of problems that can occur while using wsWidgets.
Undefined reference
When compiling statically (SHARED=0), messages like the following may be printed.
gcc_lib/libwxmsw30u_core.a(corelib_app.o):app.cpp:(.text+0x5f52): undefined reference to `__imp_InitCommonControls'
gcc_lib/libwxmsw30u_core.a(corelib_app.o):app.cpp:(.text+0x5fa2): undefined reference to `__imp_OleUninitialize'
In this case, add the wxWidgets-related libraries as below.
Additional libraries like the following may also be needed.
-lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lwsock32
MinGW w64 Compile error
The following error occurs during compilation.
The build was done in the following environment.
- wxWidgets 3.00
- MinGW32-w64
- GCC v4.8.1
- MSYS-1.0.18
There is advice to use PCH for this.
You have to be using Precompiled header (wxprec.h or in my case sdk_precomp.h CB header that normally includes wxprec.h) to see the problem.
Headers that seem directly required to trigger problem are
"wx/msw/wrapcctl.h" and any one on the below headers
<wx/choicdlg.h>, <wx/filedlg.h>, <wx/slider.h>, or <wx/textdlg.h>.
The problem seemed worse when I replaced "wx/msw/wrapcctl.h" with "wx/msw/wrapshl.h" to test if it also caused a problem.
For the related issue, see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56926
In function _start: undefined reference to main
On Linux-family systems, the following may be printed as a compile error message.
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
It means main cannot be found. There can be various causes, but check the following first.
- Check whether a wxWidgets Entry Point such as
IMPLEMENT_CLASSorIMPLEMENT_APPis set. - Check that
IMPLEMENT_APPis not wrapped in a Namespace: it must be in no namespace.
C++11 linking
To compile with c++11, use environment variables as below.