Clion+GTK

打开msys2终端,依次输入 

pacman -S mingw-w64-x86_64-gtk3
pacman -S mingw-w64-x86_64-glade
pacman -S mingw-w64-x86_64-toolchain base-devel

打开clion

修改cmake

cmake_minimum_required(VERSION 3.16)
#下面这个c90_Demo改成项目名
project(c90_Demo C)

#这个90改成你的C语言标准,如99,11
set(CMAKE_C_STANDARD 90)
FIND_PACKAGE(PkgConfig REQUIRED)
PKG_CHECK_MODULES(GTK3 REQUIRED gtk+-3.0)

INCLUDE_DIRECTORIES(${GTK3_INCLUDE_DIRS})
LINK_DIRECTORIES(${GTK3_LIBRARY_DIRS})

#下面这个c90_Demo改成项目名
add_executable(c90_Demo main.c)
#下面这个c90_Demo改成项目名
TARGET_LINK_LIBRARIES(c90_Demo ${GTK3_LIBRARIES})

main.c

#include 

static void activate(GtkApplication *app, gpointer user_data) {
    GtkWidget *window;
    window = gtk_application_window_new(app);
    gtk_window_set_title(GTK_WINDOW(window), "Window");
    gtk_window_set_default_size(GTK_WINDOW(window), 200, 200);
    gtk_widget_show_all(window);
}

int main(int argc, char **argv) {
    GtkApplication *app;
    int status;
    app = gtk_application_new("org.gtk.example", G_APPLICATION_FLAGS_NONE);
    g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
    status = g_application_run(G_APPLICATION(app), argc, argv);
    g_object_unref(app);
    return status;
}

运行结果 

Clion+GTK_第1张图片

你可能感兴趣的:(安装与配置)