[gambit-list] Building loadable library
Kartik Saranathan
ksaranat at gmail.com
Thu May 12 01:39:14 EDT 2011
I have the following setup
fileio.scm - contains c-lambda forms to bind C functions in fileio_util.cpp
fileio_util.cpp - contains code that uses functions from gambit
runtime library (data conversion functions like
___UTF_8STRING_to_SCMOBJ)
I'd like to make a loadable library from the above. Here is what I tried
bash-3.2$ uname -srmp
Darwin 10.7.0 i386 i386
gsc -link -flat -o search.o1.c fileio
g++ -no-cpp-precomp -Wno-unused -O1 -fno-math-errno
-fschedule-insns2 -fno-trapping-math -fno-strict-aliasing -fwrapv
-fomit-frame-pointer -fno-move-loop-invariants -fPIC -fno-common
-mieee-fp -D___SINGLE_HOST -I"/usr/local/Gambit-C/include" -c -o
"fileio_util.o" -D___DYNAMIC fileio_util.cpp
g++ -no-cpp-precomp -Wno-unused -O1 -fno-math-errno
-fschedule-insns2 -fno-trapping-math -fno-strict-aliasing -fwrapv
-fomit-frame-pointer -fno-move-loop-invariants -fPIC -fno-common
-mieee-fp -D___SINGLE_HOST -I"/usr/local/Gambit-C/include" -c -o
"search.o1.o" -D___DYNAMIC search.o1.c
g++ -no-cpp-precomp -Wno-unused -O1 -fno-math-errno
-fschedule-insns2 -fno-trapping-math -fno-strict-aliasing -fwrapv
-fomit-frame-pointer -fno-move-loop-invariants -fPIC -fno-common
-mieee-fp -D___SINGLE_HOST -I"/usr/local/Gambit-C/include" -c -o
"fileio.o" -D___DYNAMIC fileio.c
g++ -bundle fileio_util.o fileio.o sqlite3.o search.o1.o -o search.o1
Linker gives the following errors
Undefined symbols:
"___S64_to_SCMOBJ(long, long*, int)", referenced from:
ConvertSqliteData(sqlite3_stmt*, int, int, long&)in fileio_util.o
"___UTF_8STRING_to_SCMOBJ(char*, long*, int)", referenced from:
ConvertSqliteData(sqlite3_stmt*, int, int, long&)in fileio_util.o
w_sqlite_prepare(sqlite3*, char*)in fileio_util.o
"___F64_to_SCMOBJ(double, long*, int)", referenced from:
ConvertSqliteData(sqlite3_stmt*, int, int, long&)in fileio_util.o
Since libgambc.a defines those symbols I tried liking with it. Here
is what I get.
Undefined symbols:
"_environ", referenced from:
___unsetenv_UCS_2(unsigned short*)in libgambc.a(os_shell.o)
___cleanup_shell_module() in libgambc.a(os_shell.o)
___os_environ() in libgambc.a(os_shell.o)
___setenv_UCS_2(unsigned short*, unsigned short*)in
libgambc.a(os_shell.o)
___setenv_UCS_2(unsigned short*, unsigned short*)in
libgambc.a(os_shell.o)
___getenv_UCS_2(unsigned short*, unsigned short**)in
libgambc.a(os_shell.o)
___device_stream_setup_from_process(___device_stream_struct**,
___device_group_struct*, char**, char**, char*, int)in
libgambc.a(os_io.o)
(maybe you meant:
____G__23__23_fail_2d_check_2d_unbound_2d_os_2d_environment_2d_variable_2d_exception,
____G__23__23_display_2d_dynamic_2d_environment_3f_ , ... )
Also at first tried using gsc to run the compiler for me
gsc -verbose -cc-options "-D___DYNAMIC" -obj fileio.c
fileio_util.cpp search.o1.c
But I kept getting
*** ERROR IN "fileio_util.cpp"@1.1 -- Invalid token
I realized it was treating the .cpp file as a scheme file and failing.
Is this a bug or am I using it incorrectly? How do I compile the
above as a loadable library?
Thank you for Gambit. The more I use it the more I like it.
More information about the Gambit-list
mailing list