<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Figured it out due to this old message:<br><br>https://webmail.iro.umontreal.ca/pipermail/gambit-list/2004-October/000014.html<br><br>-John<br><br>--- On <b>Tue, 2/24/09, John Thompson <i><bargarply@yahoo.com></i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;">From: John Thompson <bargarply@yahoo.com><br>Subject: Re: [gambit-list] Difficulties linking against a C++ library<br>To: "Marc Feeley" <feeley@iro.umontreal.ca><br>Cc: gambit-list@iro.umontreal.ca<br>Date: Tuesday, February 24, 2009, 11:55 PM<br><br><div id="yiv662595030"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; font-size-adjust: inherit; font-stretch: inherit;
 -x-system-font: none;" valign="top">Hi Marc,<br>
<br>
Thanks for the response.  The include did indeed solve my compilation problems. <br><br>Now I'm compiling like this:<br><br>gsc -link -flat foo.scm<br>g++ -Wno-write-strings -fPIC -c -D___DYNAMIC foo_.c foo.c<br>g++ -Wno-write-strings -fPIC -c -D___DYNAMIC foo.cpp -o cppfoo.o<br>ld -G -o foo.o1 cppfoo.o foo.o foo_.o<br><br>This leads to a run-time linking error of:<br><br>*** WARNING -- Could not find C function: "____20_foo_2e_o1"<br>*** ERROR IN ##main -- .../foo.o1: undefined symbol: ____20_foo_2e_o1<br>(load "foo.o1")<br><br>Any idea what the issue is here?<br><br>-John<br><br><br>--- On <b>Tue, 2/24/09, Marc Feeley <i><feeley@iro.umontreal.ca></i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;">From: Marc Feeley <feeley@iro.umontreal.ca><br>Subject: Re: [gambit-list] Difficulties linking against a C++ library<br>To: bargarply@yahoo.com<br>Cc:
 gambit-list@iro.umontreal.ca<br>Date: Tuesday, February 24, 2009, 2:22 PM<br><br><pre>On 24-Feb-09, at 8:41 AM, John Thompson wrote:<br><br>> Hi,<br>> <br>> I'm trying to get a toy, loadable C++ library compiled.  My setup is<br>as follows:<br>> <br>> foo.scm:<br>> <br>>  (define bar (c-lambda (char-string) int "cpp_bar"))<br>> <br>> foo.cpp:<br>> <br>> int cpp_bar(char* text) {<br>>   return 0;<br>> }<br>> <br>> foo.h:<br>> <br>> int cpp_bar(char* text);<br><br>In C++, prototypes are not optional (and if it works in C it is by accident). <br>In the C++ code generated for foo.scm the C++ compiler has no idea what is the<br>prototype of cpp_bar that you want to call.  You might think that the c-lambda<br>types are there to supply that information, but in fact the Gambit compiler<br>simply generates a call to cpp_bar whose *actual* parameters are those of the<br>c-lambda.  By not automatically
 generating<br> a prototype for cpp_bar it allows for<br>cpp_bar to be a macro or a qualified name such as "cpp::bar" or inline<br>code such as "___result = ___arg1[0];".  So to solve your problem<br>foo.scm should be<br><br>(c-declare #<<end-of-c-declare<br>#include "foo.h"<br>end-of-c-declare<br>)<br><br>(define bar (c-lambda (char-string) int "cpp_bar"))<br><br>Note that you'd have to include foo.h if this was a C++ module, for exactly<br>the same reasons, so it shouldn't be too surprising.<br><br>Marc<br><br></pre></blockquote></td></tr></tbody></table><br>



      </div><pre>_______________________________________________<br>Gambit-list mailing list<br>Gambit-list@iro.umontreal.ca<br>https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list<br></pre></blockquote></td></tr></table><br>