R gputools: gcc: error: unrecognized command line option ‘-Wp’ - r

I had an error when I install gputools in R, and I cannot find any solution by google.
I use command install.packages("gputools")
/usr/local/cuda/bin/nvcc -c -Xcompiler "-fpic -I/usr/local/include -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic" -I. -I"/usr/local/cuda/include" -I"/usr/lib64/R/include" rinterface.cu -o rinterface.o
gcc: error: unrecognized command line option ‘-Wp’
make: *** [rinterface.o] Error 1
ERROR: compilation failed for package ‘gputools’
Can someone help me here? My gpu cards is given by
01:00.0 VGA compatible controller: NVIDIA Corporation GM107GL [Quadro K620] (rev a2)

Ok, I got this working with a couple hacks. This is for centos 7.
First issue was solved by looking at the mailing list. https://github.com/nullsatz/gputools/issues/12
Edit the Makefile, and Modify line 'CFLAGS : put '\' after 'Wp' & before ','
CFLAGS = -O2 -g -pipe -Wall -Werror=format-security -Wp\,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic
Second problem was that the R shared lib was not being found. I tried setting the LD_LIBRARY_PATH in the driver configuration file, and on the command line, but that did not work.
I ended up with the following hack:
cd /usr/local/cuda/lib64 && ln -s /usr/lib64/R/lib/libR.so libR.so
I used the command following to build (note the tar.gz file now contains the modified Makefile)
R CMD INSTALL --configure-args="--with-nvcc=/usr/local/cuda/bin/nvcc --with-r-lib=/usr/lib64/" ./gputools_1.0.tar.gz
I know this is ugly, but it seems to work.

It seems that your makefile has a typo
-Wp,-D_FORTIFY_SOURCE=2
Specifically, the comma (',') should be a space (' ') only.
Please try that and report back letting us know what happened

Related

Override Specific Compiler Flags When Installing R Packages

I have a R script that tries to install many packages (omitted all but showing just one):
install.packages("zoo")
Then I run
Rscript my_r.r
Then, I noticed it will try to compile some C code:
gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -I../inst/include -I"/latest/rsg_comm/r_packages/zoo/include" -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c any.c -o any.o
Is there a way to ask all packages to be compiled locally with -O3 and -mtune=native?
I noticed that there is a similar post that suggests using ~/R/.Makevars. But it seems like
it will override all compiler flags instead of just those 2 I specify. Is there a way to specify?
I have to download the source package of each source, which is not as convenient as just using install.packages("package_name"), which will figure the latest version, and go through a mirror, etc. Or there is a convenient way?
You can edit your .R/Makevars file and append the desired flags using the += operator, e.g.
CFLAGS+= -O3 -Wall -mtune=native -march=native
The latter flag is used if there is a conflict, as you said in your comment below. In terms of compiling from source, you can do this via install.packages(), e.g.
install.packages("package_name", type = "source")

How to change which C++ version compiler is used when installing an R package from source?

I'm trying to install an R package from source using remotes::install_github("pkgname"). I get the following error:
/bin/sh: /usr/local/Cellar/gcc/9.2.0/bin/g++-7: No such file or directory
I checked and I have g++-9 instead. I've been looking for a way to change the settings to direct to the correct path but so far have had no luck. I'm not even sure which package to look in or whether to approach R config files. Any help would be greatly appreciated.
I'm using R version 3.6.3 on Mac OSX 10.15.5 (Catalina). I have XCode developer tools installed but whenever I run checks RStudio suggests that I install them as if it can't find it.
Many thanks
Besides what #bats_n_stats (great handle!) wrote, the following holds:
Each Rcpp use is driven by R itself
R can tell us what it uses via R CMD config calls. On my system
edd#rob:~$ R CMD config CXX
ccache g++
edd#rob:~$
meaning the (standard) value of g++ (no qualified version) is used in conjunction with the accelerating cache provided by ccache (different topic, I blogged about it in the past)
You can also look at that via grep in the actual conffile (which I look up directly below)
edd#rob:~$ grep ^CXX $(R RHOME)/etc/Makeconf
CXX = g++ -std=gnu++11
CXXCPP = $(CXX) -E
CXXFLAGS = -g -O2 -fdebug-prefix-map=/build/r-base-Do_dS_/r-base-4.0.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g $(LTO)
CXXPICFLAGS = -fpic
CXX11 = g++
CXX11FLAGS = -g -O2 -fdebug-prefix-map=/build/r-base-Do_dS_/r-base-4.0.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g $(LTO)
CXX11PICFLAGS = -fpic
CXX11STD = -std=gnu++11
CXX14 = g++
CXX14FLAGS = -g -O2 -fdebug-prefix-map=/build/r-base-Do_dS_/r-base-4.0.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g $(LTO)
CXX14PICFLAGS = -fpic
CXX14STD = -std=gnu++14
CXX17 = g++
CXX17FLAGS = -g -O2 -fdebug-prefix-map=/build/r-base-Do_dS_/r-base-4.0.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g $(LTO)
CXX17PICFLAGS = -fpic
CXX17STD = -std=gnu++17
CXX20 = g++
CXX20FLAGS = -g -O2 -fdebug-prefix-map=/build/r-base-Do_dS_/r-base-4.0.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g $(LTO)
CXX20PICFLAGS = -fpic
CXX20STD = -std=gnu++2a
CXX_VISIBILITY = -fvisibility=hidden
edd#rob:~$
This values all come from when R itself was built. So if that bites on your Catalina system you need to review where you got R from and what can possibly be wrong there. Use of Cellar suggests something macOS specific and likely not the suggested R from the https://mac.r-project.org/ page.
It looks like R can't see your g++ compiler, as you suggest.
1 Checking if g++ is on PATH
Did you install R with homebrew? Since the error path is pointing at /usr/local/Cellar, that seems to be the case.
You can see if the g++ compiler is on path by opening the Terminal program on Mac OS and typing:
echo $CXX
If it returns null (or nothing), there's nothing on path there.
2 Install g++ in brew
Let's install g++ in brew. Open your Terminal and run the following, pressing enter after each line:
brew update
brew install gcc48
brew doctor
After this, please restart your computer.
3 Check if g++ is on PATH now
Run echo $CXX again on Terminal. If that still doesn't work, see this current issue:
https://github.com/r-lib/rlang/issues/754
I suggest if that didn't work to try to install XCode developer tools again. You can do that as below:
xcode-select --install

building a mapnik 2.2.0 RPM on RHEL 7

I am trying to build a mapnik 2.2.0 RPM file on my RHEL/CENTOS 7 machine.
so I took the RPM SRC file from Fedora 22 which is mapnik-2.2.0-11.fc21.src.rpm ( I have the same result with mapnik-2.2.0-5.fc20.src.rpm )
when I am running the rpmbuild I receive the following error message:
Welcome to Mapnik...
scons: warning: Ignoring missing SConscript 'deps/agg/build.py'
File "/root/rpmbuild/BUILD/mapnik-v2.2.0/SConstruct", line 1799, in <module>
scons: warning: Ignoring missing SConscript 'deps/mapnik/build.py'
File "/root/rpmbuild/BUILD/mapnik-v2.2.0/SConstruct", line 1808, in <module>
scons: done reading SConscript files.
scons: Building targets ...
g++ -o bindings/python/mapnik_building_symbolizer.os -c -ansi -Wall -pthread -ftemplate-depth-300 -O3 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fno-strict-aliasing -finline-functions -Wno-inline -Wno-parentheses -Wno-char-subscripts -fPIC -DHAVE_JPEG -DMAPNIK_USE_PROJ4 -DHAVE_PNG -DHAVE_TIFF -DBIGINT -DBOOST_REGEX_HAS_ICU -DLINUX -DMAPNIK_THREADSAFE -DNDEBUG -DHAVE_CAIRO -DHAVE_PYCAIRO -I. -Iinclude -I/usr/include/polyclipping -I/usr/include/agg2 -I/usr/include -I/usr/include/freetype2 -I/usr/include/libxml2 -I/usr/include/gdal -I/usr/include/python2.7 -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/libpng15 -I/usr/include/libdrm -I/usr/include/pycairo bindings/python/mapnik_building_symbolizer.cpp
In file included from include/mapnik/symbolizer.hpp:29:0,
from include/mapnik/building_symbolizer.hpp:29,
from bindings/python/mapnik_building_symbolizer.cpp:26:
include/mapnik/image_compositing.hpp:74:19: error: 'comp_op_grain_merge' is not a member of 'agg'
grain_merge = agg::comp_op_grain_merge,
^
include/mapnik/image_compositing.hpp:75:21: error: 'comp_op_grain_extract' is not a member of 'agg'
grain_extract = agg::comp_op_grain_extract,
^
scons: *** [bindings/python/mapnik_building_symbolizer.os] Error 1
scons: building terminated because of errors.
error: Bad exit status from /var/tmp/rpm-tmp.kuI6KW (%build)
RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.kuI6KW (%build)
Mapnik normally comes with a heavily patched version of the AGG library right there in its source tree. The Fedora build however disables that in favour of having the Mapnik-AGG patches directly in its own AGG package (because they don't like duplicating system libraries elsewhere).
You either need an AGG library for CentOS that is feature-compatible with the patched Fedora version, or you have to modify your Mapnik build to disable the "system_agg" patch (and drop the "rm -rf boost deps" from the spec file).

github_install & R CMD INSTALL fails for videoplayR

I was trying to install the package videoplayR from github but failed to do the same. I tried two ways:
1. Using the installation guidance mentioned in README file.It gave the following error:
> install_github("sjmgarnier/videoplayR")
Downloading github repo sjmgarnier/videoplayR#master
Error in function (type, msg, asError = TRUE) :
2. Using R CMD SHLIB etc gives the following error while running R CMD check. It is a part of the install.out file:
* installing source package ‘videoplayR’ ...
** libs
g++ -I/usr/share/R/include -DNDEBUG -I"/home/nandy/R/x86_64-pc-linux-gnu-library/3.1/Rcpp/include" -I"/home/nandy/R/x86_64-pc-linux-gnu-library/3.1/RcppArmadillo/include" pkg-config --cflags opencv Rscript -e <p>'Rcpp:::CxxFlags()' -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g -c RcppExports.cpp -o RcppExports.o
g++ -I/usr/share/R/include -DNDEBUG -I"/home/nandy/R/x86_64-pc-linux-gnu-library/3.1/Rcpp/include" -I"/home/nandy/R/x86_64-pc-linux-gnu-library/3.1/RcppArmadillo/include" pkg-config --cflags opencv Rscript -e <p>'Rcpp:::CxxFlags()' -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g -c Video.cpp -o Video.o
Video.cpp: In member function ‘double Video::current_frame()’:
Video.cpp:42:25: error: ‘CV_CAP_PROP_POS_FRAMES’ was not declared in this scope
return(inputVideo.get(CV_CAP_PROP_POS_FRAMES));
^
Video.cpp: In member function ‘void Video::set_current_frame(int)’:
Video.cpp:46:18: error: ‘CV_CAP_PROP_POS_FRAMES’ was not declared in this scope
inputVideo.set(CV_CAP_PROP_POS_FRAMES, n);
^
Video.cpp: In member function ‘void Video::next_frame_cv()’:
Video.cpp:63:22: error: ‘CV_CAP_PROP_POS_FRAMES’ was not declared in this scope
if (inputVideo.get(CV_CAP_PROP_POS_FRAMES) == inputVideo.get(CV_CAP_PROP_FRAME_COUNT)) {
^
Video.cpp:63:64: error: ‘CV_CAP_PROP_FRAME_COUNT’ was not declared in this scope
if (inputVideo.get(CV_CAP_PROP_POS_FRAMES) == inputVideo.get(CV_CAP_PROP_FRAME_COUNT)) {
^
Video.cpp: In member function ‘void Video::get_frame_cv(int)’:
Video.cpp:76:27: error: ‘CV_CAP_PROP_FRAME_COUNT’ was not declared in this scope
if (n > inputVideo.get(CV_CAP_PROP_FRAME_COUNT)) {
^
Video.cpp:80:18: error: ‘CV_CAP_PROP_POS_FRAMES’ was not declared in this scope
inputVideo.set(CV_CAP_PROP_POS_FRAMES, n);
^
Video.cpp: In member function ‘int Video::length()’:
Video.cpp:91:25: error: ‘CV_CAP_PROP_FRAME_COUNT’ was not declared in this scope
return(inputVideo.get(CV_CAP_PROP_FRAME_COUNT));
^
I am guessing problem 2 is occurring due to version problem of OpenCV. Am I right? Is there any way out of this?
Looks similar to these 2 reported problems: https://github.com/hadley/devtools/issues/650 and https://github.com/hadley/devtools/issues/467. It seems that you need to update your system (Linux I presume) to the latest version of Curl.
I believe this is my fault. I forgot to exclude the compiled shared object videoplayR.so last time I committed changes to the GitHub repo. If you're using a different OS than mine (OSX Yosemite), it is most certainly the cause of the problem that you encountered. I fixed it and now it should compile nicely on your computer as well.
FYI I compiled and ran the package with both OpenCV 2.4.9 and 2.4.10, but it should work with any 2.4.X version of OpenCV (never tried the latest OpenCV 3.0 beta).

QT5-alpha build errors in Ubuntu-Linux 11.10

I tried the instructions of building latest QT5-Alpha(http://qt-project.org/wiki/Qt-5-Alpha
http://qt-project.org/wiki/Building_Qt_5_from_Git)
from GIT,but facing compilation in wayland files
Ubuntu Linux 11.10
__make[4]: Entering directory `/home/xyz/build/newqt5/qt5/qtwayland/src/plugins/platforms/wayland'
g++ -c -pipe -g -fvisibility=hidden -fvisibility-inlines-hidden -D_REENTRANT -Wall -W -fPIC -DQT_NO_LIBUDEV -DQ_PLATFORM_WAYLAND -DQT_NO_WAYLAND_XKB -DQT_WAYLAND_GL_SUPPORT -DQT_WAYLAND_WINDOWMANAGER_SUPPORT -DQ_FONTCONFIGDATABASE -DQT_COMPILES_IN_HARFBUZZ -DQT_PLUGIN -DQT_GUI_LIB -DQT_CORE_LIB -I/home/xyz/build/newqt5/qt5/qtbase/mkspecs/linux-g++ -I. -I/home/xyz/build/newqt5/qt5/qtbase/include/QtCore/5.0.0 -I/home/xyz/build/newqt5/qt5/qtbase/include/QtCore/5.0.0/QtCore -I/home/xyz/build/newqt5/qt5/qtbase/include/QtCore -I/home/xyz/build/newqt5/qt5/qtbase/include/QtGui/5.0.0 -I/home/xyz/build/newqt5/qt5/qtbase/include/QtGui/5.0.0/QtGui -I/home/xyz/build/newqt5/qt5/qtbase/include/QtGui -I/home/xyz/build/newqt5/qt5/qtbase/include/QtPlatformSupport/5.0.0 -I/home/xyz/build/newqt5/qt5/qtbase/include/QtPlatformSupport/5.0.0/QtPlatformSupport -I/home/xyz/build/newqt5/qt5/qtbase/include/QtPlatformSupport -I/home/xyz/build/newqt5/qt5/qtbase/include -I../../../shared -Igl_integration/xcomposite_share -I.moc/debug-shared -o .obj/debug-shared/qwaylandintegration.o qwaylandintegration.cpp
In file included from qwaylandshmwindow.h:45:0,
from qwaylandintegration.cpp:46:
qwaylandwindow.h:112:18: error: ‘wl_callback_listener’ does not name a type
make[4]: *** [.obj/debug-shared/qwaylandintegration.o] Error 1_
Any pointers to overcome this?
Download the alpha source package here: http://releases.qt-project.org/qt5.0/alpha/ and use the steps in README file.
The master in git is NOT what was released as alpha. The build scripts are different. You have to wait for them to add alpha tag to pull it from git. But why not just grab the gz file?

Resources