提示:以下是本篇文章正文内容,下面案例可供参考
>.前文有些已经配好
pacman -S mingw-w64-x86_64-libsigc++−3.0
pacman -S mingw-w64-x86_64-glibmm-2.68
pacman -S mingw-w64-x86_64-gtkmm-4.0
>.从msys2官网搜索到它点进去也能看到它的依赖
>.pacman -Q 查询所有已安装, pacman -R [目标名] 移除
>.pacman -Q [目标名] 查询该目标是否安装
cmake_minimum_required(VERSION 3.8)
project(untitled)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
find_package(PkgConfig)
pkg_check_modules(GTKMM gtkmm-4.0)
include_directories(${GTKMM_INCLUDE_DIRS})
link_directories(${GTKMM_LIBRARY_DIRS})
set(SOURCE_FILES main.cpp)
add_executable(untitled ${SOURCE_FILES})
target_link_libraries(${CMAKE_PROJECT_NAME} ${GTKMM_LIBRARIES})
重启CLion后 编译下面代码再运行
#include
class MyWindow : public Gtk::Window
{
public:
MyWindow();
};
MyWindow::MyWindow()
{
set_title("GTKMM4");
set_default_size(200, 200);
}
int main(int argc, char* argv[])
{
auto app = Gtk::Application::create("my_test.examples.base");
return app->make_window_and_run<MyWindow>(argc, argv);
}