MSYS2: using the cmake to created a wxWidgets application

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
ollydbg23
Super wx Problem Solver
Super wx Problem Solver
Posts: 438
Joined: Fri Dec 12, 2008 10:31 am

MSYS2: using the cmake to created a wxWidgets application

Post by ollydbg23 »

Hi, I think I found a way to build the wxWidgets application very fast by using the wx library supplied by MSYS2.

I see that the MSYS2 has modified their FindwxWidgets.cmake file recently to support this, the method works OK in both the mitty shell started when you run the mingw64.exe or the normal windows command line(cmd.exe).

I wrote a step by step tutorial in this link:

https://github.com/msys2/MINGW-packages ... 1113904778

Hope that helps.

For me, I can just download the sample folder from wx's github, and build those samples when needed.
rocvan
Earned a small fee
Earned a small fee
Posts: 15
Joined: Sat May 14, 2022 6:42 am

Re: MSYS2: using the cmake to created a wxWidgets application

Post by rocvan »

Hi,

May I bother you on this thread. I have studied this guide and now there is no cmake issue.

The minimal sample compiled and executed in MSYS2 in windows 10 successfully. I use the wxWidgets 3.0.5 for MSYS2. (From this package:
https://packages.msys2.org/package/ming ... po=mingw64)

When I am tried the samples/treelist, sinice there is no CMakeLists.txt, I create one nearly same as in minimal. I got a lot of linking error:
- wx-3.0/wx/treelist.h:136: undefined reference to `wxTreeListCtrl::Init()'
- undefined reference to `vtable for wxTreeListCtrl'

It there any reason on this? How can I solve this?
Do I need to open another thread on this discussion?

Thanks advance.
ollydbg23
Super wx Problem Solver
Super wx Problem Solver
Posts: 438
Joined: Fri Dec 12, 2008 10:31 am

Re: MSYS2: using the cmake to created a wxWidgets application

Post by ollydbg23 »

Hi, my guess is that for linking to wxTreeListCtrl related symbols, you have to add some extra libraries in your cmake script.

For example, for a minimal cmake wxWidgets project, you can put some lines like:

Code: Select all

# Request the required wxWidgets libs
find_package(wxWidgets 3.0 COMPONENTS core base REQUIRED)
But it looks like wxTreeListCtrl does not belong to core or base library?
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4182
Joined: Sun Jan 03, 2010 5:45 pm

Re: MSYS2: using the cmake to created a wxWidgets application

Post by PB »

With wxWidgets 3.0, you must add the advanced library, e.g.

Code: Select all

find_package(wxWidgets 3.0 COMPONENTS adv core base REQUIRED)
The advanced library was merged with the core one only in 3.1.2.
ollydbg23
Super wx Problem Solver
Super wx Problem Solver
Posts: 438
Joined: Fri Dec 12, 2008 10:31 am

Re: MSYS2: using the cmake to created a wxWidgets application

Post by ollydbg23 »

Hi, PB, thanks for the reply.

Where can we find the map between the components such as "adv" and the actual linked libraries cmake will generate?

Since you said they differs between wx versions.

Thanks.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4182
Joined: Sun Jan 03, 2010 5:45 pm

Re: MSYS2: using the cmake to created a wxWidgets application

Post by PB »

ollydbg23 wrote: Thu May 26, 2022 2:21 am Where can we find the map between the components such as "adv" and the actual linked libraries cmake will generate?
The map of the class to library can be found in wxWidgets documentation for the class. As for mapping wxWidgets libraries to FindwxWidgets components, I am not aware of any official source. But it can be seen e.g. in CMakeGui, as those WX_** variables, e.g. WX_adv for wxAdvanced.
ollydbg23 wrote: Thu May 26, 2022 2:21 am Since you said they differs between wx versions.
Getting rid of wxAdvanced is the only such change I have ever seen in the past dozen or so years. The advanced library (now empty) still exists for compatibility reasons, so in this regard nothing have really changed.
rocvan
Earned a small fee
Earned a small fee
Posts: 15
Joined: Sat May 14, 2022 6:42 am

Re: MSYS2: using the cmake to created a wxWidgets application

Post by rocvan »

PB wrote: Wed May 25, 2022 3:25 pm With wxWidgets 3.0, you must add the advanced library, e.g.

Code: Select all

find_package(wxWidgets 3.0 COMPONENTS adv core base REQUIRED)
The advanced library was merged with the core one only in 3.1.2.
Thanks, the adv library is added and the sample can be compiled.

(besides, I cannot receive any notification (email or notification) on this thread, don't know the reason).
Post Reply