Pregunta

I want to embed guile in a c++ application, but I get "undefined reference" errors when I try to compile: Ubuntu 12.04 guile-1.8.8

If I compile the example from the guile docs

gcc -o guile-test `pkg-config guile-1.8 --cflags` `pkg-config guile-1.8 --libs` guile-test.c

on the console, it aborts with errors:

/tmp/ccHZCHNL.o: In function `inner_main':
guile-test.c:(.text+0x14): undefined reference to `scm_shell'
/tmp/ccHZCHNL.o: In function `main':
guile-test.c:(.text+0x41): undefined reference to `scm_boot_guile'
collect2: ld gab 1 als Ende-Status zurück

If I compile some example.so (including "libguile.h") to embed in guile, all is working as expected.

Does anybody know, what might cause this error?

Best, Jan-Peter

¿Fue útil?

Solución

Yes. You didn't follow their build instructions correctly. :-) In particular, you need to specify link dependencies after the dependent objects. Try this instead:

gcc -o guile-test `pkg-config guile-1.8 --cflags` guile-test.c `pkg-config guile-1.8 --libs`

In particular, the libraries need to be listed after all the objects that use them, such as guile-test.c.

(By the way, this isn't Guile-specific. The standard linker always expects this ordering.)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top