Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building wxWidgets 3.1.0 on CLion (Ubuntu)

I am currently trying to build wxWidgets-3.1.0 on a CLion 1.3 project. I use Ubuntu 16.04 (64 bit). Basically, I edited the CMakeLists.txt file like this:

cmake_minimum_required(VERSION 3.5)
project(WxProva)

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules"
${CMAKE_MODULE_PATH})

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

set(SOURCE_FILES main.cpp)
add_executable(WxProva ${SOURCE_FILES})

find_package(wxWidgets)
include_directories(${wxWidgets_INCLUDE_DIRS})
target_link_libraries(WxProva ${wxWidgets_LIBRARIES})

The "External Libraries" section also shows me wxWidgets, but when it comes to write some lines on my main.cpp, everything related with the library seems to be unreachable by the compiler (it's all written in red, like an error). Anyway, if I try to compile, that's the result:

/home/federico/ClionProjects/WxProva/main.cpp:2:35: fatal error: wxWidgets-3.1.0/include: File o directory non esistente
compilation terminated.

Which is like "File or directory doesn't exists." How can I fix this?

like image 809
Federico Màlato Avatar asked Oct 05 '16 10:10

Federico Màlato


2 Answers

After some experiments here solution. You can just copy it and change some information and ready to build and run.

cmake_minimum_required(VERSION 3.7)
project(Your_Project_Name) //any name for your project

set(CMAKE_CXX_STANDARD 11)

set(wxWidgets_ROOT_DIR </usr/include/wx-3.0-unofficial>) // here I am  giving where to search for wxwidgets library. it can be different for you
set(wxWidgets_CONFIGURATION mswu)
find_package(wxWidgets COMPONENTS core base REQUIRED)
include(${wxWidgets_USE_FILE})

set(SOURCE_FILES main.cpp)
add_executable(FirstC ${SOURCE_FILES})

target_link_libraries(FirstC ${wxWidgets_LIBRARIES})

For more Information read https://wiki.wxwidgets.org/CMake

Edit 1 Here you shouldn't even add some compile and link config (wx-config --cxxflags and wx-config --libs) as it is necessary in NetBeans

like image 180
Jasurbek Nabijonov Avatar answered Sep 18 '22 13:09

Jasurbek Nabijonov


Here is example configuration for macOS 10.14.4 (Mojave) and CLion 2019.1 (/usr/local is folder where I installed wxWidgets)

cmake_minimum_required(VERSION 3.14)
project(wx1Test)

set(CMAKE_CXX_STANDARD 14)

set(wxWidgets_ROOT_DIR </usr/local/include/wx-3.1>)
set(wxWidgets_CONFIGURATION mswu)
find_package(wxWidgets COMPONENTS core base  REQUIRED)
include(${wxWidgets_USE_FILE})

set(SOURCE_FILES main.cpp)
add_executable(wx1Test ${SOURCE_FILES})

target_link_libraries(wx1Test ${wxWidgets_LIBRARIES})
like image 39
Irek Avatar answered Sep 16 '22 13:09

Irek