[Rcpp-devel] Rcpp upgrading legacy code linking error
Dirk Eddelbuettel
edd at debian.org
Tue Mar 15 12:30:17 CET 2011
On 14 March 2011 at 15:49, Dahir Alihassan wrote:
| Hi Dirk,
|
| Thanks for your continued help and patience, and for the heads up with the
| R CMD INSTALL. I am not an R User and so my approach to this may be a bit
| painful! Following your advice, I attempted R CMD INSTALL on latest
| downloaded RCPP and RCPPClassic packages as follows:
|
| C:\Applications\Rtools>R CMD INSTALL RcppClassic_0.9.0.tar.gz
|
| * installing to library 'C:/PROGRA~1/R/R-212~1.1/library'
| ERROR: dependency 'Rcpp' is not available for package 'RcppClassic'
| * removing 'C:/PROGRA~1/R/R-212~1.1/library/RcppClassic'
|
| C:\Applications\Rtools>R CMD INSTALL Rcpp_0.9.1.tar.gz
|
| * installing to library 'C:/PROGRA~1/R/R-212~1.1/library'
| * installing *source* package 'Rcpp' ...
| ** libs
|
| *** arch - i386
|
| *** arch - x64
| ERROR: compilation failed for package 'Rcpp'
Hm I fear this demonstrates that your system is not set up right. If I ask
for a Windows build of, say, RcppClassic, I get this from win-builder:
-----------------------------------------------------------------------------
* installing *source* package 'RcppClassic' ...
** libs
*** arch - i386
g++ -I"D:/RCompile/recent/R-2.12.2/include" -I../inst/include/ -I"d:/Rcompile/CRANpkg/lib/2.12/Rcpp/include" -I"d:/Rcompile/CRANpkg/extralibs/local/include" -O2 -Wall -c RcppDate.cpp -o RcppDate.o
g++ -I"D:/RCompile/recent/R-2.12.2/include" -I../inst/include/ -I"d:/Rcompile/CRANpkg/lib/2.12/Rcpp/include" -I"d:/Rcompile/CRANpkg/extralibs/local/include" -O2 -Wall -c RcppDateVector.cpp -o RcppDateVector.o
g++ -I"D:/RCompile/recent/R-2.12.2/include" -I../inst/include/ -I"d:/Rcompile/CRANpkg/lib/2.12/Rcpp/include" -I"d:/Rcompile/CRANpkg/extralibs/local/include" -O2 -Wall -c RcppDatetime.cpp -o RcppDatetime.o
g++ -I"D:/RCompile/recent/R-2.12.2/include" -I../inst/include/ -I"d:/Rcompile/CRANpkg/lib/2.12/Rcpp/include" -I"d:/Rcompile/CRANpkg/extralibs/local/include" -O2 -Wall -c RcppDatetimeVector.cpp -o RcppDatetimeVector.o
g++ -I"D:/RCompile/recent/R-2.12.2/include" -I../inst/include/ -I"d:/Rcompile/CRANpkg/lib/2.12/Rcpp/include" -I"d:/Rcompile/CRANpkg/extralibs/local/include" -O2 -Wall -c RcppFrame.cpp -o RcppFrame.o
g++ -I"D:/RCompile/recent/R-2.12.2/include" -I../inst/include/ -I"d:/Rcompile/CRANpkg/lib/2.12/Rcpp/include" -I"d:/Rcompile/CRANpkg/extralibs/local/include" -O2 -Wall -c RcppFunction.cpp -o RcppFunction.o
g++ -I"D:/RCompile/recent/R-2.12.2/include" -I../inst/include/ -I"d:/Rcompile/CRANpkg/lib/2.12/Rcpp/include" -I"d:/Rcompile/CRANpkg/extralibs/local/include" -O2 -Wall -c RcppList.cpp -o RcppList.o
g++ -I"D:/RCompile/recent/R-2.12.2/include" -I../inst/include/ -I"d:/Rcompile/CRANpkg/lib/2.12/Rcpp/include" -I"d:/Rcompile/CRANpkg/extralibs/local/include" -O2 -Wall -c RcppNumList.cpp -o RcppNumList.o
g++ -I"D:/RCompile/recent/R-2.12.2/include" -I../inst/include/ -I"d:/Rcompile/CRANpkg/lib/2.12/Rcpp/include" -I"d:/Rcompile/CRANpkg/extralibs/local/include" -O2 -Wall -c RcppParams.cpp -o RcppParams.o
g++ -I"D:/RCompile/recent/R-2.12.2/include" -I../inst/include/ -I"d:/Rcompile/CRANpkg/lib/2.12/Rcpp/include" -I"d:/Rcompile/CRANpkg/extralibs/local/include" -O2 -Wall -c RcppResultSet.cpp -o RcppResultSet.o
g++ -I"D:/RCompile/recent/R-2.12.2/include" -I../inst/include/ -I"d:/Rcompile/CRANpkg/lib/2.12/Rcpp/include" -I"d:/Rcompile/CRANpkg/extralibs/local/include" -O2 -Wall -c RcppStringVector.cpp -o RcppStringVector.o
g++ -I"D:/RCompile/recent/R-2.12.2/include" -I../inst/include/ -I"d:/Rcompile/CRANpkg/lib/2.12/Rcpp/include" -I"d:/Rcompile/CRANpkg/extralibs/local/include" -O2 -Wall -c RcppStringVectorView.cpp -o RcppStringVectorView.o
g++ -I"D:/RCompile/recent/R-2.12.2/include" -I../inst/include/ -I"d:/Rcompile/CRANpkg/lib/2.12/Rcpp/include" -I"d:/Rcompile/CRANpkg/extralibs/local/include" -O2 -Wall -c copyMessageToR.cpp -o copyMessageToR.o
ar crs libRcppClassic.a RcppDate.o RcppDateVector.o RcppDatetime.o RcppDatetimeVector.o RcppFrame.o RcppFunction.o RcppList.o RcppNumList.o RcppParams.o RcppResultSet.o RcppStringVector.o RcppStringVectorView.o copyMessageToR.o
mkdir -p ../inst/lib/i386
mv libRcppClassic.a ../inst/lib/i386/libRcppClassic.a
g++ -shared -s -static-libgcc -o RcppClassic.dll tmp.def RcppDate.o RcppDateVector.o RcppDatetime.o RcppDatetimeVector.o RcppFrame.o RcppFunction.o RcppList.o RcppNumList.o RcppParams.o RcppResultSet.o RcppStringVector.o RcppStringVectorView.o copyMessageToR.o -Ld:/Rcompile/CRANpkg/extralibs/local/lib d:/Rcompile/CRANpkg/lib/2.12/Rcpp/lib/i386/libRcpp.a -LD:/RCompile/recent/R-2.12.2/bin/i386 -lR
installing to d:/RCompile/CRANguest/R-release/lib/RcppClassic/libs/i386
*** arch - x64
x86_64-w64-mingw32-g++ -I"D:/RCompile/recent/R-2.12.2/include" -I../inst/include/ -I"d:/Rcompile/CRANpkg/lib/2.12/Rcpp/include" -I"d:/Rcompile/CRANpkg/extralibs64new/local/include" -O2 -Wall -c RcppDate.cpp -o RcppDate.o
x86_64-w64-mingw32-g++ -I"D:/RCompile/recent/R-2.12.2/include" -I../inst/include/ -I"d:/Rcompile/CRANpkg/lib/2.12/Rcpp/include" -I"d:/Rcompile/CRANpkg/extralibs64new/local/include" -O2 -Wall -c RcppDateVector.cpp -o RcppDateVector.o
x86_64-w64-mingw32-g++ -I"D:/RCompile/recent/R-2.12.2/include" -I../inst/include/ -I"d:/Rcompile/CRANpkg/lib/2.12/Rcpp/include" -I"d:/Rcompile/CRANpkg/extralibs64new/local/include" -O2 -Wall -c RcppDatetime.cpp -o RcppDatetime.o
x86_64-w64-mingw32-g++ -I"D:/RCompile/recent/R-2.12.2/include" -I../inst/include/ -I"d:/Rcompile/CRANpkg/lib/2.12/Rcpp/include" -I"d:/Rcompile/CRANpkg/extralibs64new/local/include" -O2 -Wall -c RcppDatetimeVector.cpp -o RcppDatetimeVector.o
x86_64-w64-mingw32-g++ -I"D:/RCompile/recent/R-2.12.2/include" -I../inst/include/ -I"d:/Rcompile/CRANpkg/lib/2.12/Rcpp/include" -I"d:/Rcompile/CRANpkg/extralibs64new/local/include" -O2 -Wall -c RcppFrame.cpp -o RcppFrame.o
x86_64-w64-mingw32-g++ -I"D:/RCompile/recent/R-2.12.2/include" -I../inst/include/ -I"d:/Rcompile/CRANpkg/lib/2.12/Rcpp/include" -I"d:/Rcompile/CRANpkg/extralibs64new/local/include" -O2 -Wall -c RcppFunction.cpp -o RcppFunction.o
x86_64-w64-mingw32-g++ -I"D:/RCompile/recent/R-2.12.2/include" -I../inst/include/ -I"d:/Rcompile/CRANpkg/lib/2.12/Rcpp/include" -I"d:/Rcompile/CRANpkg/extralibs64new/local/include" -O2 -Wall -c RcppList.cpp -o RcppList.o
x86_64-w64-mingw32-g++ -I"D:/RCompile/recent/R-2.12.2/include" -I../inst/include/ -I"d:/Rcompile/CRANpkg/lib/2.12/Rcpp/include" -I"d:/Rcompile/CRANpkg/extralibs64new/local/include" -O2 -Wall -c RcppNumList.cpp -o RcppNumList.o
x86_64-w64-mingw32-g++ -I"D:/RCompile/recent/R-2.12.2/include" -I../inst/include/ -I"d:/Rcompile/CRANpkg/lib/2.12/Rcpp/include" -I"d:/Rcompile/CRANpkg/extralibs64new/local/include" -O2 -Wall -c RcppParams.cpp -o RcppParams.o
x86_64-w64-mingw32-g++ -I"D:/RCompile/recent/R-2.12.2/include" -I../inst/include/ -I"d:/Rcompile/CRANpkg/lib/2.12/Rcpp/include" -I"d:/Rcompile/CRANpkg/extralibs64new/local/include" -O2 -Wall -c RcppResultSet.cpp -o RcppResultSet.o
x86_64-w64-mingw32-g++ -I"D:/RCompile/recent/R-2.12.2/include" -I../inst/include/ -I"d:/Rcompile/CRANpkg/lib/2.12/Rcpp/include" -I"d:/Rcompile/CRANpkg/extralibs64new/local/include" -O2 -Wall -c RcppStringVector.cpp -o RcppStringVector.o
x86_64-w64-mingw32-g++ -I"D:/RCompile/recent/R-2.12.2/include" -I../inst/include/ -I"d:/Rcompile/CRANpkg/lib/2.12/Rcpp/include" -I"d:/Rcompile/CRANpkg/extralibs64new/local/include" -O2 -Wall -c RcppStringVectorView.cpp -o RcppStringVectorView.o
x86_64-w64-mingw32-g++ -I"D:/RCompile/recent/R-2.12.2/include" -I../inst/include/ -I"d:/Rcompile/CRANpkg/lib/2.12/Rcpp/include" -I"d:/Rcompile/CRANpkg/extralibs64new/local/include" -O2 -Wall -c copyMessageToR.cpp -o copyMessageToR.o
x86_64-w64-mingw32-ar crs libRcppClassic.a RcppDate.o RcppDateVector.o RcppDatetime.o RcppDatetimeVector.o RcppFrame.o RcppFunction.o RcppList.o RcppNumList.o RcppParams.o RcppResultSet.o RcppStringVector.o RcppStringVectorView.o copyMessageToR.o
mkdir -p ../inst/lib/x64
mv libRcppClassic.a ../inst/lib/x64/libRcppClassic.a
x86_64-w64-mingw32-g++ -shared -s -static-libgcc -o RcppClassic.dll tmp.def RcppDate.o RcppDateVector.o RcppDatetime.o RcppDatetimeVector.o RcppFrame.o RcppFunction.o RcppList.o RcppNumList.o RcppParams.o RcppResultSet.o RcppStringVector.o RcppStringVectorView.o copyMessageToR.o -Ld:/Rcompile/CRANpkg/extralibs64new/local/lib d:/Rcompile/CRANpkg/lib/2.12/Rcpp/lib/x64/libRcpp.a -LD:/RCompile/recent/R-2.12.2/bin/x64 -lR
installing to d:/RCompile/CRANguest/R-release/lib/RcppClassic/libs/x64
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices ...
** testing if installed package can be loaded
* MD5 sums
packaged installation of 'RcppClassic' as RcppClassic_0.9.0.zip
* DONE (RcppClassic)
-----------------------------------------------------------------------------
Do you get similar output for either i386 or x64? If not, you may to get
back to the documentation and read up on how to set up your tools. Maybe
start with the PATH settings...
| * removing 'C:/PROGRA~1/R/R-212~1.1/library/Rcpp'
|
| Alternatively from the unzipped folders:
|
| C:\Applications\Rtools\Rcpp_0.9.1.tar\Rcpp_0.9.1>RCMD INSTALL Rcpp
| * installing to library 'C:/PROGRA~1/R/R-212~1.1/library'
| * installing *source* package 'Rcpp' ...
| ** libs
|
| *** arch - i386
|
| *** arch - x64
| ERROR: compilation failed for package 'Rcpp'
| * removing 'C:/PROGRA~1/R/R-212~1.1/library/Rcpp'
|
| With regards to upgrading the legacy code, I decided to go for the easier
| option of RcppClassic initially. I followed the vignette and made the
| necessary changes to the Description, Makevars and Makevars.win files to
| add RcppClassic references. However, the build fails at the linking stage
| with "undefined references" errors to:
|
| .cpp:(.text+0x260): undefined reference to
| `RcppParams::RcppParams.cpp:(.text+0x30e):(SEXPREC*)
| .cpp:(.text+0x2a6): undefined reference to
| `RcppParams::getIntValue(std::string)'
| ... and over 50 other references.
|
| Clearly it is a linking issue. Any ideas much appreciated!
RcppClassis _depends on Rcpp_ as the DESCRIPTION file clearly shows, so you
also need to link to Rcpp's library.
Dirk
|
| Thanks,
| Dahir.
|
|
|
| On Mon, March 14, 2011 12:18, Dirk Eddelbuettel wrote:
| >
|
| > On 14 March 2011 at 10:29, Dahir Alihassan wrote:
| > | Hi Doug,
| > |
| > | For the benefit of everyone, I will update this with my findings so far.
| > | The "-lR" compile flag mentioned by Doug below links to "libR.so"
| > which is | a shared/dynamic library when you compile R from source. The
| > issue is that | I am on Windows and so I understrand the equivalent is
| > R.dll. However,
| > | this needs to be converted to a .lib /.a file so that it can be
| > statically | linked to. I'm surprised that this hasn't been documented and
| > I've seen
| > | quite a few people confused about this. Has anyone made any progress on
| > | this front or am I totally going down the wrong road? Thanks.
| >
| >
| > I fear it is the latter. You simply seem to miss the fact that R has
| > been doing this for thousands of packages for over a decade ("R CMD
| > INSTALL foo"
| > just works). We all use this feature.
| >
| > I recommend that you try to understand how packages (with C, C++, or
| > Fortran
| > sources) are built. There are many to chose from at CRAN, including those
| > using Rcpp. The 'Writing Rcpp Extensions' manual has details, and there
| > are many tutorials on the web.
| >
| > As for your porting efforts, I already once explained to you that you can
| >
| >
| > either switch to using RcppClassic and use its header RcppClassic.h
| > instead of Rcpp.h; this is explained in the RcppClassic vignette
| >
| > or port as you are attempting which should be fine too
| >
| > You are free to use Code::Blocks or whatever editing environment you
| > chose, but in order to build R you have to use the steps R needs to build.
| > 'R CMD
| > INSTALL foo' automates a lot of that, I would use it if I were you.
| >
| >
| > Dirk
| >
| >
| > |
| > | Dahir.
| > |
| > |
| > | On Wed, March 9, 2011 16:57, Douglas Bates wrote:
| > | > On Wed, Mar 9, 2011 at 9:14 AM, Dahir Alihassan <da288 at cantab.net>
| > wrote:
| > | >
| > | >> Hi,
| > | >>
| > | >>
| > | >> I am posting here upon Dirk's suggestion, as I understand this is
| > well | >> attended to and I'd be grateful for any help. I am taking over a
| > project | >> which involves upgrading to the latest version of Rcpp and
| > thus I have | >> to upgrade all the old style API calls (which is
| > compatible with the | >> Classic
| > | >> version I believe). The compile works fine but the errors arise on
| > | >> linking against the resulting \inst\libs\RLinkage.dll.
| > | >>
| > | >> I have manged to convert a lot of the code (mainly using Rcpp::List
| > to | >> extract and pack incoming and outgoing function parameters but
| > also a | >> bit of exception handling) but I simply keep getting
| > "undefined
| > | >> reference" errors on linking. The build log after compiling says
| > | >> "Linking console
| > | >> executable" and this is where it list undefined references in the
| > | >> *.o:*.cpp files to:
| > | >>
| > | >>
| > | >> 1.Rprintf or Rf_error and forward_exception_to_r.
| > | >> 2.R_NilValue
| > | >> 3.Rf_install
| > | >>
| > | >
| > | > Except for forward_exception_to_r those symbols are part of the R API.
| > | > Can you provide the output from the compilation of the package? The
| > | > last line of the compilation should look like
| > | >
| > | > g++ -shared -o minqa.so altmov.o bigden.o biglag.o bobyqa.o bobyqb.o
| > | > lagmax.o minqa.o newuoa.o newuob.o prelim.o rescue.o trsapp.o trsbox.o
| > | > trstep.o uobyqa.o uobyqb.o update.o updatebobyqa.o
| > | > -L/home/bates/R/x86_64-pc-linux-gnu-library/2.12/Rcpp/lib -lRcpp
| > | > -Wl,-rpath,/home/bates/R/x86_64-pc-linux-gnu-library/2.12/Rcpp/lib
| > | > -lgfortran -lm -L/usr/lib64/R/lib -lR
| > | >
| > | >
| > | > and the important part is the -lR at the end. That is where those
| > symbols | > (except for forward_exception_to_r) are defined.
| > | >
| > | >
| > | >> I do have #include <Rcpp.h> (there was a series of errors that were
| > | >> occuring because I had included iostream before Rcpp, which was
| > strange). | >> I've tried looking at the RCPP PDF but can't seem to figure
| > it | >> out. I also tried to ensure that R.dll is on my PATH (C:\Program
| > | >> Files\R\R-2.12.1\bin\x64). I am using Code::Blocks 10.05 IDE with
| > | >> RTools
| > | >> installed and Mingw64 referenced explicitly in the toolchain (and
| > | >> correctly Autodetected as the compiler). I'd be extremelt grateful
| > for | >> any heads up. 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
| > | >>
| > | >>
| > | >
| > |
| > | _______________________________________________
| > | 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
| >
| >
|
--
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
More information about the Rcpp-devel
mailing list