I am getting an "-Werror=format-security" error when gcc compiles lpSolve in R.
I am using Ubuntu 12.04 (lubuntu kernel) and R version 3.1.0.
Here is the exact error:
* installing *source* package ‘lpSolve’ ...
** libs
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I . -DINTEGERTIME -DPARSER_LP -DBUILDING_FOR_R -DYY_NEVER_INTERACTIVE -DUSRDLL -DCLOCKTIME -DRoleIsExternalInvEngine -DINVERSE_ACTIVE=INVERSE_LUSOL -DINLINE=static -DParanoia -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g -c colamd.c -o colamd.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I . -DINTEGERTIME -DPARSER_LP -DBUILDING_FOR_R -DYY_NEVER_INTERACTIVE -DUSRDLL -DCLOCKTIME -DRoleIsExternalInvEngine -DINVERSE_ACTIVE=INVERSE_LUSOL -DINLINE=static -DParanoia -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g -c commonlib.c -o commonlib.o
commonlib.c: In function ‘blockWriteINT’:
commonlib.c:691:3: error: format not a string literal and no format arguments [-Werror=format-security]
commonlib.c: In function ‘blockWriteBOOL’:
commonlib.c:710:3: error: format not a string literal and no format arguments [-Werror=format-security]
commonlib.c: In function ‘blockWriteREAL’:
commonlib.c:732:3: error: format not a string literal and no format arguments [-Werror=format-security]
cc1: some warnings being treated as errors
make: *** [commonlib.o] Error 1
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I . -DINTEGERTIME -DPARSER_LP -DBUILDING_FOR_R -DYY_NEVER_INTERACTIVE -DUSRDLL -DCLOCKTIME -DRoleIsExternalInvEngine -DINVERSE_ACTIVE=INVERSE_LUSOL -DINLINE=static -DParanoia -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g -c commonlib.c -o commonlib.o
commonlib.c: In function ‘blockWriteINT’:
commonlib.c:691:3: error: format not a string literal and no format arguments [-Werror=format-security]
commonlib.c: In function ‘blockWriteBOOL’:
commonlib.c:710:3: error: format not a string literal and no format arguments [-Werror=format-security]
commonlib.c: In function ‘blockWriteREAL’:
commonlib.c:732:3: error: format not a string literal and no format arguments [-Werror=format-security]
cc1: some warnings being treated as errors
make: *** [commonlib.o] Error 1
ERROR: compilation failed for package ‘lpSolve’
* removing ‘/home/ben/lpSolve.Rcheck/lpSolve’
I have tried manually installing it using R CMD INSTALL. I've also followed the instructions here to no avail.
Thanks for looking.
The error occurs at fprintf in the functions, thus if you download the source code, re-make the package, and it'll be solved. But the lpSolve packing is currently orphaned. The error might occur due to the compiler check. Here's a way to make a detour.
Go to R etc path (e.g. /usr/lib/R/etc, or /etc/R).
Edit Makeconf file: remove -Werror=format-security in CFLAGS. (It is read-only file, thus su authority is required.)
Re-install package: install.package('lpSolve')
Restore Makeconf file back if necessary.
I hope this help you.
Related
I want to build mesa3d source code for some reason. I follow the guide on https://mesa3d.org/install.html and the build environment is fedora31 and gcc9.2, but there are some build error when I trying to build the code with running ninja install.
FAILED: src/mesa/drivers/dri/r200/58cd8d4##r200#sta/radeon_buffer_objects.c.o
cc -Isrc/mesa/drivers/dri/r200/58cd8d4##r200#sta -Isrc/mesa/drivers/dri/r200 -I../src/mesa/drivers/dri/r200 -Iinclude -I../include -Isrc -I../src -Isrc/mapi -I../src/mapi -Isrc/mesa -I../src/mesa -I../src/gallium/include -Isrc/gallium/auxiliary -I../src/gallium/auxiliary -Isrc/mesa/drivers/dri/common -I../src/mesa/drivers/dri/common -Isrc/util -I../src/util -I../src/mesa/drivers/dri/r200/server -Isrc/util/xmlpool -I/usr/include/libdrm -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c99 -O2 -g -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS '-DPACKAGE_VERSION="20.0.0-devel"' '-DPACKAGE_BUGREPORT="https://gitlab.freedesktop.org/mesa/mesa/issues"' -DUSE_ELF_TLS -DHAVE_ST_VDPAU -DENABLE_ST_OMX_BELLAGIO=0 -DENABLE_ST_OMX_TIZONIA=0 -DHAVE_X11_PLATFORM -DGLX_INDIRECT_RENDERING -DGLX_DIRECT_RENDERING -DGLX_USE_DRM -DHAVE_DRM_PLATFORM -DHAVE_SURFACELESS_PLATFORM -DENABLE_SHADER_CACHE -DHAVE___BUILTIN_BSWAP32 -DHAVE___BUILTIN_BSWAP64 -DHAVE___BUILTIN_CLZ -DHAVE___BUILTIN_CLZLL -DHAVE___BUILTIN_CTZ -DHAVE___BUILTIN_EXPECT -DHAVE___BUILTIN_FFS -DHAVE___BUILTIN_FFSLL -DHAVE___BUILTIN_POPCOUNT -DHAVE___BUILTIN_POPCOUNTLL -DHAVE___BUILTIN_UNREACHABLE -DHAVE_FUNC_ATTRIBUTE_CONST -DHAVE_FUNC_ATTRIBUTE_FLATTEN -DHAVE_FUNC_ATTRIBUTE_MALLOC -DHAVE_FUNC_ATTRIBUTE_PURE -DHAVE_FUNC_ATTRIBUTE_UNUSED -DHAVE_FUNC_ATTRIBUTE_WARN_UNUSED_RESULT -DHAVE_FUNC_ATTRIBUTE_WEAK -DHAVE_FUNC_ATTRIBUTE_FORMAT -DHAVE_FUNC_ATTRIBUTE_PACKED -DHAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL -DHAVE_FUNC_ATTRIBUTE_VISIBILITY -DHAVE_FUNC_ATTRIBUTE_ALIAS -DHAVE_FUNC_ATTRIBUTE_NORETURN -DHAVE_UINT128 -D_GNU_SOURCE -DUSE_SSE41 -DUSE_GCC_ATOMIC_BUILTINS -DUSE_X86_64_ASM -DMAJOR_IN_SYSMACROS -DHAVE_SYS_SYSCTL_H -DHAVE_LINUX_FUTEX_H -DHAVE_ENDIAN_H -DHAVE_DLFCN_H -DHAVE_EXECINFO_H -DHAVE_SYS_SHM_H -DHAVE_CET_H -DHAVE_STRTOF -DHAVE_MKOSTEMP -DHAVE_TIMESPEC_GET -DHAVE_MEMFD_CREATE -DHAVE_RANDOM_R -DHAVE_FLOCK -DHAVE_STRTOK_R -DHAVE_PROGRAM_INVOCATION_NAME -DHAVE_POSIX_MEMALIGN -DHAVE_STRTOD_L -DHAVE_DLADDR -DHAVE_DL_ITERATE_PHDR -DHAVE_ZLIB -DHAVE_PTHREAD -DHAVE_PTHREAD_SETAFFINITY -DHAVE_LIBDRM -DLLVM_AVAILABLE '-DMESA_LLVM_VERSION_STRING="9.0.0"' -DHAVE_VALGRIND -DHAVE_WAYLAND_PLATFORM -DWL_HIDE_DEPRECATED -DHAVE_DRI3 -DHAVE_DRI3_MODIFIERS -Werror=implicit-function-declaration -Werror=missing-prototypes -Werror=return-type -Werror=empty-body -Werror=incompatible-pointer-types -Wno-missing-field-initializers -Wno-format-truncation -fno-math-errno -fno-trapping-math -Werror=format -Wformat-security -fPIC -fvisibility=hidden -DRADEON_R200 -MD -MQ 'src/mesa/drivers/dri/r200/58cd8d4##r200#sta/radeon_buffer_objects.c.o' -MF 'src/mesa/drivers/dri/r200/58cd8d4##r200#sta/radeon_buffer_objects.c.o.d' -o 'src/mesa/drivers/dri/r200/58cd8d4##r200#sta/radeon_buffer_objects.c.o' -c ../src/mesa/drivers/dri/r200/radeon_buffer_objects.c
../src/mesa/drivers/dri/r200/radeon_buffer_objects.c:1:1: error: expected identifier or '(' before '.' token
1 | ../radeon/radeon_buffer_objects.c
| ^
Then I check the radeon_buffer_objects.c, and this file just have one file path in it.
../radeon/radeon_buffer_objects.c
I'm not very familier with gcc and clang. What is that mean? And how can I resolve this build error?
As AnthonySottile's comment said, this error is about the symbol link support. I have cloned this repo to windows before and upload to my own git server. And the error occured when I trying to build the source code from my git.
I try to clone the repo from mesa3d.org, and the issue resolved.
Thanks for the help, guys.
When I try to do install.packages("seqminer"), I get the following error:
configure: CC = gcc -std=gnu99
configure: CFLAGS = -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g
configure: CXX = ERROR: no information for variable 'CXX1X' ERROR: no information for variable 'CXX1XSTD'
configure: CXXFLAGS = ERROR: no information for variable 'CXX1XFLAGS'
checking whether the C++ compiler works... no
configure: error: in `/tmp/Rtmp2qP3iH/R.INSTALL6ffb49156e3b/seqminer':
configure: error: C++ compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘seqminer’
I tried every possible solution I can find online excluding downgrading my gpp because I need to use this version. So far I edited my /etc/R/Makeconf like this:
CC = gcc -std=gnu99
CFLAGS = -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g $(LTO)
CPICFLAGS = -fpic
CPPFLAGS =
CXX = c++
CXXCPP = $(CXX) -E
CXXFLAGS = -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g $(LTO)
CXXPICFLAGS = -fpic
CXX11 = g++
CXX11FLAGS = -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g
CXX11PICFLAGS = -fpic
CXX11STD = -std=gnu++0x
In summary, I changed all CXX1X occurences to CXX11 and all c++11 occurences to gnu++0x. I tried to change it to gnu++11, c++0x and c++11 too. None of them works. The error I have now is almost the same:
configure: CC = gcc -std=gnu99
configure: CFLAGS = -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g
configure: CXX = ERROR: no information for variable 'CXX11' ERROR: no information for variable 'CXX11STD'
configure: CXXFLAGS = ERROR: no information for variable 'CXX11FLAGS'
checking whether the C++ compiler works... no
configure: error: in `/tmp/Rtmp2qP3iH/R.INSTALL6ffb49156e3b/seqminer':
configure: error: C++ compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘seqminer’
My versions:
I use Ubuntu 16.04 in this machine.
My R version is: 3.2.3.
gcc/g++/c++ version is: (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609
I can't find the config.log.
When I try to do R CMD config $VAR with these settings for VARS CXX11 CXX11FLAGS CXX11FLAGS CXX11PICFLAGS and CXX11STD I get the following error:
ERROR: no information for variable 'CXX11STD' etc.
I don't have any local Makeconf to override. e.g. ~/.R/Makeconf does not exists.
I tried setting env variables and getting them to check if they exist:
Sys.setenv("CXX11STD"="-std=g++11")
Sys.getenv("CXX11STD")
Works as it should be. But then I try to install package again, it still gives me same error.
Clone its repo and update its configure file as follows.
git clone https://github.com/zhanxw/seqminer.git /tmp/seqminer
cd /tmp/seqminer
vim configure
Comment out these lines in the configure file as those variables are not set correctly.
CC=`"${R_HOME}/bin/R" CMD config CC`
CFLAGS=`"${R_HOME}/bin/R" CMD config CFLAGS`
CXX11=`"${R_HOME}/bin/R" CMD config CXX11`
CXX11STD=`"${R_HOME}/bin/R" CMD config CXX11STD`
CXX11FLAGS=`"${R_HOME}/bin/R" CMD config CXX11FLAGS`
CXX="${CXX11} ${CXX11STD}"
Install the package from the local source in an R session.
install.packages("/tmp/seqminer", repos=NULL, type="source")
I have been trying to install RMariaDB on my CentOS server with no success. I am running R version 3.5. I keep getting error messages related to scope. The source files seem to be correct and the install has been MD5 Sum checked. The package will unpack but then fails with a non-zero exit status. I get similar error messages whether I am installing RMySQL or RMariaDB. They are both related to the my_bool variable. Specific error messages are posted below:
> install.packages("RMariaDB")
Installing package into ‘/home/cmiddlet#cgifederal.com/R/x86_64-redhat-linux-gnu-library/3.5’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/RMariaDB_1.0.6.tar.gz'
Content type 'application/x-gzip' length 42903 bytes (41 KB)
==================================================
downloaded 41 KB
* installing *source* package ‘RMariaDB’ ...
** package ‘RMariaDB’ successfully unpacked and MD5 sums checked
Using mysql_config
Found mysql_config/mariadb_config cflags and libs!
Using PKG_CFLAGS=-I/usr/include/mysql -m64
Using PKG_LIBS=-L/usr/lib64/mysql -lmysqlclient -lpthread -lm -lrt -lssl -lcrypto -ldl
** libs
g++ -m64 -I"/usr/include/R" -DNDEBUG -I/usr/include/mysql -m64 -I"/usr/share/R/library/BH/include" -I"/usr/share/R/library/plogr/include" -I"/home/cmiddlet#cgifederal.com/R/x86_64-redhat-linux-gnu-library/3.5/Rcpp/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 DbConnection.cpp -o DbConnection.o
g++ -m64 -I"/usr/include/R" -DNDEBUG -I/usr/include/mysql -m64 -I"/usr/share/R/library/BH/include" -I"/usr/share/R/library/plogr/include" -I"/home/cmiddlet#cgifederal.com/R/x86_64-redhat-linux-gnu-library/3.5/Rcpp/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 DbResult.cpp -o DbResult.o
In file included from MariaResultPrep.h:6:0,
from DbResult.cpp:4:
MariaBinding.h:14:15: error: ‘my_bool’ was not declared in this scope
std::vector<my_bool> is_null;
^
MariaBinding.h:14:22: error: template argument 1 is invalid
std::vector<my_bool> is_null;
^
MariaBinding.h:14:22: error: template argument 2 is invalid
In file included from MariaResultPrep.h:9:0,
from DbResult.cpp:4:
MariaRow.h:18:15: error: ‘my_bool’ was not declared in this scope
std::vector<my_bool> nulls_, errors_;
^
MariaRow.h:18:22: error: template argument 1 is invalid
std::vector<my_bool> nulls_, errors_;
^
MariaRow.h:18:22: error: template argument 2 is invalid
make: *** [DbResult.o] Error 1
ERROR: compilation failed for package ‘RMariaDB’
* removing ‘/home/cmiddlet#cgifederal.com/R/x86_64-redhat-linux-gnu-library/3.5/RMariaDB’
Warning in install.packages :
installation of package ‘RMariaDB’ had non-zero exit status
The downloaded source packages are in
‘/tmp/Rtmpwlaf35/downloaded_packages’
I am trying to compile a program mafTools on MacOSX using gnu make. I get the following error:
cd mafExtractor && make all
clang -std=c99 -stdlib=libstdc++ -O3 -c -O3 -Wall -Werror --pedantic -funroll-loops -DNDEBUG -Wshadow -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -I ../../sonLib/lib -I ../inc -I ../external src/mafExtractorAPI.c -o src/mafExtractorAPI.o.tmp -lm
This gives the error:
clang: error: -lm: 'linker' input unused [-Werror,-Wunused-command-line-argument]
make[1]: \*** [src/mafExtractorAPI.o] Error 1
make: \*** [mafExtractor.all] Error 2
I looked at similar errors but couldn't fix it. Any help will be much appreciated. Thanks!
This is the package: https://github.com/dentearl/mafTools/tree/master/mafExtractor
Everything else here compiled successfully.
This is the makefile:
https://github.com/dentearl/mafTools/blob/master/mafExtractor/Makefile
Thanks a bunch.
Your clang commaand includes the -c option which means you do not want to link and resolve external references, you just want to produce an unlinked object file.
Your -lm option says you want to link with the maths library.
Basically, the aforementioned options are incompatible - you cannot both link with the math library and not link.
TLDR; Remove -lm
I have been trying to install HEALPix over the last few days on my iMac and I am at something of a dead end as to how to proceed. When I run the necessary make command, I am told that the file string does not exist.
# compiling Healpix_cxx/syn_alm_cxx.cc
cd /Users/keir/Software/Healpix_3.11/src/cxx/build.osx/Healpix_cxx && g++ -I/usr/local
/include -I/Users/keir/Software/Healpix_3.11/src/cxx/c_utils -I/Users/keir/Software
/Healpix_3.11/src/cxx/libfftpack -I/Users/keir/Software/Healpix_3.11/src/cxx/libsharp
-I/Users/keir/Software/Healpix_3.11/src/cxx/cxxsupport -I/Users/keir/Software/
Healpix_3.11/src/cxx/Healpix_cxx -I/Users/keir/Software/Healpix_3.11/src/cxx/alice
-I/Users/keir/Software/Healpix_3.11/src/cxx/build.osx -Wall -Wextra -Wstrict-aliasing=2
-Wundef -Wshadow -Wwrite-strings -Wredundant-decls -Woverloaded-virtual -Wcast-qual
-Wcast-align -Wpointer-arith -Wold-style-cast -Wno-unknown-pragmas -Wfatal-errors -g
-fopenmp -fPIC -O2 -ffast-math -fomit-frame-pointer -ansi -fdata-sections
-ffunction-sections -c /Users/keir/Software/Healpix_3.11/src/cxx/Healpix_cxx/
syn_alm_cxx.cc
In file included from /Users/keir/Software/Healpix_3.11/src/cxx/Healpix_cxx/
syn_alm_cxx.cc:2:0:
/Users/keir/Software/Healpix_3.11/src/cxx/cxxsupport/error_handling.h:35:18: fatal
error: string: No such file or directory
#include <string>
^
compilation terminated.
make[1]: *** [/Users/keir/Software/Healpix_3.11/src/cxx/build.osx/Healpix_cxx/syn_alm_cxx.o] Error 1
I have had a look and it certainly does as is the whole of the libstdc++ library (I think). I have tried many solutions including re-installing Xcode and its Command Line Tools and trying various other versions of gcc (4.8, 4.9, 5.0 and a 4.9 copy from homebrew) - none of which solve the problem.
I have created a test file 'foo.cpp' with just #include <string> in it and this will still not compile even if I specify a directory for string with the -I tag, because it then can't find more headers that string depends on. It seems to me that libstdc++ isn't installed in the correct place? Or the '#include' command isn't looking in the right places? Do you have an idea as to how to fix this problem?