Hello!
This is my first try to use the C interface of gambit-c. I used gambit-c 4.2.8 and mingw gcc compiler from CodeBlocks under Windows XP.
Running alt.exe, I get: Hello World! from C begin 137end
The lines printed from the C function appear before the lines printed by scheme. I have two questions:
1) Why the output lines do not appear in the call order ? 2) Is this the correct way to get small executables with gambit-c or it can be done in a better way ?
Thank you!
functii.c ---------- #include <string.h> #include <stdio.h>
int hello(char * s){ printf("%s",s); return strlen(s); }
test.scm ---------- (c-declare #<<c-declare-end extern int hello(char *s); c-declare-end )
(c-define-type MyInt int) (c-define-type MyString char-string)
(define myHello (c-lambda (MyString) MyInt "hello" ))
alt.scm --------- (display "begin") (newline) (display (myHello "Hello World!\n")) (display (myHello "from C\n")) (display "end") (newline)
compile.cmd ------------ @echo off set PATH=E:\limbaje\CodeBlocks\MinGW\bin;%PATH%
gsc -link -o leg.c test.scm
gcc -shared -mwin32 -m32 -march=pentium4 -IE:\limbaje\gambit-gcc\v4.2.8\include -IE:\limbaje\CodeBlocks\MinGW\include -LE:\limbaje\gambit-gcc\v4.2.8\lib -LE:\limbaje\CodeBlocks\MinGW\lib -o test.dll -Wl,--output-def,test.def -Wl,--kill-at -Wl,--out-implib,test.a -Wl,-s -D___SINGLE_HOST -D___LIBRARY -D___SHARED test.c leg.c functii.c -lgambc -lws2_32
gsc -link -l leg -o lleg.c alt.scm
gcc -mwin32 -m32 -march=pentium4 -IE:\limbaje\gambit-gcc\v4.2.8\include -IE:\limbaje\CodeBlocks\MinGW\include -LE:\limbaje\gambit-gcc\v4.2.8\lib -LE:\limbaje\CodeBlocks\MinGW\lib -D___SINGLE_HOST -D___SHARED -Wl,-s -Wl,--enable-auto-import alt.c lleg.c test.a -o alt.exe
set PATH=%PATH:E:\limbaje\CodeBlocks\MinGW\bin;=%
gcc -v ========
Reading specs from E:/limbaje/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/specs Configured with: ../gcc-3.4.5/configure --with-gcc --with-gnu-ld --with-gnu-as - -host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls -- enable-languages=c,c++,f77,ada,objc,java --disable-win32-registry --disable-shar ed --enable-sjlj-exceptions --enable-libgcj --disable-java-awt --without-x --ena ble-java-gc=boehm --disable-libgcj-debug --enable-interpreter --enable-hash-sync hronization --enable-libstdcxx-debug Thread model: win32 gcc version 3.4.5 (mingw-vista special)
________ Information from NOD32 ________ This message was checked by NOD32 Antivirus System for Linux Mail Servers. part000.txt - is OK http://www.eset.com