Thanks for your explanation. callbackFunction will be prefect in my case.<br>Just wondering can I pass an R function like below to a c++ function in a separate cpp file (e.g., in src folder of my package)?  <br><br>funx <- cfunction(signature(N = "integer" , xvec = "numeric",<b> fun = "function"</b> ),<br>

                  cpp, , Rcpp = TRUE, include = "using namespace Rcpp; ")<br><br><br>thanks<br><br>-- Ariful<br><br><div class="gmail_quote">On Wed, Mar 21, 2012 at 9:00 PM, Dirk Eddelbuettel <span dir="ltr"><<a href="mailto:edd@debian.org">edd@debian.org</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="im"><br>
On 21 March 2012 at 20:46, Ariful Azad wrote:<br>
| Hi,<br>
|<br>
| I created a package using Rcpp (using Rcpp.package.skeleton()).<br>
| Now I need to access a piece of R code from the cpp code in the package.<br>
| I am trying to use RInside.<br>
<br>
</div>Then you do /not/ start with the package skeleton generator, which is for<br>
use with _packages loaded into R_.<br>
<br>
RInside extends standalone C++ program with their own main() function.<br>
<br>
<br>
If what you want is to call back into R from a loadable package, do not look<br>
at RInside but rather look at the examples/ directory of Rcpp, particularly<br>
callbackFunctions/ which has a working example.<br>
<div class="im"><br>
| I am using Mac 64 bit machine.<br>
<br>
</div>I can't speak to that, but folks have used Rcpp and RInside merrily on OS X<br>
in both 32 and 64 bit.<br>
<br>
Then again, maybe you don;t even want RInside.<br>
<div class="im"><br>
| When I installed RInside I found the shared libraries in two places<br>
| 1. /Library/Frameworks/R.<br>
| framework/Versions/2.14/Resources/library/RInside/lib<br>
| and  in<br>
| 2. /Library/Frameworks/R.framework/Versions/2.14/Resources/library/RInside/libs<br>
|<br>
| in the first directory I have one subfolder named i386 that contains two files<br>
| libRInside.a        libRInside.dylib<br>
|<br>
| but in the second directory I have three subfolders namely ,<br>
| a) i386 with files libRInside.a        libRInside.dylib<br>
| b) x86_64 with files RInside.so    RInside.so.dSYM<br>
| c)ppc with files RInside.so    RInside.so.dSYM<br>
|<br>
|<br>
| In my DESCRIPTION file I addedd<br>
|  LinkingTo: Rcpp, RInside<br>
<br>
</div>No, that is not how it used. You misunderstand.<br>
<br>
Look at the Rcpp examples.<br>
<br>
Dirk<br>
<div class="im"><br>
| In my MakeVars I added<br>
| PKG_LIBS = `$(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()"` `$(R_HOME)/bin/Rscript<br>
| -e "RInside:::LdFlags()"`<br>
|<br>
| Now when I install the package using R CMD install , it installs both 32 bit<br>
| and 64 bit version.<br>
| However, I am getting error for the 64 bit version , probably because<br>
| RInside.so is not for mac ? (Please see below the outputs).<br>
|<br>
| By the way how can I modify architecture specific compile option in Makevars<br>
| file for (for example I want to pass different libraries to different versions<br>
| directed fro 32 or 64 bit architectures ) ?<br>
<br>
</div>Normall R takes care of that.<br>
<div><div></div><div class="h5">|<br>
| Output from R CMD install pkg<br>
| ----------------------------<br>
|<br>
| * installing to library ‘/Library/Frameworks/R.framework/Versions/2.14/<br>
| Resources/library’<br>
| * installing *source* package ‘flowMatch’ ...<br>
| ** libs<br>
| *** arch - i386<br>
| g++ -arch i386 -I/Library/Frameworks/R.framework/Resources/include -I/Library/<br>
| Frameworks/R.framework/Resources/include/i386  -I/usr/local/include -I"/<br>
| Library/Frameworks/R.framework/Versions/2.14/Resources/library/Rcpp/include"<br>
| -I"/Library/Frameworks/R.framework/Versions/2.14/Resources/library/RInside/<br>
| include"   -fPIC  -g -O2 -c BipartiteGraph.cpp -o BipartiteGraph.o<br>
| BipartiteGraph.cpp:28: warning: division by zero in ‘1.0e+0 / 0.’<br>
| g++ -arch i386 -I/Library/Frameworks/R.framework/Resources/include -I/Library/<br>
| Frameworks/R.framework/Resources/include/i386  -I/usr/local/include -I"/<br>
| Library/Frameworks/R.framework/Versions/2.14/Resources/library/Rcpp/include"<br>
| -I"/Library/Frameworks/R.framework/Versions/2.14/Resources/library/RInside/<br>
| include"   -fPIC  -g -O2 -c MinWghtEdgCoverBipartite.cpp -o<br>
| MinWghtEdgCoverBipartite.o<br>
| g++ -arch i386 -I/Library/Frameworks/R.framework/Resources/include -I/Library/<br>
| Frameworks/R.framework/Resources/include/i386  -I/usr/local/include -I"/<br>
| Library/Frameworks/R.framework/Versions/2.14/Resources/library/Rcpp/include"<br>
| -I"/Library/Frameworks/R.framework/Versions/2.14/Resources/library/RInside/<br>
| include"   -fPIC  -g -O2 -c rcpp_hello_world.cpp -o rcpp_hello_world.o<br>
| g++ -arch i386 -dynamiclib -Wl,-headerpad_max_install_names -undefined<br>
| dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -o<br>
| flowMatch.so BipartiteGraph.o MinWghtEdgCoverBipartite.o rcpp_hello_world.o /<br>
| Library/Frameworks/R.framework/Versions/2.14/Resources/library/Rcpp/lib/i386/<br>
| libRcpp.a /Library/Frameworks/R.framework/Versions/2.14/Resources/library/<br>
| RInside/lib/i386/libRInside.a -F/Library/Frameworks/R.framework/.. -framework R<br>
| -Wl,-framework -Wl,CoreFoundation<br>
| installing to /Library/Frameworks/R.framework/Versions/2.14/Resources/library/<br>
| flowMatch/libs/i386<br>
| *** arch - x86_64<br>
| g++ -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -I/Library<br>
| /Frameworks/R.framework/Resources/include/x86_64  -I/usr/local/include -I"/<br>
| Library/Frameworks/R.framework/Versions/2.14/Resources/library/Rcpp/include"<br>
| -I"/Library/Frameworks/R.framework/Versions/2.14/Resources/library/RInside/<br>
| include"   -fPIC  -g -O2 -c BipartiteGraph.cpp -o BipartiteGraph.o<br>
| BipartiteGraph.cpp:28: warning: division by zero in ‘1.0e+0 / 0.’<br>
| g++ -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -I/Library<br>
| /Frameworks/R.framework/Resources/include/x86_64  -I/usr/local/include -I"/<br>
| Library/Frameworks/R.framework/Versions/2.14/Resources/library/Rcpp/include"<br>
| -I"/Library/Frameworks/R.framework/Versions/2.14/Resources/library/RInside/<br>
| include"   -fPIC  -g -O2 -c MinWghtEdgCoverBipartite.cpp -o<br>
| MinWghtEdgCoverBipartite.o<br>
| g++ -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -I/Library<br>
| /Frameworks/R.framework/Resources/include/x86_64  -I/usr/local/include -I"/<br>
| Library/Frameworks/R.framework/Versions/2.14/Resources/library/Rcpp/include"<br>
| -I"/Library/Frameworks/R.framework/Versions/2.14/Resources/library/RInside/<br>
| include"   -fPIC  -g -O2 -c rcpp_hello_world.cpp -o rcpp_hello_world.o<br>
| g++ -arch x86_64 -dynamiclib -Wl,-headerpad_max_install_names -undefined<br>
| dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -o<br>
| flowMatch.so BipartiteGraph.o MinWghtEdgCoverBipartite.o rcpp_hello_world.o /<br>
| Library/Frameworks/R.framework/Versions/2.14/Resources/library/Rcpp/lib/x86_64/<br>
| libRcpp.a /libRInside.a -F/Library/Frameworks/R.framework/.. -framework R<br>
| -Wl,-framework -Wl,CoreFoundation<br>
| i686-apple-darwin11-llvm-g++-4.2: /libRInside.a: No such file or directory<br>
| make: *** [flowMatch.so] Error 1<br>
| ERROR: compilation failed for package ‘flowMatch’<br>
|<br>
|<br>
| -------------<br>
|<br>
|<br>
| thanks<br>
|<br>
| -- Ariful<br>
|<br>
</div></div>| ----------------------------------------------------------------------<br>
| _______________________________________________<br>
| Rcpp-devel mailing list<br>
| <a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">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><br>
<font color="#888888">--<br>
"Outside of a dog, a book is a man's best friend. Inside of a dog, it is too<br>
dark to read." -- Groucho Marx<br>
</font></blockquote></div><br>