[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [plt-scheme] Embebed Mzscheme

Lo, on Tuesday, May 7, Paulo J. Matos did write:

> Hi all,
> Following the manual "Inside MzScheme" I've passed the example
> in the first pages just to test if embebeding mzscheme is fine in
> my PC... (I mean, if configs are ok) and I've found out that they
> are not. After compiling DrScheme to get libmzscheme.a and
> libmzgc.a as mentioned in the manual I've added
> /usr/local/plt/lib to LD_LIBRARY_PATH and ran ldconfig as root.
> Then I've tried to compile scheme.c (the file containing the
> example) and I get:
> bash-2.05$ gcc -o scheme scheme.o -lmzscheme -lmzgc
> /usr/i386-slackware-linux/bin/ld: cannot find -lmzscheme
> This is indeed strange.

LD_LIBRARY_PATH is only relevant when you're running the built
executable.  Try adding the -L switch to the compiler command line,
specifying the directory where gcc should look for libraries: something
like -L/usr/local/lib/plt/....  See the gcc man/info pages for more

> However if I try to solve this by creating symbolic links to:
> libmzscheme.a, libmzscheme.la, libmzgc.a, libmzgc.la I get a LOT

The .la's are supplementary files created by libtool; you don't need
those at all.  In any case, creating symlinks like this isn't the right
answer; use the -L switch.

Incidentally, do libmzscheme.so and libmzgc.so not exist?  (I don't have
PLT installed right now due to computer problems, so I can't check
myself.)  If they do, you'll almost certainly want to use those
instead.  Of course, if you supply the correct directory with the -L
switch, the compiler will default to the shared libs over the statics.

> of undefined reference... I've pasted a few:
> /usr/local/lib/libmzscheme.a(number.o): In function `exp_prim':
> /home/pdestroy/src/plt/src/mzscheme/src/./number.c:1375: undefined reference to `exp'
> /usr/local/lib/libmzscheme.a(number.o): In function `log_prim':
> /home/pdestroy/src/plt/src/mzscheme/src/./number.c:1376: undefined reference to `log'
> <snip>
> /home/pdestroy/src/plt/src/mzscheme/src/./dynext.c:235: undefined reference to `dlopen'
> /home/pdestroy/src/plt/src/mzscheme/src/./dynext.c:237: undefined reference to `dlerror'
> /home/pdestroy/src/plt/src/mzscheme/src/./dynext.c:251: undefined reference to `dlsym'

Check the man pages for the functions in question; they should tell you
which additional libraries you need to link in.  exp and log are both in
libm.so; dlopen, dlerror, and dlsym are all in libdl.so (at least on my
Debian/stable system).  Add `-lm -ldl' to your command line.