configure: error: ERROR: ProtoBuf compiler headers require
wangchong666 opened this issue · 4 comments
- Download protobuf-all-3.15.1.tar.gz and install success.
- R CMD INSTALL RProtoBuf_0.4.17.tar.gz
configure: error: ERROR: ProtoBuf compiler headers required; use '-Iincludedir' in CXXFLAGS for unusual locations.
[czl@tkpcjk01-07 ~/RProtoBuf]$ configure: error: ERROR: ProtoBuf compiler headers requireno
After read the configure file i found the error log
/usr/local/include/google/protobuf/stubs/port.h:115:2: error: #error "Protobuf requires at least C++11."
#error "Protobuf requires at least C++11."
So we should add -std=c++11
flag
R CMD INSTALL --configure-args="CPPFLAGS='-std=c++11'" RProtoBuf_0.4.17.tar.gz
checking if ProtoBuf version >= 2.2.0... configure: error: Need ProtoBuf version >= 2.2.0
check the configure
file
## also check for minimum version
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if ProtoBuf version >= 2.2.0" >&5
$as_echo_n "checking if ProtoBuf version >= 2.2.0... " >&6; }
if test "$cross_compiling" = yes; then :
pb_version_ok=yes
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <google/protobuf/stubs/common.h>
int main() {
if (GOOGLE_PROTOBUF_VERSION >= 2001000) {
exit (0);
} else {
exit(1);
}
}
_ACEOF
if ac_fn_cxx_try_run "$LINENO"; then :
pb_version_ok=yes
else
pb_version_ok=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
check google/protobuf/stubs/common.h
#define GOOGLE_PROTOBUF_VERSION 3015001
Debug the configure script。。。
./conftest: error while loading shared libraries: libprotobuf.so.26: cannot open shared object file: No such file or directory
After export LD_LIBRARY_PATH=/usr/local/lib
finally install success!!
You may have that wrong. What operating system are you on? What compiler do you use, and what version does it have? I.e. please show g++ --version
or clang++ --version
or whatever corresponding compiler you use.
We have been enforcing use of C++11 for a long time -- at least for four years now per the git blame
below. So when a build fails at your end it usually means ... your compiler is too old.
edd@rob:~/git/rprotobuf(master)$ git blame src/Makevars.in
ab5e224c (Dirk Eddelbuettel 2009-10-27 02:49:57 +0000 1) ## -*- mode: makefile; -*-
296a2012 (Dirk Eddelbuettel 2009-11-05 12:26:43 +0000 2)
133e1cd0 (Dirk Eddelbuettel 2017-01-18 10:27:44 -0600 3) ## Make this C++11 so that we get better int64 support and much more
133e1cd0 (Dirk Eddelbuettel 2017-01-18 10:27:44 -0600 4) CXX_STD=CXX11
133e1cd0 (Dirk Eddelbuettel 2017-01-18 10:27:44 -0600 5)
133e1cd0 (Dirk Eddelbuettel 2017-01-18 10:27:44 -0600 6) ## Configure tells us about locations for ## both Rcpp (ie libRcpp.so and Rcpp.h) and
133e1cd0 (Dirk Eddelbuettel 2017-01-18 10:27:44 -0600 7) ## ProtoBuf headers and library via these variables
133e1cd0 (Dirk Eddelbuettel 2017-01-18 10:27:44 -0600 8) PKG_CPPFLAGS=@PKG_CPPFLAGS@
133e1cd0 (Dirk Eddelbuettel 2017-01-18 10:27:44 -0600 9) PKG_LIBS=@PKG_LIBS@
edd@rob:~/git/rprotobuf(master)$
@eddelbuettel thanks for reply
- g++ (GCC) 5.4.0 clang++: command not found
- centos 7
CentOS 7 and g++
5.4.0 "should be" good enough.
Re-reading, I think I also jumped at the wrong line in your log output (and you may have misread it too). The other problem we have is
checking if ProtoBuf version >= 2.2.0... configure: error: Need ProtoBuf version >= 2.2.0
So configure
, when called from R when trying to compile the RProtoBuf
package from source, does find an old version of the protocol buffers library on your system. That too is likely on your end. Here (using Ubuntu) I have
edd@rob:~$ dpkg -l | grep libproto | cut -c-70
ii libprotobuf-c-dev:amd64 1.3.3-1build2
ii libprotobuf-c1:amd64 1.3.3-1build2
ii libprotobuf-dev:amd64 3.12.3-2ubuntu2
ii libprotobuf-lite23:amd64 3.12.3-2ubuntu2
ii libprotobuf23:amd64 3.12.3-2ubuntu2
ii libprotoc-dev:amd64 3.12.3-2ubuntu2
ii libprotoc23:amd64 3.12.3-2ubuntu2
edd@rob:~$
You may have a library either from CentOS or from a local installation that makes the test go off. The test for this is really simple (once you know to read autoconf
which is a little like shell):
## also check for minimum version
AC_MSG_CHECKING([if ProtoBuf version >= 2.2.0])
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <google/protobuf/stubs/common.h>
int main() {
if (GOOGLE_PROTOBUF_VERSION >= 2001000) {
exit (0);
} else {
exit(1);
}
}
]])],
[pb_version_ok=yes],
[pb_version_ok=no],
[pb_version_ok=yes])
if test x"${pb_version_ok}" == x"no"; then
AC_MSG_ERROR([Need ProtoBuf version >= 2.2.0])
else
AC_MSG_RESULT([yes])
fi
There is a four-line C program in there that gets built and which reports back if the version is larger that 2001000 (which is actually more lax then the display; I may have a buglet there). In any event most installations will have Protocol Buffers 3.* these days.
I suggest you build the littler four-liner by hand (and maybe add a printf()
) and see where you end up with. That too is really old test code which has worked for many users, including invariably some on CentOS.
@eddelbuettel
I copy the exe file generated by the test source code to /tmp/conftest
,and then run ldd /tmp/conftest
linux-vdso.so.1 => (0x00007ffddcdf7000)
libprotobuf.so.26 => not found
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f5d09002000)
libstdc++.so.6 => /usr/local/lib64/libstdc++.so.6 (0x00007f5d08c87000)
libm.so.6 => /lib64/libm.so.6 (0x00007f5d08985000)
libgcc_s.so.1 => /usr/local/lib64/libgcc_s.so.1 (0x00007f5d0876d000)
libc.so.6 => /lib64/libc.so.6 (0x00007f5d083ab000)
/lib64/ld-linux-x86-64.so.2 (0x0000557ed5d3b000)
I think the problem is not mutiple version of protobuf but the LD_LIBRARY_PATH
,the program seems do not scan the protobuf install path /usr/local/lib
After set LD_LIBRARY_PATH=/usr/local/lib
I finally install success.