我从 Github 克隆了该项目,但没有足够的配置来执行这些文件。如何创建/添加它?我尝试运行 -> 编辑配置,创建一个 CMake 应用程序,但是我应该在Target和Executable中放入什么?
Булат
Asked:
2022-07-21 22:15:45 +0800 CST
组装时,会出现一条消息,说它看不到gtk/gtk.h
. 如果你指出这一点gtk-3.0/gtk/gtk.h
并且gtk-3.0/gdk/gdk.h
已经对别的东西发誓。但最重要的是,如果你尝试通过控制台编译这段代码:
#include <gtk/gtk.h>
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;
}
使用以下命令一切都会好起来的:
gcc `pkg-config --cflags gtk+-3.0` -o test test.c `pkg-config --libs gtk+-3.0`
在 Ubuntu 22.04 上工作
附言
Cmake 输出:
/snap/clion/198/bin/cmake/linux/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=/snap/clion/198/bin/ninja/linux/ninja -G Ninja -S /home/home-pc/CLionProjects/gtk_PNX -B /home/home-pc/CLionProjects/gtk_PNX/cmake-build-debug
-- Configuring done
-- Generating done
-- Build files have been written to: /home/home-pc/CLionProjects/gtk_PNX/cmake-build-debug
[Finished]
CMakeLists.txt:
cmake_minimum_required(VERSION 3.22)
project(gtk_PNX C)
set(CMAKE_C_STANDARD 99)
add_executable(gtk_PNX main.c)