Page 1 of 1

I search working example cmake for Windows

Posted: Sun May 30, 2021 8:56 am
by AndrzejB
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.

Re: I search working example cmake for Windows

Posted: Sun May 30, 2021 9:50 am
by PB
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

Re: I search working example cmake for Windows

Posted: Sun Jun 20, 2021 3:58 pm
by bitdiverly
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!

Re: I search working example cmake for Windows

Posted: Sun Jun 20, 2021 8:29 pm
by ONEEYEMAN
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.

Re: I search working example cmake for Windows

Posted: Mon Jun 21, 2021 8:28 am
by bitdiverly
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)

Re: I search working example cmake for Windows

Posted: Mon Jun 21, 2021 11:50 am
by ONEEYEMAN
Hi,
What os are you building?

Thank you.

Re: I search working example cmake for Windows

Posted: Mon Jun 21, 2021 12:11 pm
by bitdiverly
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 ?

Re: I search working example cmake for Windows

Posted: Mon Jun 21, 2021 10:37 pm
by ONEEYEMAN
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.