6

I am using instructions here and here to build OpenWrt in Ubuntu, but I am getting:

make[4]: Entering directory '~/openwrt/build_dir/host/cmake-3.11.1/Bootstrap.cmk'
make[4]: 'cmake' is up to date.
make[4]: Leaving directory '~/openwrt/build_dir/host/cmake-3.11.1/Bootstrap.cmk'
loading initial cache file ~/openwrt/build_dir/host/cmake-3.11.1/Bootstrap.cmk/InitialCacheFlags.cmake
CMake Error at CMakeLists.txt:92 (message):
  The C++ compiler does not support C++11 (e.g.  std::unique_ptr).


-- Configuring incomplete, errors occurred!

There was a solution to a similar problem here. However, it is not clear to me which CMakeLists.txt file is the 'root' in my case. I am not seeing much on the OpenWrt forums (or search engines in general) about this fail.

The impression I get is that the CMake installation is downloaded by the OpenWrt builder itself, as I do not have CMake installed and installing CMake resolved nothing.

Tried checking out latest OpenWrt v18.06.2. When that failed to build I deleted the cloned directory and tried v18.06.0-rc2. There was no improvement.

I also tried

export CMAKE_CXX_STANDARD=11

before running 'make', but it did not resolve the issue.

The state of my g++ install:

g++ -v

Output:

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.3.0-27ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04)

Well, that's five hours, and I'm out of ideas. Could this be a misconfiguration or a bug on the developer end?

If a misconfiguration, what could be set up wrong?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
user515655
  • 989
  • 2
  • 10
  • 24
  • 1
    g++ accepts command line options to enable support of more recent standards. For example `g++ -std=c++11`. AFAIK, it doesn't check environment variables to enable similar things. You need to configure your build script to provide those command line options. The default "dialect" depends on gcc/g++ version, but tends to default to stability rather than being the latest (e.g. it's a fair bet that a gcc version dated 2018 will default to supporting C++14 or even earlier, rather than C++17 - so using C++17 requires you to supply the needed command line option). – Peter Apr 20 '19 at 10:59
  • @Peter Thanks for the input but it's not even my make script - it's OpenWRTs - and it completes on a fresh VM install of the same OS Version with the same packages. Something is broken in my build environment and I'm baffled as to where it is. I even reinstalled all of my dev packages, no improvement. – user515655 Apr 22 '19 at 09:35

5 Answers5

5

My solution is simply:

I copied the CMake source code to my system drive. If you make CMake on a remote harddrive it will fail and error just like above.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Nicholas Jela
  • 2,540
  • 7
  • 24
  • 40
  • This turned out to be the issue. I use an NFS-mounted home directory. Rebuilding on a local directory worked. – user515655 May 13 '23 at 13:18
1

My bad experience could help others. I have GCC 7.4.0. On the same machine, I didn't had any problem configuring my package. One day I decided to build a optimized version,

export CXXFLAGS=O3

configure
... many lines ignored
checking whether g++ supports C++11 features by default... no
checking whether g++ supports C++11 features with -std=c++11... no
checking whether g++ supports C++11 features with +std=c++11... no
checking whether g++ supports C++11 features with -h std=c++11... no
checking whether g++ supports C++11 features with -std=c++0x... no
checking whether g++ supports C++11 features with +std=c++0x... no
checking whether g++ supports C++11 features with -h std=c++0x... no
configure: error: *** A compiler with support for C++11 language features is required.

Note: after doing export CXXFLAGS="-O3", my problem went away. The typo is missing the dash. I hope this could help many others. Most difficulties are caused by subtle mistake we made.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Kemin Zhou
  • 6,264
  • 2
  • 48
  • 56
1

I'm facing exactly the same problem in a gentoo common x86 PC (not cross build),so it must be their bug, not your fault nor mine.

[1] gentoo bug - https://bugs.gentoo.org/691544, [2] your proposed solution -https://thelinuxcluster.com/2021/10/01/the-c-compiler-does-not-support-c11-during-bootstrap-for-cmake/

Therefore, although there may be some working around upon setting c flags to "-O3" and mounting points to local drive or something in the form of "mount -o remount /", I personally recomend patching the make file not to bugously try to check these C++11 features.

In cmake-3.21.4, I removed ten lines from the file 'CMakeLists.txt', namely 99 ~ 109. Here's the .diff file of

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9944ea4c..195fd842 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -96,17 +96,7 @@ if(NOT DEFINED CMAKE_CXX_STANDARD AND NOT CMake_NO_CXX_STANDARD)
     endif()
   endif()
 endif()
-if(NOT CMake_TEST_EXTERNAL_CMAKE)
-  # include special compile flags for some compilers
-  include(CompileFlags.cmake)
-
-  # check for available C++ features
-  include(${CMake_SOURCE_DIR}/Source/Checks/cm_cxx_features.cmake)
 
-  if(NOT CMake_HAVE_CXX_UNIQUE_PTR)
-    message(FATAL_ERROR "The C++ compiler does not support C++11 (e.g. std::unique_ptr).")
-  endif()
-endif()
 
 # Inform STL library header wrappers whether to use system versions.
 configure_file(${CMake_SOURCE_DIR}/Utilities/std/cmSTL.hxx.in

Of course, only do so if you're sure your compiler supports C+11 (like any gcc from late 2000's onwards).

Marcelo Ruggeri
  • 1,939
  • 1
  • 17
  • 10
  • What are "c flags"? Compiler flags? GCC flags? Environment variable [`CXXFLAGS`](https://cmake.org/cmake/help/latest/envvar/CXXFLAGS.html#envvar:CXXFLAGS)? Environment variable [`CFLAGS`](https://cmake.org/cmake/help/latest/envvar/CFLAGS.html?)? Something else? – Peter Mortensen May 10 '23 at 13:21
  • Re *"last but least"*: Do you mean *"[last but* ***not*** *least](https://en.wiktionary.org/wiki/last_but_not_least#Adverb)"*? – Peter Mortensen May 10 '23 at 13:26
0

I get the same error (on a Linux desktop, unrelated to OpenWrt) when having MAKEFLAGS set (to "-j8"). This is because of the warning gmake[1]: warning: -jN forced in submake: disabling jobserver mode. which makes the CMake test think something went wrong. Duh. Workaround: unset MAKEFLAGS.

In any case, the way to investigate this error is to read CMakeFiles/CMakeError.log.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
David Faure
  • 1,836
  • 15
  • 19
0

Try the solution

vim /etc/profile
export LC_ALL=C
unset LANGUAGE
source /etc/profile

if you find the setlocate warning.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 10 '23 at 11:37