Issue
On a Windows 7 virtual machine I set up a C++ build environment using the following:
C:\usr\local\gcc-13.2.0
(from winlibs);C:\usr\local\cmake-3.27.6
(from KitWare);C:\usr\local\wxWidgets-3.2.2.1
(sources, from wxwidgets.org);C:\usr\local\codelite-17.6.0
(from codelite.org), built wxWidgets in the directoryC:\usr\local\wxWidgets-3.2.2.1\build
(directory was there already, seemed the right place), using theCMake
andgcc
executables above and usingmingw32-make
from the compiler directory.
The binaries are in lib\gcc_x64_dll
under the wxWidgets directory, and the names of all the shared libraries end in _gcc_custom.dll
.
Then to build a wxWidgets 'Hello World' example, in CodeLite:
- changed "Settings" - "Compiler Settings" to the just-installed
gcc
- changed "Settings" - "GDB Settings" to
gdb
in the same directory - added
WXWIN=C:\usr\local\wxWidgets-3.2.2.1
andWXCFG=gcc_x64_dll\mswu
to "Settings" -> "Environment Variables" - open a new project "hello_wxwidget", Category "GUI", Type "wxWidgets GUI application", compiler and debugger as above, Build System "CodeLite Makefile Generator". This will generate standard code to make a simple wxFrame.
The program builds successfully! However, when I run it, the output in CodeLite is just "Program exited" (no error messages) and no window appears.
When I run it through the debugger, it says Debugger exited with the following error string: "During startup program exited with code 0xc0000135
".
Without other errors and warnings and no call stack available, is it possible to find out what is not working here?
EDIT
Following advice by @Tsyvarev I have opened the .exe
file in the program Explorer Suite, which shows its dependencies:
libgcc_s_seh-1.dll
,libstdc++-6.dll
(both inC:\usr\local\gcc-13.2.0\bin
but not found by CFF Explorer);KERNEL32.dll
,ucrtbase.dll
(both found inC:\Windows\system32
);wxbase32u_gcc_custom.dll
,wxmsw32u_core_gcc_custom.dll
,wxmsw32u_xrc_gcc_custom.dll
(all three inC:\usr\local\wxWidgets-3.2.2.1\libgcc_x64_dll
but not found by CFF Explorer)
In my "Settings" -> "Global Settings" I have now added C:\usr\local\wxWidgets-3.2.2.1\lib\gcc_x64_dll; C:\usr\local\gcc-13.2.0\bin;
to the "Library Path" and -lwxbase32u_gcc_custom; -lwxmsw32u_core_gcc_custom; -lwxmsw32u_xrc_gcc_custom; -llibgcc_s_seh-1; -llibstdc++-6
to the "Linker Options". To make the last option work I also need to rename libstdc++-6.dll.a
in the compiler's lib
directory, otherwise the .a
clashes with the .so
.
Compilation finishes successfully, program crashes. From the IDE as well as from the shell. The IDE (debugger) gives the "exit code" message and the shell says: "The program cannot start because libgcc_s_seh-1.dll is missing from your computer."
Does anyone know what is needed to be able to use those DLLs both during linking my program and for running it independently?
EDIT II
After putting the two directories C:\usr\local\gcc-13.2.0\bin
(the DLLs of g++) and C:\usr\local\wxWidgets-3.2.2.1\lib\gcc_x64_dll
(the DLLs of wxWidgets) to the path and restarting:
- the first run from the IDE neither produced an error, nor a window
- the first run from the shell produced a window (!)
- all runs after that from the IDE produced a window as well
So that finally seems to have done the trick! (though not really sure what happened at "1.")
Will do some more testing and then produce a nice bullet list.
Solution
In the end the comments by @Tsyvarev and @Igor helped me find the answer. The issue with building wxWidgets as shared libraries, which is normal in Linux but not in Windows, is that these libraries need to be in the system's (or the user's) Path
environment variable. They could also be copied into every executable's directory, but that would defy the purpose of shared libraries!
So my recipe for building GUIs with wxWidgets in CodeLite in Windows is:
- Download G++, CMake and CodeLite binaries and wxWidgets sources;
- Build wxWidgets with GCC and CMake (with wxBUILD_SHARED ticked);
- Set the compiler in CodeLite to the new GCC and set
WXWIN
andWXCFG
to the wxWidgets source directory and the lib//mswu directory, respectively; - Set the System
Path
environment variable so that it includes both thebin
directory of the GCC compiler and the full path of theWXCFG
directory's parent; - Select a project type in CodeLite that is wxWidgets-aware: it will put the right compiler, linker and resources options in.
In the end, no extra linker options are necessary for building, but if you want to use shared libraries as they were intended, they need to be reachable via the Path
environment variable (there is no $LD_LIBRARY_PATH
equivalent)
I copied the result of steps 1-2 to another Windows 7 virtual machine and steps 3-5 were enough to get a wxFrame working.
Answered By - alle_meije Answer Checked By - Cary Denson (WPSolving Admin)