As the google perftools are specifically designed for multi-threaded C++ programs I ask this here rather than on R-devel. On a Linux system (Ubuntu 11.10) I have been unsuccessful linking a package, say Rcpp, against -ltcmalloc. I do have /usr/lib/libtcmalloc.so.0 and friends installed but the link step comes back saying it can't find -ltcmalloc. I actually went to the trouble of including -L/usr/lib but installing the source package still ends in ... g++ -shared -Bdirect,--hash-style=both,-Wl,-O1 -o Rcpp.so Date.o DateVector.o Datetime.o DatetimeVector.o Dimension.o DottedPair.o Environment.o Evaluator.o Formula.o Function.o Language.o Module.o Pairlist.o Promise.o RObject.o RcppCommon.o Rcpp_init.o Reference.o Rostream.o Rstreambuf.o S4.o Symbol.o WeakReference.o barrier.o cache.o coerce.o complex.o debugging.o exceptions.o posixt.o r_cast.o -L/home/bates/build/R-devel/lib -lR -L/usr/lib -ltcmalloc ... /usr/bin/ld: cannot find -ltcmalloc collect2: ld returned 1 exit status make: *** [Rcpp.so] Error 1 ERROR: compilation failed for package ?Rcpp? Am I missing something subtle?
[Rcpp-devel] Linking a package to -ltmalloc from the google perftools
5 messages · Douglas Bates, Dirk Eddelbuettel
On 28 February 2012 at 12:43, Douglas Bates wrote:
| As the google perftools are specifically designed for multi-threaded | C++ programs I ask this here rather than on R-devel. | | On a Linux system (Ubuntu 11.10) I have been unsuccessful linking a | package, say Rcpp, against -ltcmalloc. I do have | /usr/lib/libtcmalloc.so.0 and friends installed but the link step | comes back saying it can't find -ltcmalloc. I actually went to the | trouble of including -L/usr/lib but installing the source package | still ends in | ... | g++ -shared -Bdirect,--hash-style=both,-Wl,-O1 -o Rcpp.so Date.o | DateVector.o Datetime.o DatetimeVector.o Dimension.o DottedPair.o | Environment.o Evaluator.o Formula.o Function.o Language.o Module.o | Pairlist.o Promise.o RObject.o RcppCommon.o Rcpp_init.o Reference.o | Rostream.o Rstreambuf.o S4.o Symbol.o WeakReference.o barrier.o | cache.o coerce.o complex.o debugging.o exceptions.o posixt.o r_cast.o | -L/home/bates/build/R-devel/lib -lR -L/usr/lib -ltcmalloc | ... | /usr/bin/ld: cannot find -ltcmalloc | collect2: ld returned 1 exit status | make: *** [Rcpp.so] Error 1 | ERROR: compilation failed for package ?Rcpp? | | Am I missing something subtle? You do have libgoogle-perftools-dev installed, right? Dirk
"Outside of a dog, a book is a man's best friend. Inside of a dog, it is too dark to read." -- Groucho Marx
On Tue, Feb 28, 2012 at 1:17 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
On 28 February 2012 at 12:43, Douglas Bates wrote: | As the google perftools are specifically designed for multi-threaded | C++ programs I ask this here rather than on R-devel. | | On a Linux system (Ubuntu 11.10) I have been unsuccessful linking a | package, say Rcpp, against -ltcmalloc. ?I do have | /usr/lib/libtcmalloc.so.0 and friends installed but the link step | comes back saying it can't find -ltcmalloc. ?I actually went to the | trouble of including -L/usr/lib but installing the source package | still ends in | ... | g++ -shared -Bdirect,--hash-style=both,-Wl,-O1 -o Rcpp.so Date.o | DateVector.o Datetime.o DatetimeVector.o Dimension.o DottedPair.o | Environment.o Evaluator.o Formula.o Function.o Language.o Module.o | Pairlist.o Promise.o RObject.o RcppCommon.o Rcpp_init.o Reference.o | Rostream.o Rstreambuf.o S4.o Symbol.o WeakReference.o barrier.o | cache.o coerce.o complex.o debugging.o exceptions.o posixt.o r_cast.o | -L/home/bates/build/R-devel/lib -lR -L/usr/lib -ltcmalloc | ... | /usr/bin/ld: cannot find -ltcmalloc | collect2: ld returned 1 exit status | make: *** [Rcpp.so] Error 1 | ERROR: compilation failed for package ?Rcpp? | | Am I missing something subtle? You do have libgoogle-perftools-dev installed, right?
Well, actually, no I didn't have that package installed. Thanks for the pointer.
On Tue, Feb 28, 2012 at 1:24 PM, Douglas Bates <bates at stat.wisc.edu> wrote:
On Tue, Feb 28, 2012 at 1:17 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
On 28 February 2012 at 12:43, Douglas Bates wrote: | As the google perftools are specifically designed for multi-threaded | C++ programs I ask this here rather than on R-devel. | | On a Linux system (Ubuntu 11.10) I have been unsuccessful linking a | package, say Rcpp, against -ltcmalloc. ?I do have | /usr/lib/libtcmalloc.so.0 and friends installed but the link step | comes back saying it can't find -ltcmalloc. ?I actually went to the | trouble of including -L/usr/lib but installing the source package | still ends in | ... | g++ -shared -Bdirect,--hash-style=both,-Wl,-O1 -o Rcpp.so Date.o | DateVector.o Datetime.o DatetimeVector.o Dimension.o DottedPair.o | Environment.o Evaluator.o Formula.o Function.o Language.o Module.o | Pairlist.o Promise.o RObject.o RcppCommon.o Rcpp_init.o Reference.o | Rostream.o Rstreambuf.o S4.o Symbol.o WeakReference.o barrier.o | cache.o coerce.o complex.o debugging.o exceptions.o posixt.o r_cast.o | -L/home/bates/build/R-devel/lib -lR -L/usr/lib -ltcmalloc | ... | /usr/bin/ld: cannot find -ltcmalloc | collect2: ld returned 1 exit status | make: *** [Rcpp.so] Error 1 | ERROR: compilation failed for package ?Rcpp? | | Am I missing something subtle? You do have libgoogle-perftools-dev installed, right?
Well, actually, no I didn't have that package installed. ?Thanks for the pointer.
Followup question: How does one invoke the cpu-profiler? You need to give a path to the binary, which is actually something like /usr/lib/R/bin/exec/R but that needs several environment variables to be set. Do you get around this by using littler?
On 28 February 2012 at 13:56, Douglas Bates wrote:
| >> You do have libgoogle-perftools-dev installed, right? | > | > Well, actually, no I didn't have that package installed. ?Thanks for | > the pointer. | | Followup question: How does one invoke the cpu-profiler? You need to | give a path to the binary, which is actually something like | /usr/lib/R/bin/exec/R but that needs several environment variables to | be set. Do you get around this by using littler? You need to link with -lprofiler for profiling, the tcmalloc library is another (unrelated) perftool. Once linked with the profiling library, you can either use env vars to control the profiling (where to log etc) or use two functions to start/end, not unlike what Rprof does. I do believe I used littler, but then I generally do on the command-line (rather than R CMD BATCH et al). A worked example should be in the "Intro to HPC with R" slides of which the latest version may be the one from useR 2010. Dirk
"Outside of a dog, a book is a man's best friend. Inside of a dog, it is too dark to read." -- Groucho Marx