Building wxWidgets 3.1.0 on CLion (Ubuntu)

允我心安 提交于 2019-12-31 00:42:07

问题


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?


回答1:


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




回答2:


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})


来源:https://stackoverflow.com/questions/39871053/building-wxwidgets-3-1-0-on-clion-ubuntu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!