I search working example cmake for Windows

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
AndrzejB
Experienced Solver
Experienced Solver
Posts: 88
Joined: Sun Nov 29, 2015 12:46 pm

I search working example cmake for Windows

Post by AndrzejB » Sun May 30, 2021 8:56 am

I search working example project for Windows with MinGw or Visual Studio (prefer MinGw AND Visual Studio ). Using cmake.
With Stc and Aui.
I will try make my project based on this example. Main problem is linking mismatch.

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

Re: I search working example cmake for Windows

Post by PB » Sun May 30, 2021 9:50 am

Please do not create new threads for the same topic you already did. Particularly if you go silent in the existing topic where people tried to help you. This is not only rude but also pollutes the forum with noise.

An example CMakefile is shipped with wxWidgets, in the minimal sample folder. If you need additional libraries, you need to add them to the find_package() in your CMakefile. Please not that with GCC, the library order matters, so you need to put aui and stc before core and base, for example

Code: Select all

find_package(wxWidgets 3.1 COMPONENTS stc aui core base REQUIRED) 
The official wxWidgets CMake documentation is at https://docs.wxwidgets.org/trunk/overvi ... cmake_apps

I recommend using CMakeGUI where all the settings can be easily observed and changed, in particular the relevant wxWidgets folders.

Also please not that when wxWidgets itself was built with CMake and MinGW, the library names are currently incompatible with CMake's FindwxWidgets module, see https://groups.google.com/g/wx-dev/c/J_ ... z5EUHgFwAJ

bitdiverly
In need of some credit
In need of some credit
Posts: 3
Joined: Sun Jun 20, 2021 3:40 pm

Re: I search working example cmake for Windows

Post by bitdiverly » Sun Jun 20, 2021 3:58 pm

Hello,
I am running into a similar problem.
1) I downloaded wxWidgets source and build it with cmake
this gives:

Code: Select all

       /c/wxWidgets-3.1.5/build/libs --> contents
adv/  base/                CMakeFiles/  gl/    media/  propgrid/  ribbon/    stc/      xml/
aui/  cmake_install.cmake  core/        html/  net/    qa/        richtext/  webview/  xrc/
and quite a few dlls in build/lib/vc_dell

I am trying to use findPackage for wxWidgets but it complains about a missing file:

wxWidgetsConfig.cmake


Also I am wondering about the best way to link the libs (once found).
I will explore a bit more but maybe someone here has some thoughts or experiences how it can work.

Thanks!

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

Re: I search working example cmake for Windows

Post by ONEEYEMAN » Sun Jun 20, 2021 8:29 pm

Hi,
Using CMake thingy is relatively new with wxWidgets.

Why not use wxWidgets.props file since you are using MSVC anyway?

Or use an existing "minimal" sample solution.

Thank you.

bitdiverly
In need of some credit
In need of some credit
Posts: 3
Joined: Sun Jun 20, 2021 3:40 pm

Re: I search working example cmake for Windows

Post by bitdiverly » Mon Jun 21, 2021 8:28 am

I am able to build my minimal project with help of these 3 CMake find_package commands:

Code: Select all

    
    find_package(wxWidgets REQUIRED)
    target_include_directories(main PRIVATE ${wxWidgets_INCLUDE_DIRS})
    target_link_libraries(main PRIVATE ${wxWidgets_LIBRARIES})
However, with the default linking in my project is dynamic linking, and with this I get errors during runtime on missing libs: wx_base, wx_core, ...
I copy these files into the bin directory, but then I get:

The procedure entry point inflateValidate could not be located in the dynamic linked library libpng.dll

Not sure how this error occurs, and what to do.
Also I tried to remove to remove the libpng library with:

Code: Select all

    set(wxWidgets_EXCLUDE_COMMON_LIBRARIES png tiff jpeg zlib regex expat)
And not sure if this is needed or not:

Code: Select all

   set(wxWidgets_CONFIGURATION msw)

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

Re: I search working example cmake for Windows

Post by ONEEYEMAN » Mon Jun 21, 2021 11:50 am

Hi,
What os are you building?

Thank you.

bitdiverly
In need of some credit
In need of some credit
Posts: 3
Joined: Sun Jun 20, 2021 3:40 pm

Re: I search working example cmake for Windows

Post by bitdiverly » Mon Jun 21, 2021 12:11 pm

Windows with MSVC but the wxWidgets is downloaded and build with help of vcpkg. Default are dynamic libs while I am also open to try static libs.
Note that I also tried to include wxWidgets as subproject in my repo but this led to new errors and increased build time.
There is some discussion on the wxWidgets issues how to better integrate vcpkg with wxWidgets, e.g. https://github.com/microsoft/vcpkg/issues/18066 maybe I should look there for more help ?

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

Re: I search working example cmake for Windows

Post by ONEEYEMAN » Mon Jun 21, 2021 10:37 pm

Hi,
Do you want the end-user of your software to be able to build your project from the ground up?
How many dependencies do you have besides wxWidgets?
Can't you provide the binaries to download and skip building the product by your customers? There is no guarantee they won't break it before or during compilation...

And building everything is easy - just build static version of wxWidgets, create new projects inside MSVC, copy wxwidgets.props file into the project, add all of your source files and build.

Then just drop the resulting binary to download somewhere...

Thank you.

Post Reply