Author Topic: wxWidgets Hello World! fails to build  (Read 4489 times)

Offline Frank_CB

  • Almost regular
  • **
  • Posts: 148
wxWidgets Hello World! fails to build
« on: July 22, 2023, 04:47:21 am »
I created a C++ console project. It was 'Hello World'. Both debug and release projects compiled fine. I then replaced the code in main.cpp with the code from wxWidgets 'Hello World'. Custom variables and search directories were modified. Neither Debug or Release projects compiled.

Has anyone been successful in building wxWidgets 'Hello World' with any gnu/gcc compile version, with or without using any modifications to the project? Any suggestions would be greatly appreciated!

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7670
    • My Best Post
Re: wxWidgets Hello World! fails to build
« Reply #1 on: July 22, 2023, 01:10:58 pm »
My suggestion is post a build log in code tags if you want help.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7670
    • My Best Post
Re: wxWidgets Hello World! fails to build
« Reply #2 on: July 22, 2023, 03:07:37 pm »
I am building an custom wxWidgets to see if my current CB project will work.

It will be building for a few more hours.

Edit: I had to add two missing $(WX_CFG)
Code
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="wxMinimal" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Release">
<Option output="bin/Release/wxMinimal" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="0" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
<Add directory="$(#WX)/lib/$(WX_COMPILER)_dll$(WX_CFG)/msw$(WX_SUFFIX)" />
</Compiler>
<Linker>
<Add option="-s" />
<Add library="libwxmsw$(WX_VERSION)$(WX_SUFFIX).a" />
<Add directory="$(#WX)/lib/$(WX_COMPILER)_dll$(WX_CFG)" />
</Linker>
<Environment>
<Variable name="WX_SUFFIX" value="u" />
</Environment>
</Target>
<Environment>
<Variable name="WX_CFG" value="mono" />
<Variable name="WX_COMPILER" value="gcc1310MINGW64" />
<Variable name="WX_VERSION" value="32" />
</Environment>
</Build>
<Compiler>
<Add option="-Wall" />
<Add directory="$(#WX)/include" />
</Compiler>
<Unit filename="minimal.cpp" />
<Extensions />
</Project>
</CodeBlocks_project_file>

Tim S.
« Last Edit: July 22, 2023, 04:32:02 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Frank_CB

  • Almost regular
  • **
  • Posts: 148
Re: wxWidgets Hello World! fails to build
« Reply #3 on: July 22, 2023, 05:19:22 pm »
Here's the build log of failed 'wxWidgets Hello World!' per stahta01's suggestion!

Code
-------------- Clean: Release in hw (compiler: GNU GCC 13.1.0 Mingw64 Compiler)---------------

Cleaned "hw - Release"

-------------- Build: Release in hw (compiler: GNU GCC 13.1.0 Mingw64 Compiler)---------------

g++.exe  -I..\..\wxWidgets-3.2.2.1\lib\gcc_dll64\mswu -I..\..\wxWidgets-3.2.2.1\include -c C:\Sandbox1\hw\main.cpp -o obj\Release\main.o
g++.exe  -o bin\Release\hw.exe obj\Release\main.o   
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text+0x32): undefined reference to `wxEntry(HINSTANCE__*, HINSTANCE__*, char*, int)'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text+0x71): undefined reference to `wxAppConsoleBase::CheckBuildOptions(char const*, char const*)'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text+0x174): undefined reference to `wxString::FromAscii(char const*)'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text+0x3cd): undefined reference to `wxMenuBar::wxMenuBar()'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text+0x4aa): undefined reference to `wxFrameBase::SetMenuBar(wxMenuBar*)'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text+0x4c7): undefined reference to `wxString::FromAscii(char const*)'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text+0x4ec): undefined reference to `wxFrameBase::CreateStatusBar(int, long, int, wxString const&)'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text+0x530): undefined reference to `wxFrameBase::SetStatusText(wxString const&, int)'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text+0x79e): undefined reference to `wxFrame::~wxFrame()'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text+0x7df): undefined reference to `wxWindowBase::Close(bool)'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text+0x851): undefined reference to `wxMessageBox(wxString const&, wxString const&, long, wxWindow*, int, int)'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text+0x96f): undefined reference to `wxString::FromAscii(char const*)'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_Z16wxGet_wxConvLibcv[_Z16wxGet_wxConvLibcv]+0x18): undefined reference to `wxGet_wxConvLibcPtr()'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZNK14wxFormatStringcvPKwEv[_ZNK14wxFormatStringcvPKwEv]+0x14): undefined reference to `wxFormatString::AsWChar()'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZN8wxString7ImplStrEPKcRK8wxMBConv[_ZN8wxString7ImplStrEPKcRK8wxMBConv]+0x37): undefined reference to `wxString::ConvertStr(char const*, unsigned long long, wxMBConv const&)'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZN8wxObjectaSERKS_[_ZN8wxObjectaSERKS_]+0x26): undefined reference to `wxObject::Ref(wxObject const&)'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZN10wxListBaseC2E9wxKeyType[_ZN10wxListBaseC2E9wxKeyType]+0x2c): undefined reference to `wxListBase::Init(wxKeyType)'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZN50wxStringToStringHashMap_wxImplementation_HashTable5clearEv[_ZN50wxStringToStringHashMap_wxImplementation_HashTable5clearEv]+0x29): undefined reference to `_wxHashTableBase2::DeleteNodes(unsigned long long, _wxHashTable_NodeBase**, void (*)(_wxHashTable_NodeBase*))'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZN47wxStringToNumHashMap_wxImplementation_HashTable5clearEv[_ZN47wxStringToNumHashMap_wxImplementation_HashTable5clearEv]+0x29): undefined reference to `_wxHashTableBase2::DeleteNodes(unsigned long long, _wxHashTable_NodeBase**, void (*)(_wxHashTable_NodeBase*))'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZN23wxCriticalSectionLockerC1ER17wxCriticalSection[_ZN23wxCriticalSectionLockerC1ER17wxCriticalSection]+0x26): undefined reference to `wxCriticalSection::Enter()'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZN23wxCriticalSectionLockerD1Ev[_ZN23wxCriticalSectionLockerD1Ev]+0x17): undefined reference to `wxCriticalSection::Leave()'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZN8wxThread6IsMainEv[_ZN8wxThread6IsMainEv]+0x16): undefined reference to `wxThread::GetCurrentId()'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZN15wxLogRecordInfoC1EPKciS1_S1_[_ZN15wxLogRecordInfoC1EPKciS1_S1_]+0x5e): undefined reference to `wxThread::GetCurrentId()'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZN5wxLog9IsEnabledEv[_ZN5wxLog9IsEnabledEv]+0x15): undefined reference to `wxLog::IsThreadLoggingEnabled()'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZN5wxLog14IsLevelEnabledEmRK8wxString[_ZN5wxLog14IsLevelEnabledEmRK8wxString]+0x20): undefined reference to `wxLog::GetComponentLevel(wxString const&)'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZN8wxLogger11DoCallOnLogEmRK8wxStringPc[_ZN8wxLogger11DoCallOnLogEmRK8wxStringPc]+0x1b): undefined reference to `wxGetUTCTimeMillis()'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZN8wxLogger11DoCallOnLogEmRK8wxStringPc[_ZN8wxLogger11DoCallOnLogEmRK8wxStringPc]+0x80): undefined reference to `wxString::FormatV(wxString const&, char*)'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZN8wxLogger11DoCallOnLogEmRK8wxStringPc[_ZN8wxLogger11DoCallOnLogEmRK8wxStringPc]+0x91): undefined reference to `wxLog::OnLog(unsigned long, wxString const&, wxLogRecordInfo const&)'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZN11wxTrackable10RemoveNodeEP13wxTrackerNode[_ZN11wxTrackable10RemoveNodeEP13wxTrackerNode]+0x8f): undefined reference to `wxOnAssert(char const*, int, char const*, char const*, char const*)'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZN20wxObjectEventFunctorD1Ev[_ZN20wxObjectEventFunctorD1Ev]+0x22): undefined reference to `wxEventFunctor::~wxEventFunctor()'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZNK12wxWindowBase18GetBestVirtualSizeEv[_ZNK12wxWindowBase18GetBestVirtualSizeEv]+0x27): undefined reference to `wxWindowBase::GetBestSize() const'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZNK12wxWindowBase12CanBeFocusedEv[_ZNK12wxWindowBase12CanBeFocusedEv]+0x31): undefined reference to `wxWindowBase::IsEnabled() const'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZN12wxWindowBase25ProcessWindowEventLocallyER7wxEvent[_ZN12wxWindowBase25ProcessWindowEventLocallyER7wxEvent]+0x27): undefined reference to `wxEvtHandler::ProcessEventLocally(wxEvent&)'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZNK12wxWindowBase10HasCaptureEv[_ZNK12wxWindowBase10HasCaptureEv]+0xd): undefined reference to `wxWindowBase::GetCapture()'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZNK12wxWindowBase20GetDefaultAttributesEv[_ZNK12wxWindowBase20GetDefaultAttributesEv]+0x26): undefined reference to `wxWindowBase::GetClassDefaultAttributes(wxWindowVariant)'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZN8wxWindowC2Ev[_ZN8wxWindowC2Ev]+0x17): undefined reference to `wxWindowBase::wxWindowBase()'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZN8wxWindowC2Ev[_ZN8wxWindowC2Ev]+0x59): undefined reference to `wxWindow::Init()'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZN8wxWindowC2Ev[_ZN8wxWindowC2Ev]+0x6a): undefined reference to `wxWindowBase::~wxWindowBase()'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZN8wxWindow14ShowWithEffectE12wxShowEffectj[_ZN8wxWindow14ShowWithEffectE12wxShowEffectj]+0x2c): undefined reference to `wxWindow::MSWShowWithEffect(bool, wxShowEffect, unsigned int)'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZN8wxWindow14HideWithEffectE12wxShowEffectj[_ZN8wxWindow14HideWithEffectE12wxShowEffectj]+0x2c): undefined reference to `wxWindow::MSWShowWithEffect(bool, wxShowEffect, unsigned int)'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZN20wxTopLevelWindowBase8IsActiveEv[_ZN20wxTopLevelWindowBase8IsActiveEv]+0x14): undefined reference to `wxWindowBase::FindFocus()'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZN20wxTopLevelWindowBase8IsActiveEv[_ZN20wxTopLevelWindowBase8IsActiveEv]+0x1f): undefined reference to `wxWindowBase::IsDescendant(wxWindowBase*) const'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZN7wxFrameC2EP8wxWindowiRK8wxStringRK7wxPointRK6wxSizelS4_[_ZN7wxFrameC2EP8wxWindowiRK8wxStringRK7wxPointRK6wxSizelS4_]+0x23): undefined reference to `wxFrameBase::wxFrameBase()'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZN7wxFrameC2EP8wxWindowiRK8wxStringRK7wxPointRK6wxSizelS4_[_ZN7wxFrameC2EP8wxWindowiRK8wxStringRK7wxPointRK6wxSizelS4_]+0x41): undefined reference to `wxFrame::Init()'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZN7wxFrameC2EP8wxWindowiRK8wxStringRK7wxPointRK6wxSizelS4_[_ZN7wxFrameC2EP8wxWindowiRK8wxStringRK7wxPointRK6wxSizelS4_]+0x7b): undefined reference to `wxFrame::Create(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, long, wxString const&)'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZN7wxFrameC2EP8wxWindowiRK8wxStringRK7wxPointRK6wxSizelS4_[_ZN7wxFrameC2EP8wxWindowiRK8wxStringRK7wxPointRK6wxSizelS4_]+0x8c): undefined reference to `wxFrameBase::~wxFrameBase()'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZN7wxFrame19MSWTranslateMessageEP6tagMSG[_ZN7wxFrame19MSWTranslateMessageEP6tagMSG]+0x23): undefined reference to `wxFrame::MSWDoTranslateMessage(wxFrame*, tagMSG*)'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZN20wxwxMenuItemListNodeC1EP10wxListBasePS_S2_P10wxMenuItemRK9wxListKey[_ZN20wxwxMenuItemListNodeC1EP10wxListBasePS_S2_P10wxMenuItemRK9wxListKey]+0x3e): undefined reference to `wxNodeBase::wxNodeBase(wxListBase*, wxNodeBase*, wxNodeBase*, void*, wxListKey const&)'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZNK14wxMenuItemList4FindERK9wxListKey[_ZNK14wxMenuItemList4FindERK9wxListKey]+0x1c): undefined reference to `wxListBase::Find(wxListKey const&) const'
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj\Release\main.o:main.cpp:(.text$_ZN14wxMenuItemListD1Ev[_ZN14wxMenuItemListD1Ev]+0x22): undefined reference to `wxListBase::~wxListBase()'
Process terminated with status 1 (1 minute(s), 6 second(s))
50 error(s), 0 warning(s) (1 minute(s), 6 second(s))
 


Offline PB

  • Multiple posting newcomer
  • *
  • Posts: 60
Re: wxWidgets Hello World! fails to build
« Reply #4 on: July 22, 2023, 05:39:21 pm »
Well, it's pretty obvious that you do not tell the linker about the wxWidgets libraries needed and where to find them.

Using console template as a starting point for a GUI library project seems rather odd choice, particularly when C::B ships with a wxWidgets project template wizard which makes using wxWidgets with C::B trivial.

Your build command line should look like something like this, where I bolded some of the important parts you are missing
Quote
-------------- Build: Release in testwx321 (compiler: msys2-mingw-w64-x86_64)---------------

windres.exe -IC:\dev\libs\wxWidgets-3.2\include -IC:\dev\libs\wxWidgets-3.2\lib\gcc_dll\mswu -DwxUSE_DPI_AWARE_MANIFEST=2  -J rc -O coff -i C:\dev\TESTWX~1\resource.rc -o obj\Release\resource.res
g++.exe -Wall -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -O2 -DNDEBUG -IC:\dev\libs\wxWidgets-3.2\include -IC:\dev\libs\wxWidgets-3.2\lib\gcc_dll\mswu -c C:\dev\testwx321\test.cpp -o obj\Release\test.o
g++.exe -LC:\dev\libs\wxWidgets-3.2\lib\gcc_dll -o bin\Release\testwx321.exe  obj\Release\test.o obj\Release\resource.res -s -mthreads -lwxmsw32u_core -lwxbase32u -mwindows
Output file is bin\Release\testwx321.exe with size 86.50 KB
Please notice there is a windows resource file, without having it and it including wx.rc, your application will not have a compatibility manifest, which will result in your application looking weird and some issues (e.g., bitmap transparency in toolbar).
Also, without -mwindows, the application will show a console, which is generally not welcome in a GUI application.

Once again, I suggest not trying to reinvent a wheel and using the C::B wizard shipped with a nightly (or the one from my guide).
« Last Edit: July 22, 2023, 05:47:48 pm by PB »

Offline Frank_CB

  • Almost regular
  • **
  • Posts: 148
Re: wxWidgets Hello World! fails to build
« Reply #5 on: July 22, 2023, 07:30:56 pm »
@PB:
What tells you that 'wxWidgets Hello World!' should be handled as a wxWidgets GUI Project. I've just attempted to use the wxWidgets template to build a wxWidgets GUI Project. I've replaced the code of appmain.cpp with the code of 'wxWidgets' Hello Wold!'. The build log follows:

Code
------------- Clean: Release in HW2 (compiler: GNU GCC 13.1.0 Mingw64 Compiler)---------------

Cleaned "HW2 - Release"

-------------- Build: Release in HW2 (compiler: GNU GCC 13.1.0 Mingw64 Compiler)---------------

g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -IC:\wxWidgets-3.2.2.1\include -IC:\wxWidgets-3.2.2.1\lib\gcc_dll\mswu -c C:\Sandbox1\HW2\HW2App.cpp -o obj\Release\HW2App.o
g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -IC:\wxWidgets-3.2.2.1\include -IC:\wxWidgets-3.2.2.1\lib\gcc_dll\mswu -c C:\Sandbox1\HW2\HW2Main.cpp -o obj\Release\HW2Main.o
windres.exe -IC:\wxWidgets-3.2.2.1\include -IC:\wxWidgets-3.2.2.1\lib\gcc_dll\mswu  -J rc -O coff -i C:\Sandbox1\HW2\resource.rc -o obj\Release\resource.res
g++.exe -LC:\wxWidgets-3.2.2.1\lib\gcc_dll -o bin\Release\HW2.exe obj\Release\HW2App.o obj\Release\HW2Main.o  obj\Release\resource.res -mthreads  -lwxmsw32u -mwindows
In file included from C:\wxWidgets-3.2.2.1\include/wx/defs.h:45,
                 from C:\wxWidgets-3.2.2.1\include/wx/wx.h:14,
                 from C:\Sandbox1\HW2\HW2Main.cpp:2:
C:\wxWidgets-3.2.2.1\include/wx/platform.h:162:11: fatal error: wx/setup.h: No such file or directory
  162 |  #include "wx/setup.h"
      |           ^~~~~~~~~~~~
compilation terminated.
In file included from C:\wxWidgets-3.2.2.1\include/wx/defs.h:45,
                 from C:\wxWidgets-3.2.2.1\include/wx/event.h:14,
                 from C:\wxWidgets-3.2.2.1\include/wx/app.h:19,
                 from C:\Sandbox1\HW2\HW2App.h:13,
                 from C:\Sandbox1\HW2\HW2App.cpp:14:
C:\wxWidgets-3.2.2.1\include/wx/platform.h:162:11: fatal error: wx/setup.h: No such file or directory
  162 |  #include "wx/setup.h"
      |           ^~~~~~~~~~~~
compilation terminated.
Process terminated with status 1 (0 minute(s), 1 second(s))
 
Process terminated with status 1 (0 minute(s), 1 second(s))
 
Process terminated with status 0 (0 minute(s), 3 second(s))
2 error(s), 0 warning(s) (0 minute(s), 3 second(s))


Using the wxWidgets template involves several dialogs, each with several choices. Is this what you were talking about? I'll have to work longer on this project!

Much appreciation!

 

Offline PB

  • Multiple posting newcomer
  • *
  • Posts: 60
Re: wxWidgets Hello World! fails to build
« Reply #6 on: July 22, 2023, 07:48:32 pm »
I think it would be easier if you followed my guide linked above, or at least its chapter 4.8 which explains what is actually needed in a C::B wxWidgets project. But the wizard should work as well, as long as you know what you are doing.

Anyway, I see at least two issues with your last build:
1. The library folder is different than before (gcc_dll vs gcc_dll64): are you sure your build (including the build-specific setup.h) is really there?
2. You attempt to link against the monolithic wxWidgets library (-lwxmsw32u): is your wxWidgets build really monolithic (MONOLITHIC=1) and not the default multilib?

If you do not want to follow a guide, I strongly advise looking at least at the official docs. IMO, the trial and error is not the best way here, wasting lot of time and effort.

Offline Frank_CB

  • Almost regular
  • **
  • Posts: 148
Re: wxWidgets Hello World! fails to build
« Reply #7 on: July 22, 2023, 08:23:39 pm »
@PB:
I'll take a look at your guide (took a quick peek at it after your last reply). Yes, the library is monolithic and WX_CFG=64.

Your guide is a tutorial rather than a reference manual. Just what I need!

Thanks again!

Offline Frank_CB

  • Almost regular
  • **
  • Posts: 148
Re: wxWidgets Hello World! fails to build
« Reply #8 on: July 24, 2023, 04:26:05 am »
@PB:
I followed the guide. Used compiler from CB13318, Recompiled wxWidgets libraries to  multilib. Build log for debug target follows:
Code
-------------- Build: Debug in Test (compiler: GNU GCC 13.1.0 Mingw64 Compiler)---------------

g++.exe -pipe -mthreads -DwxUSE_DPI_AWARENESS_MANIFEST=2 -DwxUSE_AWARE_MANIF=2 -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -DwxUSE_DPI_AWARE_MANIFEST=2 -D__WXDEBUG__ -IC:\wxWidgets-3.2.2.1\include -IC:\wxWidgets-3.2.2.1\lib\gcc_dll64\mswud -c C:\Sandbox1\Test\TestApp.cpp -o obj\Debug\TestApp.o
g++.exe -pipe -mthreads -DwxUSE_DPI_AWARENESS_MANIFEST=2 -DwxUSE_AWARE_MANIF=2 -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -DwxUSE_DPI_AWARE_MANIFEST=2 -D__WXDEBUG__ -IC:\wxWidgets-3.2.2.1\include -IC:\wxWidgets-3.2.2.1\lib\gcc_dll64\mswud -c C:\Sandbox1\Test\TestMain.cpp -o obj\Debug\TestMain.o
g++.exe -LC:\wxWidgets-3.2.2.1\lib\gcc_dll -o bin\Debug\Test.exe  obj\Debug\TestApp.o obj\Debug\TestMain.o obj\Debug\resource.res -mthreads -mwindows  -lwxmsw32ud_core -lwxbase32ud -mwindows
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lwxmsw32ud_core: No such file or directory
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lwxbase32ud: No such file or directory
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 25 second(s))
3 error(s), 0 warning(s) (0 minute(s), 25 second(s))
 

What have I missed?

Offline PB

  • Multiple posting newcomer
  • *
  • Posts: 60
Re: wxWidgets Hello World! fails to build
« Reply #9 on: July 24, 2023, 07:28:51 am »
@PB:
I followed the guide. What have I missed?

It seems you did not follow my guide. For example, it makes no sense to pass C++ compiler this (the second one does not even exist)
Code
-DwxUSE_DPI_AWARENESS_MANIFEST=2 -DwxUSE_AWARE_MANIF=2
While this should do no harm, it can be seen that some steps were missed or done incorrectly.

More importantly, the command line is a mess
Quote
g++.exe -pipe -mthreads -DwxUSE_DPI_AWARENESS_MANIFEST=2 -DwxUSE_AWARE_MANIF=2 -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -DwxUSE_DPI_AWARE_MANIFEST=2 -D__WXDEBUG__ -IC:\wxWidgets-3.2.2.1\include -IC:\wxWidgets-3.2.2.1\lib\gcc_dll64\mswud -c C:\Sandbox1\Test\TestMain.cpp -o obj\Debug\TestMain.o
vs
Quote
g++.exe -LC:\wxWidgets-3.2.2.1\lib\gcc_dll -o bin\Debug\Test.exe  obj\Debug\TestApp.o obj\Debug\TestMain.o obj\Debug\resource.res -mthreads -mwindows  -lwxmsw32ud_core -lwxbase32ud -mwindowss
why are you using two wxWidgets library folders, this is obviously wrong?

Sorry, but it is pretty clear you did not follow the guide as the wizard would have set the folder correctly (and also added the resource file).

Did you at least, as instructed, build and run the minimal sample to check whether the wxWidgets library build was successful?

You should also read the build output: if you did, you would have noticed the problems as they are hard to miss.
« Last Edit: July 24, 2023, 07:38:54 am by PB »

Offline Frank_CB

  • Almost regular
  • **
  • Posts: 148
Re: wxWidgets Hello World! fails to build
« Reply #10 on: July 24, 2023, 06:04:46 pm »
@PB:
i had compiled your tutorial's sample a few times accounting for multiple occurrences of wxUSE_DPI... i deleted that sample and started over. Your tutorial's sample was for 32-bit machines. I made a couple of modifications to make that sample compile on a 64-bitplatform. I obvious didn't change the link command correctly. Also your tutorial  said to set a particular compiler flag,  but the available compiler flags weren't available. The new build log follows:
Code
-------------- Build: Debug in Test (compiler: GNU GCC 13.1.0 Mingw64 Compiler)---------------

g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -DwxUSE_DPI_AWARE_MANIFEST=2 -D__WXDEBUG__ -IC:\wxWidgets-3.2.2.1\include -IC:\wxWidgets-3.2.2.1\lib\gcc_dll64\mswud -c C:\Sandbox1\Test\TestApp.cpp -o obj\Debug\TestApp.o
g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -DwxUSE_DPI_AWARE_MANIFEST=2 -D__WXDEBUG__ -IC:\wxWidgets-3.2.2.1\include -IC:\wxWidgets-3.2.2.1\lib\gcc_dll64\mswud -c C:\Sandbox1\Test\TestMain.cpp -o obj\Debug\TestMain.o
g++.exe -LC:\wxWidgets-3.2.2.1\lib\gcc_dll -o bin\Debug\Test.exe  obj\Debug\TestApp.o obj\Debug\TestMain.o obj\Debug\resource.res -mthreads  -lwxmsw32ud_core -lwxbase32ud -mwindows
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lwxmsw32ud_core: No such file or directory
C:/Mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lwxbase32ud: No such file or directory
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 18 second(s))
3 error(s), 0 warning(s) (0 minute(s), 18 second(s))
 

Is what I missed apparent?
« Last Edit: July 24, 2023, 06:07:52 pm by Frank_CB »

Offline PB

  • Multiple posting newcomer
  • *
  • Posts: 60
Re: wxWidgets Hello World! fails to build
« Reply #11 on: July 24, 2023, 06:45:10 pm »
i had compiled your tutorial's sample a few times accounting for multiple occurrences of wxUSE_DPI... i deleted that sample and started over.
The number of compilations has no effect on the number of occurrences of a define. Still, the point was this define belongs to the resource compiler, not the C++ compiler, as is clearly explained in the guide.

Your tutorial's sample was for 32-bit machines. I made a couple of modifications to make that sample compile on a 64-bitplatform. I obvious didn't change the link command correctly. Also your tutorial  said to set a particular compiler flag,  but the available compiler flags weren't available.
My guide is for the 64-bit compiler (are we even talking about the same document?), moreover, the bitness does not matter at all here and everything works out of the box irregardless. I also do not see how it would be possible for the available compiler flags to be unavailable?

Looking at the build output, it is pretty obvious you are still mixing library folders and did not follow the guide, letting the wizard set everything for you.

Unfortunately, it seems that my guide is not a good match for you and you need to use another, better, resource. Sorry for leading you the wrong way and good luck in the future!
« Last Edit: July 24, 2023, 06:55:09 pm by PB »

Offline Frank_CB

  • Almost regular
  • **
  • Posts: 148
Re: wxWidgets Hello World! fails to build
« Reply #12 on: July 24, 2023, 07:51:57 pm »
@PB:
I apologize for wasting your time in you trying to explain to an [old] newbie how your tutorial builds the correct sample right out of the box. I'll read your tutorial completely, but there will be no more correspondence about this subject.

Thanks again for your efforts in trying to explain to an [old] newbie how wxWidgets projects can be built.

Frank_CB