写一个简单的例子:
main.c:
#include <stdio.h>
#include <stdlib.h>
#include <libguile.h>
int main (int argc, char *argv[])
{
SCM func_symbol;
SCM func;
scm_init_guile();
// Load the scheme function definitions
scm_c_primitive_load ("script.scm");
func_symbol = scm_c_lookup("do-hello");
func = scm_variable_ref(func_symbol);
scm_call_0 (func);
exit(EXIT_SUCCESS);
}
Makefile:
CC = gcc
GUILE_CFLAGS = `guile-config compile`
GUILE_LIBS = `guile-config link`
all:
$(CC) $(GUILE_CFLAGS) -c main.c
$(CC) $(GUILE_LIBS) -o main main.o
如果连接有错误的话,把
$(CC) $(GUILE_LIBS) -o main main.o
改成
$(CC) main.o $(GUILE_LIBS)
-o main
注意:因为这里gcc一般都是把-l参数放在最后一个-o参数之前的.