我目前正在尝试在CLion 1.3项目上构建wxWidgets-3.1.0。我使用Ubuntu 16.04(64位)。基本上,我编辑了CMakeLists.txt文件,如下所示:
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})
“外部库”部分也向我展示了wxWidgets,但是当我在main.cpp上写一些行时,编译器似乎无法访问与库相关的所有内容(它全部用红色写,就像一个错误)。无论如何,如果我尝试编译,那就是结果:
/home/federico/ClionProjects/WxProva/main.cpp:2:35: fatal error: wxWidgets-3.1.0/include: File o directory non esistente
compilation terminated.
这就像“文件或目录不存在”。 我该如何解决这个问题?
答案 0 :(得分:5)
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})
欲了解更多信息,请阅读 https://wiki.wxwidgets.org/CMake
修改1
在这里,你甚至不应该在NetBeans中添加一些编译和链接配置(wx-config --cxxflags
和wx-config --libs
)
答案 1 :(得分:0)
这是macOS 10.14.4(Mojave)和CLion 2019.1的示例配置 ( / usr / local 是我安装wxWidgets的文件夹)
request()