[Rcpp-devel] Question about using Rcpp to integrate C++ code with Boost Graph Library

Yan Zhou zhouyan at me.com
Mon Jan 21 08:16:35 CET 2013


>From your original message you said the error message is the compiler does not recognize the headers. Have you tried to also add the -I flag?

Yan 

On Jan 21, 2013, at 7:05 AM, Kevin Ushey <kevinushey at gmail.com> wrote:

> Hi Won-min,
> 
> 1) There shouldn't be a space between -L and the directory containing your boost libraries. Also, ensure that the libboost_graph.a file is available in that directory as well -- is there a chance that you have 'libboost_graph-mt.a', the multi-threaded flavor, instead?
> 
> 2) You don't want to wrap the whole expression in parentheses. The Rcpp library location is found by calling Rscript and checking Rcpp:::LdFlags() through a shell on Windows.
> 
> It's better to have the directory containing your boost libraries somewhere in your PATH, so that you simply need to put '-lboost_graph' in the PKG_LIBS variable. So, try:
> 
> PKG_LIBS = $(shell ${R_HOME}/bin/Rscript.exe -e "Rcpp:::LdFlags()") -L"C:/Users/Won/Documents/Boost/boost_1_51/lib" -lboost_graph
> 
> or, perhaps better,
> 
> PKG_LIBS = $(shell ${R_HOME}/bin/Rscript.exe -e "Rcpp:::LdFlags()") -lboost_graph
> 
> with the library found somewhere in your PATH.
> 
> -Kevin
> 
> On Sun, Jan 20, 2013 at 8:31 PM, Song, Won-min <won-min.song at mssm.edu> wrote:
>> Hi Dirk,
>> 
>> Thanks alot for your reply. Nevertheless, it doesn't seem I don't have `Rcmd COMPILE' running in my R.
>> I do have other functions such as Rcmd INSTALL, build etc, but couldn't find 'COMPILE' from the Rcmd options in the help display.
>> 
>> After you pointed out that I should have used -L/-I options in PKG_LIBS, I tried the following in Makevars.win file:
>> 
>> PKG_LIBS = $(shell ${R_HOME}/bin/Rscript.exe -e "Rcpp:::LdFlags()" -L "C:/Users/Won/Documents/Boost/boost_1_51/lib" -lboost_graph)
>> 
>> and it still doesn't recognize boost library.
>> 
>> As I am rather a beginner in R, it is likely that there is something missing. Could you or anyone direct me to right direction?
>> 
>> Thanks,
>> 
>> Won
>> ________________________________________
>> From: Dirk Eddelbuettel [edd at debian.org]
>> Sent: Saturday, January 19, 2013 9:29 AM
>> To: Song, Won-min
>> Cc: rcpp-devel at lists.r-forge.r-project.org
>> Subject: Re: [Rcpp-devel] Question about using Rcpp to integrate C++ code with Boost Graph Library
>> 
>> Hi,
>> 
>> On 19 January 2013 at 08:14, Song, Won-min wrote:
>> |
>> | Hi,
>> | I am a new beginner in using Rcpp with C++.
>> | I have a piece of C++ code with Rcpp and boost graph library, and am trying to
>> | make a package with helps from Rcpp.package.skeleton() command.
>> |
>> | When I try to install the package with Rcmd INSTALL pkgname (I'm running on
>> | windows machine), it seems that it is not recognizing the boost library by
>> | displaying error messages that it is not recognizing the header files from
>> | boost. I used the following Makevars.win file in the src directory:
>> |
>> | PKG_LIBS = $(shell ${R_HOME}/bin/Rscript.exe -e "Rcpp:::LdFlags()")
>> | PKG_CPPFLAGS = -L "C:/Users/Won/Documents/Boost/boost_1_51/lib" -lboost_graph
>> |
>> | C:/Users/Won/Documents/Boost/boost_1_51/lib is the directory where the .dll
>> | files live.
>> | Would you be able to point me in the right direction? Is there something I've
>> | done wrong in Makevars.win file?
>> 
>> You added the _linker_ arguments to the _header_ flag. That is wrong: -L/-l
>> belong to PKG_LIBS.
>> 
>> Try in the src/ directory to decompose the steps into
>> 
>>     R CMD COMPILE mylib.dll *.cpp
>> 
>> and
>> 
>>     R CMD SHLIB mylib.dll
>> 
>> (or some other name for mylib) to see that you can a) compile (does g++ find
>> headers) and b) link (does g++ find the dll).
>> 
>> Dirk
>> 
>> |
>> | Any comments would be greatly appreciated.
>> |
>> | Thanks,
>> |
>> | ----------------------------------------------------------------------
>> | _______________________________________________
>> | Rcpp-devel mailing list
>> | Rcpp-devel at lists.r-forge.r-project.org
>> | https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>> --
>> Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
>> _______________________________________________
>> Rcpp-devel mailing list
>> Rcpp-devel at lists.r-forge.r-project.org
>> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
> 
> 
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20130121/61267e38/attachment.html>


More information about the Rcpp-devel mailing list