Hello Darren,<br><br>Thank you for your advice. It makes good sense.<br><br>I now have a linker problem, and I have written some code to abstract the problem for your viewing.<br><br>The error message is:<br>&quot;Error in dyn.load(libLFile) : <br>
  unable to load shared object &#39;/tmp/RtmpBFr1mw/file44b636b6.so&#39;:<br>  /tmp/RtmpBFr1mw/file44b636b6.so: undefined symbol: _Z6sumvecSt6vectorIiSaIiEE&quot;<br><br>It seems safe to say that it cannot find the cpp file for LinkTest.h<br>
<br>The problem might be with how to use the&quot;includes&quot; argument for cxxfunction (see 1.b below).<br><br>It seems a common enough problem, but I have not been able to gain a clearer understanding by reading past comments on it, as most of these seem to pertain to packages. So I will post the relevant code here, and the full output from verbose=TRUE below it:<br>
<br>1. R Calling Function<br>linktest&lt;-cxxfunction( signature( vec = &quot;numeric&quot;, len = &quot;integer&quot; ), paste( readLines( &quot;/home/simon/College/PackageOne/src/BZip/LinkTestWrap.cpp&quot;),collapse = &quot;\n&quot; ) , plugin = &quot;Rcpp&quot;,verbose=TRUE )<br>
<br>1.b I also tried using user includes in the cxxfunction, and taking them out of the cpp file. But they don&#39;t seem to be parse properly in the created code, i.e.:<br>&quot;// user includes<br>  /home/simon/College/PackageOne/src/BZip/LinkTest.h&quot;<br>
 which the compiler naturally flags.<br><br><br>2. LinkTestWrap.cpp: Rcpp Wrapping Function (for use by inline)<br>#include &lt;Rcpp.h&gt;<br>#include &lt;vector&gt;<br>#include &quot;/home/simon/College/PackageOne/src/BZip/LinkTest.h&quot;<br>
    <br>    using std::vector;<br><br>    vector&lt;int&gt; input_vector( as&lt; vector&lt;int&gt; &gt;( vec ) );<br>    int length = as&lt;int&gt; ( len );<br><br>    int res = sumvec( input_vector );<br><br>    return Rcpp::wrap( res );<br>
<br>3. LinkTest.h<br>#include &lt;vector&gt;<br>int sumvec(std::vector&lt;int&gt; vec);<br><br>4.LinkTest.cpp<br>#include &quot;/home/simon/College/PackageOne/src/BZip/LinkTest.h&quot;<br><br>using std::vector;<br><br>int sumvec(vector&lt;int&gt; vec){<br>
    int total = 0;<br>    for( vector&lt;int&gt;::const_iterator it = vec.begin(); it != vec.end(); ++it ){<br>        total += *it;<br>    }<br>    return total;<br>}<br><br>Thanks again,<br><br>Simon<br><br><br><br>I thought the problem is with inline though. To take the link you gave:<br>
<a href="http://stackoverflow.com/questions/3221422/gcc-template-error" target="_blank">http://stackoverflow.com/questions/3221422/gcc-template-error</a><br>

One answer cites: &quot;The errors that you have posted suggest that the problem is within the function <code>void init_module_PyCML()</code>. It would therefore appear that you have tried to define a function template within the body of another function.&quot; I interpreted this to be due to inline because the problem with static member variables certainly seems to be because the class and other code is defined within a wrapper function by inline.<br>


<br><div class="gmail_quote">On Wed, Oct 12, 2011 at 12:24 AM, Darren Cook <span dir="ltr">&lt;<a href="mailto:darren@dcook.org" target="_blank">darren@dcook.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div>&gt; My apologies for not posting comprehensive code. My intention was only to<br>
&gt; lessen the reading burden for you.<br>
<br>
</div>Don&#39;t post comprehensive code :-)<br>
But if you can discover the smallest possible example that shows the<br>
problem, that will encourage lots of helpful responses.<br>
<div><br>
<br>
&gt; I am currently getting this error:<br>
&gt;<br>
&gt; /home/simon/College/PackageOne/src/BZip/BinaryTree.h: In function ‘SEXPREC*<br>
&gt; file354d98a8(SEXPREC*, SEXPREC*)’:<br>
&gt; /home/simon/College/PackageOne/src/BZip/BinaryTree.h:8:1: error: expected<br>
&gt; primary-expression before ‘template’<br>
&gt; /home/simon/College/PackageOne/src/BZip/BinaryTree.h:8:1: error: expected<br>
&gt; ‘;’ before ‘template’<br>
<br>
<br>
</div>This is saying that you&#39;ve not finished a statement before defining<br>
another one. E.g. see<br>
  <a href="http://stackoverflow.com/questions/3221422/gcc-template-error" target="_blank">http://stackoverflow.com/questions/3221422/gcc-template-error</a><br>
<br>
It could mean a missing semi-colon in the file being included before<br>
this one. If there are no statements or #include lines before line 8 in<br>
BinaryTree.h, look at the files that include BinaryTree.h.<br>
<div><br>
&gt;  I think I can see a quick solution, (not to use the template - I don&#39;&#39;t<br>
</div>&gt; need genericity here anyway,)...<br>
<br>
If that is true, then the Smallest Possible Example would be very<br>
interesting to the Rcpp developers, I&#39;m sure.<br>
<br>
Darren<br>
<font color="#888888"><br>
<br>
--<br>
Darren Cook, Software Researcher/Developer<br>
<br>
<a href="http://dcook.org/work/" target="_blank">http://dcook.org/work/</a> (About me and my work)<br>
<a href="http://dcook.org/blogs.html" target="_blank">http://dcook.org/blogs.html</a> (My blogs and articles)<br>
</font><div><div></div><div>_______________________________________________<br>
Rcpp-devel mailing list<br>
<a href="mailto:Rcpp-devel@lists.r-forge.r-project.org" target="_blank">Rcpp-devel@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a></div></div></blockquote></div><br>