Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

I can't get dev-cpp to compile C files produced by gsc(Gambit-C 4.0 beta 17)

11 views
Skip to first unread message

nobunaga86c...@yahoo.com.cn

unread,
Apr 9, 2006, 6:55:22 AM4/9/06
to
Hello! This afternoon I asked how to compile Gambit-C 4.0 beta 17 with
Visual C++ Toolkit 2003 in Windows XP sp2. After that, I get it
compiled with gcc from Dev-C++ 4.9.9.2 and MinGW's Msys. And now the
file is in C:\msys\1.0\local\Gambit-C. OK, I set the Environment and
could use gsc directly in cmd.exe. I created a file t.scm, and then use
"gsc t.scm", it generates t.c and t_.c. The problem is that how I get
them compiled to t.exe via gcc of Dev-C++?

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)

Brad Lucier

unread,
Apr 12, 2006, 12:56:47 AM4/12/06
to

nobunaga86c...@yahoo.com.cn wrote:
> E:\Projects\SICP>gcc t.c t_.c

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

fee...@iro.umontreal.ca

unread,
Apr 12, 2006, 9:41:21 AM4/12/06
to
nobunaga86c...@yahoo.com.cn wrote:
> Hello! This afternoon I asked how to compile Gambit-C 4.0 beta 17 with
> Visual C++ Toolkit 2003 in Windows XP sp2. After that, I get it
> compiled with gcc from Dev-C++ 4.9.9.2 and MinGW's Msys. And now the
> file is in C:\msys\1.0\local\Gambit-C. OK, I set the Environment and
> could use gsc directly in cmd.exe. I created a file t.scm, and then use
> "gsc t.scm", it generates t.c and t_.c. The problem is that how I get
> them compiled to t.exe via gcc of Dev-C++?
>
> 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)'

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

0 new messages