chicken-users
[Top][All Lists]
Advanced

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

[Chicken-users] static library and link


From: Frederic Peschanski
Subject: [Chicken-users] static library and link
Date: Mon, 22 May 2006 19:14:38 +0200
User-agent: Mozilla Thunderbird 1.0.6 (Windows/20050716)

Hello,

I am working on a library (maybe an egg at some point) for chicken.
I have some record of scheme programming but I am new to chicken.

My initial plan, in order to be portable across linux and cygwin, was to
compile a static library e.g. mylib.a  from the .scm (and .c and .o) files.

For the library part, the makefile I use produces something like:

chicken src/utils.scm -optimize-level 1 -output-file src/utils.c
compiling `src/utils.scm' ...
generating `src/utils.c' ...
gcc -DHAVE_CHICKEN_CONFIG_H -Os -fomit-frame-pointer -fno-strict-aliasing -Wall -Wno-unused 
-Wno-uninitialized -DHAVE_ALLOCA_H -DC_STACK_GROWS_DOWNWARD=1 
-DC_INSTALL_LIB_HOME="/usr/lib/chicken" -DC_INSTALL_HOME="/usr/share/chicken" 
-DC_USE_C_DEFAULTS -DC_NO_PIC_NO_DLL  -c src/utils.c -o src/utils.o
chicken src/semaphore.scm -optimize-level 1 -output-file src/semaphore.c
compiling `src/semaphore.scm' ...
generating `src/semaphore.c' ...
> .... other files here ....
gcc -DHAVE_CHICKEN_CONFIG_H -Os -fomit-frame-pointer -fno-strict-aliasing -Wall -Wno-unused 
-Wno-uninitialized -DHAVE_ALLOCA_H -DC_STACK_GROWS_DOWNWARD=1 
-DC_INSTALL_LIB_HOME="/usr/lib/chicken" -DC_INSTALL_HOME="/usr/share/chicken" 
-DC_USE_C_DEFAULTS -DC_NO_PIC_NO_DLL  -c src/pischeme.c -o src/pischeme.o
ar cru lib/libpischeme.a src/utils.o src/semaphore.o src/dyntype.o 
src/pichannel.o src/pischeme.o
ranlib lib/libpischeme.a
rm src/pichannel.c src/semaphore.c src/dyntype.c src/utils.c src/pischeme.c

It's probably bad but in my .scm files, only the main one, pischeme.scm starts with a "declare unit" (I think this does only apply to shared libraries).

Maybe I should use csc instead of chicken but I have not yet figured out
how I could use it to make a static lib.

Now, in a separate directory, I wrote an example that I compile as follows:

chicken pingpong.scm -optimize-level 1 -output-file pingpong.c
compiling `pingpong.scm' ...
generating `pingpong.c' ...
gcc -DHAVE_CHICKEN_CONFIG_H -Os -fomit-frame-pointer -fno-strict-aliasing -Wall -Wno-unused 
-Wno-uninitialized -DHAVE_ALLOCA_H -DC_STACK_GROWS_DOWNWARD=1 
-DC_INSTALL_LIB_HOME="/usr/lib/chicken" -DC_INSTALL_HOME="/usr/share/chicken" 
-DC_USE_C_DEFAULTS -DC_NO_PIC_NO_DLL  -c pingpong.c -o pingpong.o
ld pingpong.o -lpcre -lm  -lpcre -lchicken  ../../lib/libpischeme.a -o 
pingpong.exe
ld: warning: cannot find entry symbol _mainCRTStartup; defaulting to 00401000
pingpong.o(.text+0x79):pingpong.c: undefined reference to `__main'
../../lib/libpischeme.a(pischeme.o)(.text+0x13b):pischeme.c: undefined 
reference to `C_h_list'
../../lib/libpischeme.a(pischeme.o)(.text+0x352):pischeme.c: undefined 
reference to `C_srfi_18_toplevel'
../../lib/libpischeme.a(pischeme.o)(.text+0x5b4):pischeme.c: undefined 
reference to `C_i_car'
../../lib/libpischeme.a(pischeme.o)(.text+0x5c3):pischeme.c: undefined 
reference to `C_i_cadr'
../../lib/libpischeme.a(pichannel.o)(.text+0xf4):pichannel.c: undefined 
reference to `C_temporary_stack_bottom'
../../lib/libpischeme.a(pichannel.o)(.text+0x105):pichannel.c: undefined 
reference to `_alloca'
... and so on ...
Info: resolving _C_temporary_stack by linking to __imp__C_temporary_stack 
(auto-import)
Info: resolving _C_stack_limit by linking to __imp__C_stack_limit (auto-import)
Info: resolving _C_fromspace_top by linking to __imp__C_fromspace_top 
(auto-import)
Info: resolving _C_fromspace_limit by linking to __imp__C_fromspace_limit 
(auto-import)
Info: resolving _C_timer_interrupt_counter by linking to 
__imp__C_timer_interrupt_counter (auto-import)
make: *** [pingpong] Error 1
rm pingpong.c

I am sure I am not using the correct steps... Maybe I should spend sometimes already to look at the generated C code to understand the
way to make it modular (in the weak C understanding of the term)
but if you see what's wrong with my naive approach I would be happy,
undoubtfully.

Or maybe it's simply wrong to make a static lib ?

Thanks in advance,
Frederic Peschanski.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]