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

wxWidgets & CLion on Linux

Post by stormfinger »

hi

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.

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

Re: wxWidgets & CLion on Linux

Post by ONEEYEMAN »

Hi,
So do you still have problems?

Thank you.
aduq
Earned a small fee
Earned a small fee
Posts: 15
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.
stormfinger
In need of some credit
In need of some credit
Posts: 4
Joined: Mon Oct 11, 2021 5:41 pm

Re: wxWidgets & CLion on Linux

Post by stormfinger »

No i dont have problems anymore as i described procedure how to build from scratch specialy now that wxWidgets is available on github. NOTE when updating wxWidgets or changing directory make sure Clion is not using cached values. i found that best is delete cmake-build-debug directory and close/open Clion. this will also require rebuilding project ..sometimes it needs more than once to rebuild with closing/opening IDE..

Also invalidating cache with both options on will delete enviroment variable set in CLion. so if you arent using several wxWidgets versions i assume it is better to declare variable in user session.

Regards
aduq
Earned a small fee
Earned a small fee
Posts: 15
Joined: Mon Oct 18, 2021 1:27 pm

Re: wxWidgets & CLion on Linux

Post by aduq »

stormfinger wrote: Mon Nov 08, 2021 8:42 pm No i dont have problems anymore as i described procedure how to build from scratch specialy now that wxWidgets is available on github. NOTE when updating wxWidgets or changing directory make sure Clion is not using cached values. i found that best is delete cmake-build-debug directory and close/open Clion. this will also require rebuilding project ..sometimes it needs more than once to rebuild with closing/opening IDE..

Also invalidating cache with both options on will delete enviroment variable set in CLion. so if you arent using several wxWidgets versions i assume it is better to declare variable in user session.

Regards
Have you installed wxWidgets locally? You could, for example, use a docker image with the library version you want already installed. Then, in CMake, just use the FindPackage module to use wxWidgets. You can specify which version you want to use as well.
Post Reply