<div dir="ltr">Thanks for your input everyone.  I got it working in a bare bones project.  I am still having the original problem in my actual program which is using s7 as an extension language in the Cocos2d-x game engine, but now I am sure the problem lies with Cocos2d-x.  It was ported from objective C to C++, so a lot of the pointer stuff is odd.<div><br></div><div>Here is the working sample C++ project in case it is of use to anyone:</div><div><br></div><div><div>//Scheme.h</div><div>#ifndef __SCHEME_H__</div><div>#define __SCHEME_H__</div><div><br></div><div>#include &quot;s7.h&quot;</div><div>#include &quot;stdlib.h&quot;</div><div><br></div><div>extern &quot;C&quot; {</div><div><br></div><div>class Scheme</div><div>{</div><div>public:</div><div>        static s7_pointer plus(s7_scheme *sc, s7_pointer args);</div><div>        Scheme();</div><div>        ~Scheme();</div><div>        int addFFItoScheme();</div><div>        int testFFI();</div><div>private:</div><div>        static s7_scheme* s7;</div><div>};</div><div>}</div><div>#endif</div></div><div><br></div><div><div>//Scheme.cpp</div><div>#include &quot;s7.h&quot;</div><div>#include &quot;Scheme.h&quot;</div><div>#include &lt;stdlib.h&gt;</div><div>#include &lt;iostream&gt;</div><div><br></div><div>s7_scheme*  Scheme::s7;</div><div>s7_pointer Scheme::plus(s7_scheme *sc, s7_pointer args)</div><div>{</div><div>        /* (define* (plus (red 32) blue) (+ (* 2 red) blue)) */</div><div>        return(s7_make_integer(sc, 2 * s7_integer(s7_car(args)) + s7_integer(s7_car(s7_cdr(args)))));</div><div>}</div><div><br></div><div>Scheme::Scheme() {</div><div>        s7 = s7_init();</div><div>        std::cout &lt;&lt; &quot;Scheme init\n&quot;;</div><div>}</div><div><br></div><div>Scheme::~Scheme() {</div><div>        free(s7);</div><div>        std::cout &lt;&lt; &quot;Bye!\n&quot;;</div><div>}</div><div><br></div><div>int Scheme::addFFItoScheme()</div><div>{</div><div>        std::cout &lt;&lt; &quot;addFFItoScheme\n&quot;;</div><div>        s7_define_function_star(s7, &quot;plus&quot;, Scheme::plus, &quot;(red 32) blue&quot;, &quot;an example of define* from C&quot;);</div><div>        return 0;</div><div>}</div><div><br></div><div>int Scheme::testFFI()</div><div>{</div><div>        std::cout &lt;&lt; &quot;testFFI\n&quot;;</div><div>        auto val = s7_eval_c_string(s7, &quot;(+ 2 3)&quot;); // should be 5</div><div>        std::cout &lt;&lt; &quot;5 = &quot; &lt;&lt; s7_object_to_c_string(s7, val) &lt;&lt; std::endl;</div><div>        val = s7_eval_c_string(s7, &quot;(plus 2 3)&quot;); // should be 7</div><div>        std::cout &lt;&lt; &quot;7 = &quot; &lt;&lt; s7_object_to_c_string(s7, val) &lt;&lt; std::endl;</div><div>        return 0;</div><div>}</div></div><div><br></div><div><div>//main.cpp</div><div>#include &quot;s7.h&quot;</div><div>#include &quot;Scheme.h&quot;</div><div>#include &quot;Scheme.cpp&quot;</div><div><br></div><div>int main(int argc, char **argv)</div><div>{</div><div>        std::cout &lt;&lt; &quot;Main&quot; &lt;&lt; std::endl;</div><div>        Scheme* scheme = new Scheme();</div><div>        scheme-&gt;addFFItoScheme();</div><div>        scheme-&gt;testFFI();</div><div><br></div><div>}</div><div><br></div><div>//to build:</div><div>//g++ -c s7.c -I. -g</div><div>//g++ -c Scheme.cpp -I. -g -std=c++0x &amp;&amp; g++ main.cpp -o ffi s7.o -I. -lm -ldl -std=c++0x &amp;&amp; ./ffi</div></div><div><br></div><div>and output is as expected:</div><div><div>Main</div><div>Scheme init</div><div>addFFItoScheme</div><div>testFFI</div><div>5 = 5</div><div>7 = 7</div></div><div><br></div><div>Thanks again for your help,</div><div>Jason</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 12, 2015 at 10:39 AM, Ralf Mattes <span dir="ltr">&lt;<a href="mailto:rm@seid-online.de" target="_blank">rm@seid-online.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Thu, Feb 12, 2015 at 10:42:31AM -0500, Jason Ripley wrote:<br>
<br>
</span><span class="">&gt; should.  However, I cannot seem to find the correct invocation in C++ to<br>
&gt; make it work.  I was wondering if it needs something like extern &quot;C&quot;, which<br>
&gt; I tried to no avail.<br>
<br>
</span>Yes, when compiling with a C++ compiler you need to declare your calls into<br>
C as &quot;extern C&quot; otherwise you&#39;ll be the victim of name mangling.<br>
<br>
 Cheers, RalfD<br>
<br>
<br>
Yes, when compiling with a C++ compiler you need to declare your calls into<br>
C as &quot;extern C&quot; otherwise you&#39;ll be the victim of name mangling.<br>
<br>
 Cheers, RalfD<br>
<br>
</blockquote></div><br></div>