3.1.5 Mac sample errors with Cmake

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
pvn
Experienced Solver
Experienced Solver
Posts: 93
Joined: Mon Dec 26, 2016 5:21 am
Contact:

3.1.5 Mac sample errors with Cmake

Post by pvn » Mon May 17, 2021 7:55 pm

trying a 3.1.5 build with Cmake on Mac OS 11.3 (Big Sur), using

Cmake call is

Code: Select all

cmake ../../wxwidgets-3.1.5 -DwxBUILD_COMPATIBILITY=3.1 -DwxBUILD_SHARED=OFF -DwxBUILD_SAMPLES=ALL 
cmake --build . --parallel 9
gcc is

Code: Select all

gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.5 (clang-1205.0.22.9)
Target: x86_64-apple-darwin20.4.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
I get these errors on this sample
thx

Code: Select all

/Volumes/Home/pvn/git/wx/wxwidgets-3.1.5/samples/menu/menu.cpp:191:5: error: unknown type name 'wxFileHistory'
    wxFileHistory* m_fileHistory;
    ^
/Volumes/Home/pvn/git/wx/wxwidgets-3.1.5/samples/menu/menu.cpp:454:5: error: cannot initialize object parameter of type 'wxFrame' with an expression of type 'MyFrame'
    frame->Show(true);
    ^~~~~
/Volumes/Home/pvn/git/wx/wxwidgets-3.1.5/samples/menu/menu.cpp:457:5: error: cannot initialize object parameter of type 'wxFrameBase' with an expression of type 'MyFrame'
    frame->SetStatusText("Welcome to wxWidgets menu sample");
    ^~~~~
/Volumes/Home/pvn/git/wx/wxwidgets-3.1.5/samples/menu/menu.cpp:471:5: error: cannot initialize object parameter of type 'wxTopLevelWindowBase' with an expression of type 'MyFrame'
    SetIcon(wxICON(sample));
    ^~~~~~~
/Volumes/Home/pvn/git/wx/wxwidgets-3.1.5/samples/menu/menu.cpp:481:5: error: cannot initialize object parameter of type 'wxFrameBase' with an expression of type 'MyFrame'
    CreateStatusBar();
    ^~~~~~~~~~~~~~~

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 5308
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: 3.1.5 Mac sample errors with Cmake

Post by ONEEYEMAN » Mon May 17, 2021 8:54 pm

Hi,
I suggest following:

1. Unpack wxWidgets 3.1.5 in ~/
2. Run the Terminal
3. In the Terminal do:
3a cd ~/wxWidgets-3.1.5
3b. mkdir buildMac
3c. cd buildMac
3d. ../configure --enable-debug --with-cocoa && make
33. cd samples && make

If you will get an error at ANY point - please come back and post an error.

Thank you.

pvn
Experienced Solver
Experienced Solver
Posts: 93
Joined: Mon Dec 26, 2016 5:21 am
Contact:

Re: 3.1.5 Mac sample errors with Cmake

Post by pvn » Mon May 17, 2021 9:13 pm

no errors, and the call to the menu sample was
/Volumes/Home/pvn/tmp/wxWidgets-3.1.5/buildMac/bk-deps g++ -std=gnu++11 -mmacosx-version-min=10.10 -c -o menu_menu.o -I/Volumes/Home/pvn/tmp/wxWidgets-3.1.5/buildMac/lib/wx/include/osx_cocoa-unicode-3.1 -I../../../include -D_FILE_OFFSET_BITS=64 -D__WXOSX_COCOA__ -I../../../samples/menu -DWXUSINGDLL -I../../../samples/menu/../../samples -Wall -Wundef -Wunused-parameter -Wno-ctor-dtor-privacy -Woverloaded-virtual -Wno-deprecated-declarations -g -O0 -fno-common -fvisibility=hidden -fvisibility-inlines-hidden -dynamic -fPIC -DPIC ../../../samples/menu/menu.cpp
but the parameters are different; this is not a static build, it is a dynamic build;

it seems the CMake script is missing something, we just have to find what it is

Could you try a Cmake build with
cmake ../../wxwidgets-3.1.5 -DwxBUILD_COMPATIBILITY=3.1 -DwxBUILD_SHARED=OFF -DwxBUILD_SAMPLES=ALL

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 5308
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: 3.1.5 Mac sample errors with Cmake

Post by ONEEYEMAN » Mon May 17, 2021 9:30 pm

Hi,
It is de-facto a standard to make a build dynamic on *nix/Mac.

If you really, really, really need a static build, change step 3d to read:

3d. ../configure --enable-debug --with-cocoa --disable-shared && make

but be prepared to have a legal consequences from Apple or any company whose software will be used by your program for License violation.
Or even worse - have a random crashes because the 3rd party library used by you program is ABI-incompatible with the Apple ones. And good luck trucking it down.

Thank you.

BTW.: I don't use "CMake-thingy". The only thing its useful for is when you distribute your application to the end user as part of the bigger software that already is using "CMake-thingy".
Otherwise wxWidgets provides everything you need to build the library and the samples.
It is like when you going to cry "Eurika", but then this law was already in place for the past 2000 years, if not more.

pvn
Experienced Solver
Experienced Solver
Posts: 93
Joined: Mon Dec 26, 2016 5:21 am
Contact:

Re: 3.1.5 Mac sample errors with Cmake

Post by pvn » Mon May 17, 2021 10:47 pm

this error

Code: Select all

/Volumes/Home/pvn/git/wx/wxwidgets-3.1.5/samples/menu/menu.cpp:191:5: error: unknown type name 'wxFileHistory'
    wxFileHistory* m_fileHistory;
can be fixed by simply adding these 2 headers to the sample menu.cpp

Code: Select all

#include "wx/filehistory.h"
#include "wx/filename.h"
I don't know why the ./configure build is fine with this, but the CMake build fails , so it seems that you should make this change in your 3.1.5 code
(btw, this has nothing to do with a static or dynamic build)

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 5308
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: 3.1.5 Mac sample errors with Cmake

Post by ONEEYEMAN » Mon May 17, 2021 10:54 pm

Hi,
My point is that configure build is OK - whether its a dynamic or static linkage.
And this is the way wxWidgvets is building for the past 20+ years.

You can try to argue you point in wx-users ML (sign-up is required): here.

Thank you.

BTW, the automatic wxWidgets build/test framework doesn't fail and didn't fail even when configuring with CMake-thingy.

pvn
Experienced Solver
Experienced Solver
Posts: 93
Joined: Mon Dec 26, 2016 5:21 am
Contact:

Re: 3.1.5 Mac sample errors with Cmake

Post by pvn » Mon May 17, 2021 11:08 pm

BTW, the automatic wxWidgets build/test framework doesn't fail and didn't fail even when configuring with CMake-thingy.
I does fail;
I tried just to use the 3.1.5 distribution with CMake (not my app),
did you try to build with CMake on a Mac?

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 5308
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: 3.1.5 Mac sample errors with Cmake

Post by ONEEYEMAN » Tue May 18, 2021 12:00 am

Hi,
I am not - automatic builds on Travis does.
And obviously there was no breakage at the time of release.

You need to understand - wxWidgets provide everything you need to start developing (Makefile to build the library and samples and the samle code to start your work off of).

There is no need to regenerate the Makefile's - its already been done for you.

CMake is not a build tool - its a configuration tool designed to create Makefile for the build. But since its already been done - all you need to do is run configure and make.

wxWIdgets team until very recently didn't care about CMake-thingy. They didn't provide support for it. Because it is NOT NEEDED.

Moreover - this forum is for users of the library. Nobody here is affiliated with it in any way. No core wxWidgets developers come here to help you. I'm ust like you - a user of the library. All I'm doing is running configure and make and it gives me wxWIdgets library. There is no need to run CMake-thingy. In fact I'm scared to run it to build wxWidgets itself and any and all samples,, because everything is already generated and I can build it by simply doing:

cd <build_dir>/samples/minimal && make

No need to run anything extra (reinvent the wheel/recreate the bike).

I suggest for you to stick with configure to build the library and samples and for everything else use whatever your heart desires.

Thank you.

stahta01
Super wx Problem Solver
Super wx Problem Solver
Posts: 494
Joined: Fri Nov 03, 2006 2:00 pm

Re: 3.1.5 Mac sample errors with Cmake

Post by stahta01 » Tue May 18, 2021 4:38 am

Code: Select all

wxTOOLSET=cmake wxCMAKE_GENERATOR=Xcode wxCMAKE_DEFINES="-DCMAKE_CXX_STANDARD=11"
You might try adding some of the above options.

And, I would remove "-DwxBUILD_COMPATIBILITY=3.1" because it makes no sense to me as an option to try at first; maybe after you get it to work without it.

But, I am not really an cmake user; but, I do use configure/make to build wxWidgets a lot.

Tim S.

Post Reply