Ubuntu 安装 GLib

 5个月前     3  

文章目录

安装

sudo apt install libglib2.0-dev

查看路径

pkg-config --cflags glib-2.0
pkg-config --libs glib-2.0

编译

cc hello.c `pkg-config --cflags --libs glib-2.0` -o hello

或者

clang hello.c `pkg-config --cflags --libs glib-2.0` -o hello

hello.c

#include <glib.h>
#include <stdlib.h>
#include <stdio.h>

int main(int argc, char** argv) {
 GList* list = NULL;
 list = g_list_append(list, "Hello world!");
 printf("The first item is '%s'\n", g_list_first(list)->data);
 return 0;
}

暂无评论

暂无评论...