[solved] Cmake build error (and wolfssl error in alpine)

OpenWrt does not compile on Arch Linux.

Steps to reproduce error:

git clone https://git.openwrt.org/openwrt/openwrt.git
cd openwrt
./scripts/feeds update -a
./scripts/feeds install -a
make menuconfig
make

Error:

time: tools/mklibs/compile#0.21#0.24#0.46
make[3]: Entering directory '/home/user/openwrt/tools/libressl'
make[3]: Leaving directory '/home/user/openwrt/tools/libressl'
time: tools/libressl/compile#0.32#0.38#0.58
make[3]: Entering directory '/home/user/openwrt/tools/cmake'
(cd /home/user/openwrt/build_dir/host/cmake-3.12.4/; if [ -x configure ]; then cp -fpR /home/user/openwrt/scripts/config.{guess,sub} /home/user/openwrt/build_dir/host/cmake-3.12.4// && CC="gcc" CFLAGS="-O2 -I/home/user/openwrt/staging_dir/host/include " CXX="g++" CPPFLAGS="-I/home/user/openwrt/staging_dir/host/include " LDFLAGS="-L/home/user/openwrt/staging_dir/host/lib " CONFIG_SHELL="/usr/bin/env bash" MAKEFLAGS="" CXXFLAGS="-O2 -I/home/user/openwrt/staging_dir/host/include "  bash ./configure  --prefix=/home/user/openwrt/staging_dir/host ; fi )
---------------------------------------------
CMake 3.12.4, Copyright 2000-2018 Kitware, Inc. and Contributors
C compiler on this system is: gcc -O2 -I/home/user/openwrt/staging_dir/host/include       
C++ compiler on this system is: g++ -O2 -I/home/user/openwrt/staging_dir/host/include          
Makefile processor on this system is: make
g++ has setenv
g++ has unsetenv
g++ does not have environ in stdlib.h
g++ has stl wstring
g++ has <ext/stdio_filebuf.h>
---------------------------------------------
make[4]: Entering directory '/home/user/openwrt/build_dir/host/cmake-3.12.4/Bootstrap.cmk'
make[4]: 'cmake' is up to date.
make[4]: Leaving directory '/home/user/openwrt/build_dir/host/cmake-3.12.4/Bootstrap.cmk'
loading initial cache file /home/user/openwrt/build_dir/host/cmake-3.12.4/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!
See also "/home/user/openwrt/build_dir/host/cmake-3.12.4/CMakeFiles/CMakeOutput.log".
See also "/home/user/openwrt/build_dir/host/cmake-3.12.4/CMakeFiles/CMakeError.log".
---------------------------------------------
Error when bootstrapping CMake:
Problem while running initial CMake
---------------------------------------------
make[3]: *** [Makefile:36: /home/user/openwrt/build_dir/host/cmake-3.12.4/.configured] Error 11
make[3]: Leaving directory '/home/user/openwrt/tools/cmake'
time: tools/cmake/compile#20.42#6.83#26.87
make[2]: *** [tools/Makefile:155: tools/cmake/compile] Error 2
make[2]: Leaving directory '/home/user/openwrt'
make[1]: *** [tools/Makefile:151: /home/user/openwrt/staging_dir/target-mipsel_24kc_musl/stamp/.tools_compile_yynyyyyynyyyyynyynnyyyynyyyyyyyyyyyyyyynyynynnyyynnyy] Error 2
make[1]: Leaving directory '/home/user/openwrt'
make: *** [/home/user/openwrt/include/toplevel.mk:218: world] Error 2

I have worked around the problem before by reverting patches for tools/cmake back to "ools/cmake: Update to 3.11.0". But now it becomes to much of a problem.

Some more detailed host infos:

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --enable-multilib --disable-werror --enable-checking=release --enable-default-pie --enable-default-ssp --enable-cet=auto
Thread model: posix
gcc version 8.2.1 20180831 (GCC) 

$ gdb -v
GNU gdb (GDB) 8.2
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

$ cmake --version
cmake version 3.12.3

CMake suite maintained and supported by Kitware (kitware.com/cmake).

Does a vanilla version of cmake build? Looking at the package repo it doesn't look like there are any workarounds.

@diizzy indeed, vanilla cmake-3.12.4 throws the same error!

The Arch Linux cmake package definition calls ./bootstrap, but this also gives the same error as ./configure.
The arch package does not seem to apply any patches.

https://git.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/cmake&id=500a7dce9e5b74e7e4f32aef65a4b568dc4c9ffd

For the record, this cmake change is the cause: https://gitlab.kitware.com/cmake/cmake/commit/fd4fd9a276126a1b1044d57a064c3b8201a91a33

It compiled just fine on Alpine just a few weeks ago and Arch Linux doesn't seem to do anything special for cmake... https://git.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/cmake

I had this problem on arch linux and void linux. Looks I'm haunted. :>

...just switch to something that works? :wink:

@mwarning
FWIW, my quick notes for Alpine Linux 3.8.2

Default install (Extended)

apk add git build-base bash ncurses-dev perl tar findutils patch coreutils gawk grep unzip bzip2 wget python2-dev linux-headers curl diffutils bsd-compat-headers less diffutils

I created a docker container for the purpose of building openwrt: https://github.com/mwarning/docker-openwrt-builder

That works too, I wanted to avoid the rather large Debian install

alpine linux gives me "./configure: line 2: syntax error: unterminated quoted string" when building openwrt (in package wolfssl).
See https://github.com/mwarning/docker-openwrt-builder/tree/alpine

Heh, interesting... I'll try to have a look at it later if time allows

@mwarning
master builds just fine for me on Alpine

What exactly did you do?

This is what I did:

git clone -b alpine https://github.com/mwarning/docker-openwrt-builder.git
cd docker-openwrt-builder
docker build -t openwrt_alpine_builder .

mkdir ~/mybuild
docker run -v ~/mybuild:/home/user/build -it openwrt_alpine_builder /bin/bash

git clone -b openwrt-18.06 https://git.openwrt.org/openwrt/openwrt.git
cd openwrt

./scripts/feeds update -a
./scripts/feeds install -a

make menuconfig # I selected "8devices Lima"
make -j4

This gives an error. I restart with "make V=s". This gives me:

configure: WARNING: unrecognized options: --disable-nls
configure: loading site script /home/user/build/openwrt/include/site/mips
./configure: line 2: syntax error: unterminated quoted string
make[3]: *** [Makefile:178: /home/user/build/openwrt/build_dir/target-mips_24kc_musl/wolfssl-3.15.3-stable/.configured_b7642ce15094029926a9913be4cb199e] Error 2
make[3]: Leaving directory '/home/user/build/openwrt/package/libs/wolfssl'
time: package/libs/wolfssl/compile#12.30#0.59#14.02
make[2]: *** [package/Makefile:109: package/libs/wolfssl/compile] Error 2
make[2]: Leaving directory '/home/user/build/openwrt'
make[1]: *** [package/Makefile:103: /home/user/build/openwrt/staging_dir/target-mips_24kc_musl/stamp/.package_compile] Error 2
make[1]: Leaving directory '/home/user/build/openwrt'
make: *** [/home/user/build/openwrt/include/toplevel.mk:218: world] Error 2

Using the master branch and switching to alpine will fail, as alpine does not have apt.

Default install of extended (no docker image)

apk add git build-base bash ncurses-dev perl tar findutils patch coreutils gawk grep unzip bzip2 wget python2-dev linux-headers curl diffutils bsd-compat-headers less diffutils

Create non root user

cd openwrt
make menuconfig
....

Works great for me, no idea if 18.X works however

OpenWrt master on alpine:edge compiles for me as well (tested with Docker).
But compiling the openwrt-18.0.6 fails.

OpenWrt master and openwrt-18.0.6 both fail using the alpine:edge docker container (same error).

The debian:jessie Docker image compiles OpenWrt master and openwrt-18.06.

Maybe I get around looking into the cmake problem. I was not able to reproduce it with Docker yet.

Btw. your apk line fails finding the the diff package in my alpine:edge docker container (even after apk update).

Ahh, terribly sorry... I made a typo in my notes, it's diffutils not diff.