I'm now playing with LLVM and it's JIT. I'm pretty interested in the JIT and then I wrote a small 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;
}
I compiled it into Bitcode this way:
clang -emit-llvm -S a.c `pkg-config --cflags gtk+-3.0`
llvm-link a.s -o a.o
But when I run it
> lli a.o
LLVM ERROR: Program used external function 'gtk_init' which could not be resolved!
I tried to find out how to add an external library when linking, but I found nothing. Is there a way to let it run?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…