TinyC + GTK2 + pkg-config(主要缺失)

时间:2018-04-22 09:12:55

标签: gtk gtk2 pkg-config tcc

对于以下用GCC编译的程序:

$ gcc memtray.c `pkg-config --libs --cflags gtk+-2.0`

但不适用于TinyC(命令在单个字符g - > t)中有所不同:

$ tcc memtray.c `pkg-config --libs --cflags gtk+-2.0`
tcc: error: undefined symbol 'main'

但主要是:

#include <gtk/gtk.h>
#include <string.h>
#include <stdlib.h>

..... program code .....    

int main(int argc, char ** argv) {
    gtk_init(&argc, &argv);
    create_tray_icon();
    gtk_main();
    return 0;
}

这是pkg-config展开的内容:

$ pkg-config --libs --cflags gtk+-2.0
-pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include
-I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0
-I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1
-I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12
-I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0
-I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include
-I/usr/include/freetype2 -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0
-latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0
-lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype

注意-phtread部分,如果我发出下面的命令(与上面相同,但没有-pthread),我的程序就没有必要了,编译工作正常:

 $ tcc memtray.c -o memtray -I/usr/include/gtk-2.0
-I/usr/lib/x86_64-linux-gnu/gtk-2.0/include
-I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0
-I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1
-I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12
-I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0
-I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include
-I/usr/include/freetype2 -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0
-latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0
-lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype

但这样长的命令不仅不方便,而且便携性较差。

如何用TinyC和pkg-config编译GTK2程序?

0 个答案:

没有答案