Below is what I get:
E:\Projects\SICP>gcc t.c t_.c
C:\DOCUME~1\jim\LOCALS~1\Temp/ccclbaaa.o(.text+0x870):t.c: undefined
refere
nce to `a_::___G(void)'
C:\DOCUME~1\jim\LOCALS~1\Temp/ccclbaaa.o(.text+0x876):t.c: undefined
refere
nce to `a_::___G(void)'
C:\DOCUME~1\jim\LOCALS~1\Temp/ccclbaaa.o(.text+0x8b2):t.c: undefined
refere
nce to `d_::___G(void)'
C:\DOCUME~1\jim\LOCALS~1\Temp/ccclbaaa.o(.text+0x8b8):t.c: undefined
refere
nce to `d_::___G(void)'
C:\DOCUME~1\jim\LOCALS~1\Temp/ccclbaaa.o(.text+0x8d2):t.c: undefined
refere
nce to `d_::___G(void)'
C:\DOCUME~1\jim\LOCALS~1\Temp/ccclbaaa.o(.text+0x8d8):t.c: undefined
refere
nce to `d_::___G(void)'
C:\DOCUME~1\jim\LOCALS~1\Temp/ccclbaaa.o(.text+0x98f):t.c: undefined
refere
nce to `d_::___G(void)'
C:\DOCUME~1\jim\LOCALS~1\Temp/ccclbaaa.o(.text+0x9ea):t.c: more
undefined r
eferences to `d_::___G(void)' follow
C:\DOCUME~1\jim\LOCALS~1\Temp/ccclbaaa.o(.text+0xa50):t.c: undefined
refere
nce to `___G_abs'
C:\DOCUME~1\jim\LOCALS~1\Temp/ccclbaaa.o(.text+0xaab):t.c: undefined
refere
nce to `___G_abs'
C:\DOCUME~1\jim\LOCALS~1\Temp/ccclbaaa.o(.text+0xb0a):t.c: undefined
refere
nce to `___G__3c_'
C:\DOCUME~1\jim\LOCALS~1\Temp/ccclbaaa.o(.text+0xb65):t.c: undefined
refere
nce to `___G__3c_'
C:\DOCUME~1\jim\LOCALS~1\Temp/ccclbaaa.o(.text+0xc65):t.c: undefined
refere
nce to `a_::___G(void)'
C:\DOCUME~1\jim\LOCALS~1\Temp/ccclbaaa.o(.text+0xcc0):t.c: undefined
refere
nce to `a_::___G(void)'
C:\DOCUME~1\jim\LOCALS~1\Temp/ccclbaaa.o(.text+0xcda):t.c: undefined
refere
nce to `d_::___G(void)'
C:\DOCUME~1\jim\LOCALS~1\Temp/ccclbaaa.o(.text+0xce0):t.c: undefined
refere
nce to `d_::___G(void)'
C:\DOCUME~1\jim\LOCALS~1\Temp/ccclbaaa.o(.text+0xd4f):t.c: undefined
refere
nce to `d_::___G(void)'
C:\DOCUME~1\jim\LOCALS~1\Temp/ccclbaaa.o(.text+0xd55):t.c: undefined
refere
nce to `d_::___G(void)'
C:\DOCUME~1\jim\LOCALS~1\Temp/ccclbaaa.o(.text+0xdf5):t.c: undefined
refere
nce to `f_::___G(void)'
C:\DOCUME~1\jim\LOCALS~1\Temp/ccclbaaa.o(.text+0xe50):t.c: undefined
refere
nce to `f_::___G(void)'
C:\DOCUME~1\jim\LOCALS~1\Temp/ccclbaaa.o(.text+0xffa):t.c: undefined
refere
nce to `b_::___G(void)'
C:\DOCUME~1\jim\LOCALS~1\Temp/ccclbaaa.o(.text+0x1000):t.c: undefined
refer
ence to `b_::___G(void)'
C:\DOCUME~1\jim\LOCALS~1\Temp/ccclbaaa.o(.text+0x10a5):t.c: undefined
refer
ence to `b_::___G(void)'
C:\DOCUME~1\jim\LOCALS~1\Temp/ccclbaaa.o(.text+0x1100):t.c: undefined
refer
ence to `b_::___G(void)'
C:\DOCUME~1\jim\LOCALS~1\Temp/ccclbaaa.o(.text+0x1160):t.c: undefined
refer
ence to `f_::___G(void)'
C:\DOCUME~1\jim\LOCALS~1\Temp/ccclbaaa.o(.text+0x11b7):t.c: undefined
refer
ence to `f_::___G(void)'
C:\DOCUME~1\jim\LOCALS~1\Temp/ccIVbaaa.o(.text+0x52):t_.c: undefined
refere
nce to `___main_char'
C:\DOCUME~1\jim\LOCALS~1\Temp/ccIVbaaa.o(.data+0x0):t_.c: undefined
referen
ce to `____20___gambc'
collect2: ld returned 1 exit status
E:\Projects\SICP>gcc t.c t_.c -lgambit
D:\Dev-Cpp\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe:
cannot f
ind -lgambit
collect2: ld returned 1 exit status
I don't know what to do indeed, so can anyone help me? Thank you!
Mao..
PS: the source code is :
(define (iterative-improve judger improver)
(lambda (g)
(if (judger g)
g
((iterative-improve judger improver) (improver g)))))
(define (sqrt-v2 x)
(define (square y)
(* y y))
(define (improve y)
(average y (/ x y)))
(define (good-enough? y)
(< (abs (- (square y)
x))
0.0000000001))
((iterative-improve good-enough? improve) 1.0))
(define (average x y)
(/ (+ x y)
2)
make sure you link with the gambit library, and that gambit.h is in the
include path for these files. On unix it would be something like
gcc t.c t_.c -lgambc -ldl -lm
Brad Lucier
You have to link with the appropriate C libraries. Here's a trace
showing the steps for MinGW and MSYS:
$ cd gambc40b17
$ cat t.scm
(define (iterative-improve judger improver)
(lambda (g)
(if (judger g)
g
((iterative-improve judger improver) (improver g)))))
(define (sqrt-v2 x)
(define (square y)
(* y y))
(define (improve y)
(average y (/ x y)))
(define (good-enough? y)
(< (abs (- (square y)
x))
0.0000000001))
((iterative-improve good-enough? improve) 1.0))
(define (average x y)
(/ (+ x y)
2))
(pp (sqrt-v2 100))
$ gsc/gsc -:d-,=. t.scm
$ gcc -I./include t.c t_.c lib/libgambc.a -lws2_32
$ ./a -:d-
10.
Alternatively you can use the -dynamic option to compile the program.
With this option the Gambit compiler will automatically link with the
Gambit library. For example:
$ gsc/gsc -:d-,=. -dynamic t.scm
$ gsi/gsi -:d- t.o1
10.
Marc