Page 1 of 1

Using wxWidgets with Win10, msys2, mingw64 and CLion

Posted: Fri Sep 25, 2020 10:37 am
by Zimon
Hello,

I am starting to learn how to use wxWidgets and after 3 days am not even able to get it to work using my regular C++ environment. I've read many tutorials, but none of them seem to cover the specific combination of MSYS2, MingW and CLion. My goal is to build an run the HelloWorld App for starters.

Let me list what i've tried:
  • installing the MingW packages "mingw-w64-x86_64-wxWidgets" and "mingw-w64-i686-wxWidgets".
  • manually compile the github packages and installing the libs to MingW
  • using the prebuilt development libraries für MingW (this appeared to be the most promising approach, since I was able to start the compiling process but got loads of errors relating to missing constants of the setup.h, which I still struggle to understand the purpose of).
  • downloading the Linux and Windows versions from the website (what's the difference compared to the github version and which one would I need for the MSYS2, which is a Linux-type system)?
I've read that I am merely to build and install the libs for wxWidgets, but apparently that's not quite the case. I am suprised how different wokring with wx is compared to Qt5, which only needs the packages that are available as part of the msys2/MingW repo.

Sorry for those questions, but after 3 days of trying to get this to work, I can honestly say, that no online source to far really helped me with this and I really would like to try out wxWidgets.

Re: Using wxWidgets with Win10, msys2, mingw64 and CLion

Posted: Fri Sep 25, 2020 12:25 pm
by doublemax
Maybe you should start with the standard: Building wxWidgets and then the "minimal" sample that comes with wxWidgets, with MinGW. This is all well documented in <wxdir>/docs/msw/install.md and e.g. viewtopic.php?f=19&t=47231 (Although this uses CodeBlocks, the first part, just building wxWidgets is the same).

If you run into problems, post what you did and the exact error message you get.

Re: Using wxWidgets with Win10, msys2, mingw64 and CLion

Posted: Fri Sep 25, 2020 9:07 pm
by ONEEYEMAN
Hi,
Hello,
Zimon wrote:
Fri Sep 25, 2020 10:37 am
I am starting to learn how to use wxWidgets and after 3 days am not even able to get it to work using my regular C++ environment. I've read many tutorials, but none of them seem to cover the specific combination of MSYS2, MingW and CLion. My goal is to build an run the HelloWorld App for starters.
Welcome!
Zimon wrote:
Fri Sep 25, 2020 10:37 am
Let me list what i've tried:
  • installing the MingW packages "mingw-w64-x86_64-wxWidgets" and "mingw-w64-i686-wxWidgets".
Let me stop you right there.
When you say "installing wxWidgets" - what did you mean?
Downloaded and run the installer?
Downloaded prebuilt binaries from wxwidgets.org/download?
Installed prebuilt binaries from the MSYS environment??
Something else?
Zimon wrote:
Fri Sep 25, 2020 10:37 am
  • manually compile the github packages and installing the libs to MingW
Did you compile them using standard MSYS way - using configure?
Or you are working from the Windows environment with just MinGW?
Zimon wrote:
Fri Sep 25, 2020 10:37 am
  • using the prebuilt development libraries für MingW (this appeared to be the most promising approach, since I was able to start the compiling process but got loads of errors relating to missing constants of the setup.h, which I still struggle to understand the purpose of).
What you were tried to compile? How? Inside MSYS or Windows environment? What command did you use?
Zimon wrote:
Fri Sep 25, 2020 10:37 am
  • downloading the Linux and Windows versions from the website (what's the difference compared to the github version and which one would I need for the MSYS2, which is a Linux-type system)?
Please do not mix up different OSes - start with one and then move to the other one.
For the MSYS you will need the Windows source code.
Zimon wrote:
Fri Sep 25, 2020 10:37 am
I've read that I am merely to build and install the libs for wxWidgets, but apparently that's not quite the case. I am suprised how different wokring with wx is compared to Qt5, which only needs the packages that are available as part of the msys2/MingW repo.
I believe there is a package made for MSYS environment and you can catch its "maintainer" here on the forum.
However, it is very easy to build wxWidgets for MSYS{2} -- do the following:

Code: Select all

cd wxWidgets
mkdir buildMSYS
cd buildMSYS
CXXFLAGS="-std=c++11" ..configure --with-msw --enable-debug && make
make install
Now, the only difference between Windows and Linux/Mac versions is the line ending,
But for MSYS2 getting the Windows archive is better.
Zimon wrote:
Fri Sep 25, 2020 10:37 am
Sorry for those questions, but after 3 days of trying to get this to work, I can honestly say, that no online source to far really helped me with this and I really would like to try out wxWidgets.
Please let us know if you get any other questions - we are here to help.

Thank you.

Re: Using wxWidgets with Win10, msys2, mingw64 and CLion

Posted: Sat Sep 26, 2020 8:26 am
by stahta01
Word of warning trying to use the wx-config from the MSys2 MinGW32/64 wxWidgets 3.0.5.1 or 3.1.3 package is not easy to do unless it is ran from inside the Msys2 sh.exe.

I have no idea how Clion IDE finds the location of wxWidgets; without this info I have no idea if the OP should try using the MSys2 wxWidgets packages or not. Or if the OP needs to build the wxWidgets binaries for themselves.

Tim S.

Re: Using wxWidgets with Win10, msys2, mingw64 and CLion

Posted: Sat Sep 26, 2020 6:50 pm
by stahta01
I have downloaded an 30 day trial copy of Clion; I am on Windows 7 64 bit.

I will see if I can build the wxWidgets CMake minimal sample; could be hours or days before I make much progress.

Links I plan to use as reference
https://www.jetbrains.com/help/clion/qu ... ndows.html
viewtopic.php?t=45198

CLion with MSYS2 https://gist.github.com/phazmatis/fd747 ... 7da49baacb
CLion with MSYS2 and Qt https://blog.bachi.net/?p=9485
Embedding MSYS2 terminal in CLion https://menaceinc.com/2019/03/embedding-msys2-in-clion/

Tim S.

Re: Using wxWidgets with Win10, msys2, mingw64 and CLion

Posted: Sat Sep 26, 2020 10:28 pm
by stahta01
I have decide to remove Clion from the problem.

So, I will first try to get MSys2, MinGW64 GCC, CMake, and wxWidgets to work together.

Tim S.

Re: Using wxWidgets with Win10, msys2, mingw64 and CLion

Posted: Sun Sep 27, 2020 4:20 am
by stahta01
I have gotten minimal to build under Clion.

The below line is for use with normal "mingw32-make -f makefile.gcc" built wxWidgets

Code: Select all

-DwxWidgets_FIND_STYLE:STRING="win32" -DwxWidgets_ROOT_DIR:STRING="C:/repos/git/wxWidgets" -DwxWidgets_LIB_DIR:STRING="C:/repos/git/wxWidgets/lib/gcc_dll" -DwxWidgets_CONFIGURATION="mswu"
The above had to be added to "Cmake Options"
I found this setting under File -> Settings
Build, Execution, Deployment -> cmake

It built OK; but, it had run-time errors likely missing DLLs from run-time path.

Edit: I built wxWidgets git master branch shared libs; I am now building git master branch static libs to see if the run-time error goes away.

Tim S.

Re: Using wxWidgets with Win10, msys2, mingw64 and CLion

Posted: Sun Sep 27, 2020 11:28 am
by stahta01
Check disk found no problems after last night major problem (Hard drive space was exhausted)

Static wxWidgets libraries built and sample built and ran with no problem

Code: Select all

-DwxWidgets_FIND_STYLE:STRING="win32" -DwxWidgets_ROOT_DIR:STRING="C:/repos/git/wxWidgets" -DwxWidgets_LIB_DIR:STRING="C:/repos/git/wxWidgets/lib/gcc_lib" -DwxWidgets_CONFIGURATION="mswu"
Complete rebuild log

Code: Select all

====================[ Clean | Release ]=========================================
"C:\Program Files\JetBrains\CLion 2020.2.3\bin\cmake\win\bin\cmake.exe" --build C:\repos\git\wxWidgets\samples\minimal\cmake-build-release --target clean -- -j 1

Clean finished

====================[ Build | all | Release ]===================================
"C:\Program Files\JetBrains\CLion 2020.2.3\bin\cmake\win\bin\cmake.exe" --build C:\repos\git\wxWidgets\samples\minimal\cmake-build-release --target all -- -j 1
[ 33%] Building CXX object CMakeFiles/minimal.dir/minimal.cpp.obj
[ 66%] Building RC object CMakeFiles/minimal.dir/C_/repos/git/wxWidgets/samples/sample.rc.obj
[100%] Linking CXX executable minimal.exe
[100%] Built target minimal

Build finished
Run log

Code: Select all

C:\repos\git\wxWidgets\samples\minimal\cmake-build-release\minimal.exe

Process finished with exit code 0

Tim S.

Re: Using wxWidgets with Win10, msys2, mingw64 and CLion

Posted: Sun Sep 27, 2020 6:09 pm
by stahta01
Since, I got an CLion minimal static wxWidgets built using makefile.gcc to build and run without error; I have uninstalled CLion.

Tim S.