我现在正在玩 LLVM,它是 JIT。我对 JIT 很感兴趣,然后我写了一个小 GTK+ hello world:
#include <gtk/gtk.h>
int main ()
{
gtk_init(NULL, NULL);
GtkWidget *win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (win, "delete-event", G_CALLBACK (gtk_main_quit), NULL);
GtkWidget *lbl = gtk_label_new ("hello world");
gtk_container_add (GTK_CONTAINER (win), lbl);
gtk_widget_show_all (win);
gtk_main();
return 0;
}
我以这种方式将其编译为 Bitcode:
clang -emit-llvm -S a.c `pkg-config --cflags gtk+-3.0`
llvm-link a.s -o a.o
但是当我运行它时
> lli a.o
LLVM ERROR: Program used external function 'gtk_init' which could not be resolved!
我试图找出如何在链接时添加外部库,但我什么也没找到。有没有办法让它运行?