wxWidgets & CLion on Linux

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
In need of some credit
In need of some credit
Posts: 1
Joined: Mon Oct 11, 2021 5:41 pm

wxWidgets & CLion on Linux

Post by stormfinger »


i seen lots of ppl have problem with CLion and wxWidgets on linux ..as most have also found solution from viewtopic.php?p=197038#p187276 but its only half of solution because we come to problem if we have more than one library to use ..so i took day for getting familiar with the subject .. the short for inpatient is set your environment variable WX_CONFIG=/pathTo/wx-config ..clion has cmake script that searches for wx-config to configure library but there is problem your linux session can use other command line interpreter than sh as mine uses bash ...because script assumes sh, wx-config doesnt execute. Changing the script can work too but i dont know what would happen on upgrade. if you provide whole path to wx-config sh will find it and execute it..i did set enviroment variable within CLion .. File | Settings | Build, Execution, Deployment | Cmake > Enviroment. i did notice that sometimes when i invalidate cache can clear the Enviroment variable within Clion but havent it yet set it in system.

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

Re: wxWidgets & CLion on Linux


So do you still have problems?

Thank you.
In need of some credit
In need of some credit
Posts: 3
Joined: Mon Oct 18, 2021 1:27 pm

Re: wxWidgets & CLion on Linux

Post by aduq »

Hey there,

I am currently using CLion and the wxWidgets library. You have two options, maybe three, to set up CLion and wxWidgets.
CLion is just the IDE that supports CMake, so you have to think that you need to make available wxWidgets to CMake in order to compile your project.

1st option:
- Windows & Linux: Fetch and compile wxWidgets using the FetchContent module from CMake in your project. This is quite easy and that's how I was working until some weeks ago in windows.

2nd option:
- Windows: The FetchContent module from CMake is quite nice because it allows you to download any library that is made using CMake but for big libraries such as this one is better to install the whole library in your local machine and use the find_package() function to add the library. So following the installation procedure from the wxWidgets website, you can build and set the installation path to C:/wxWidgets for example. Then, in CMake you will need to set up the following variables:
  • - wxWidgets_ROOT_DIR
    - wxWidgets_LIB_DIR
    - wxWidgets_INCLUDE_DIRS
Once all this is set up, you just add the following line to use wxWidgets
- find_package(wxWidgets REQUIRED net gl core base)

Now, you have avoided the full fetching and building of the library.

- Linux: Using GitHub you can do the following commands to install wxWidgets. In this example, I am going to set the v3.1.4 release.
  • - cd Downloads
    - gh repo clone wxWidgets/wxWidgets
    - cd wxWidgets
    - git fetch --tags
    - git checkout v3.1.4
    - mkdir build-debug
    - cd build-debug
    - cmake ..
    - sudo make -j 8 install
You will have installed wxWidgets in your Linux distribution. From there you just need to call wxWidgets using the find_package() function.

In this repo, you have the main branch which works on Linux, and in order to compile it, you need to install wxWidgets in your local machine.
There is another branch called cmake-supports-wxwidgets-windows where previously you have installed wxWidgets following the installation instructions from wxWidgets and the installation path is C:/wx314_install/Debug for the Debug mode and C:/wx314_install/Release for the release mode.

Source code: https://github.com/AndresDuque/wxWidgetsCLion

I will be happy to write/update the current solution that is in the wiki. If someone can tell me how can I do it, I will do it.
Post Reply