<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>Hi all, I'm trying to compile a simple program using macros but for some reason it won't work.</p>
<p>This is the code in test.scm</p>
<p><br>
</p>
<p></p>
<div>    (define-syntax while<br>
<span>    </span>  (syntax-rules ()<br>
<span>    </span>    ((while condition body ...)<br>
<span>    </span>     (let loop ()<br>
<span>    </span>       (if condition<br>
<span>    </span>           (begin<br>
<span>    </span>             body ...<br>
<span>    </span>             (loop))<br>
<span>    </span>           #f)))))<br>
<br>
<span>    </span>(define x 0)<br>
<span>    </span>(while (< x 5)<br>
<span>    </span>  (set! x (+ x 1))<br>
<span>    </span>  (print x))<br>
<br>
When I load the file into the interpreter (with the -:s option) it works, but when I try to compile it (using gambitc -:s -exe test.scm) I get the following error:<br>
<div>*** ERROR -- missing or invalid linking information for module "/usr/lib/gambit-c/_gambit"<br>
/usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../lib/crt1.o: In function `_start':<br>
(.text+0x20): undefined reference to `main'<br>
test.o: In function `___setup_mod':<br>
test.c:(.text+0xa): undefined reference to `___G__20_test'<br>
test.o: In function `___init_mod':<br>
test.c:(.text+0x26): undefined reference to `___G__20_test'<br>
test.o: In function `___H__20_test':<br>
test.c:(.text+0x113): undefined reference to `___G__24_sc_2d_put_2d_cte'<br>
test.c:(.text+0x181): undefined reference to `___G__24_sc_2d_put_2d_cte'<br>
test.c:(.text+0x1a2): undefined reference to `___G__24_sc_2d_put_2d_cte'<br>
test.c:(.text+0x1f3): undefined reference to `___G__24_sc_2d_put_2d_cte'<br>
test.c:(.text+0x214): undefined reference to `___G_x'<br>
test.c:(.text+0x24d): undefined reference to `___G_x'<br>
test.c:(.text+0x3a6): undefined reference to `___G_x'<br>
test.c:(.text+0x450): undefined reference to `___G_x'<br>
test.c:(.text+0x59b): undefined reference to `___G__24_syntax_2d_dispatch'<br>
test.c:(.text+0x60f): undefined reference to `___G__24_syntax_2d_dispatch'<br>
test.c:(.text+0x6a0): undefined reference to `___G_syntax_2d_error'<br>
test.c:(.text+0x6fa): undefined reference to `___G_syntax_2d_error'<br>
test.o: In function `____20_test':<br>
test.c:(.text+0xd38): undefined reference to `___S__2a_top_2a_'<br>
test.c:(.text+0xd46): undefined reference to `___S_any'<br>
test.c:(.text+0xd62): undefined reference to `___S_body'<br>
test.c:(.text+0xd70): undefined reference to `___S_condition'<br>
test.c:(.text+0xd8c): undefined reference to `___S_each_2d_any'<br>
test.c:(.text+0xd9a): undefined reference to `___S_global'<br>
test.c:(.text+0xdc4): undefined reference to `___S_loop'<br>
test.c:(.text+0xdd2): undefined reference to `___S_ribcage'<br>
test.c:(.text+0xdee): undefined reference to `___S_syntax_2d_object'<br>
test.c:(.text+0xe18): undefined reference to `___S_top_2d_ribcage'<br>
test.c:(.text+0xe34): undefined reference to `___S_x'<br>
collect2: error: ld returned 1 exit status</div>
<br>
I tried compiling with the interactive mode using <br>
    (compile-file-to-target "test.scm")<br>
    (quit)<br>
    gambitc -exe test.c<br>
and it compiles well, but when I try to run the exe I get:<br>
<div>    *** ERROR IN | test| -- Operator is not a PROCEDURE<br>
<span>    </span>(#!unbound<br>
<span>    </span> '#(syntax-object while ((top) #(ribcage #(while) #((top)) #(while))))<br>
<span>    </span> '#<procedure #2><br>
<span>    </span> '*top*)<br>
<br>
No matter how hard I try I can't compile any code that makes use of macros. Any help appreciated!<br>
</div>
<span>(I'm using Arch Linux and I installed gambit from Arch's repositroy, everything else apart from macros works well</span>)<br>
</div>
<p></p>
</div>
</body>
</html>