Search code examples
c++ubuntumesos

Error: unrecognized command line option ‘-Wno-invalid-source-encoding’ [-Werror] within building Mesos


My operating system is Ubuntu 18.10. I follow these steps on three nodes: To install Mesos I did these steps one by one without any errors, except every node has already had Open JDK 8, so I did not install Open JDK 8 again.

   sudo apt-get update
   sudo apt-get install -y tar wget git
   sudo apt-get install -y openjdk8-jdk (I did not do that)
   sudo apt-get install -y autoconf libtool
   sudo apt-get -y install build-essential python-dev python-six python- 
   virtualenv libcurl4-nss-dev libsasl2-dev libsasl2-modules maven 
   libapr1-dev libsvn-dev zlib1g-dev iputils-ping
   

The problem is begin when I want to build Mesos. I did these steps for that:

cd mesos-1.7.0
./bootstrap
mkdir build
cd build
../configure
make

My IP addresses are 150.20.11.137,150.20.11.134,150.20.11.157. I downloaded Mesos package on all of them and extracted in the same path. I did <../configure> on every node without any problems, but when I run "make" I got this error on each node:

third_party/cares/cares/ares_init.c: In function ‘ares_dup’: third_party/cares/cares/ares_init.c:301:17: error: argument to ‘sizeof’ in ‘strncpy’ call is the same expression as the source; did you mean to use the size of the destination? [-Werror=sizeof-pointer- memaccess]

       sizeof(src->local_dev_name));
             ^

third_party/cares/cares/ares_init.c: At top level:

cc1: error: unrecognized command line option ‘-Wno-invalid-source- encoding’ [-Werror] cc1: all warnings being treated as errors

make[4]: *** [Makefile:2635: /home/spark/mesos- 1.7.0/build/3rdparty/grpc- 1.10.0/objs/opt/third_party/cares/cares/ares_init.o] Error 1

make[4]: Leaving directory '/home/spark/mesos- 1.7.0/build/3rdparty/grpc-1.10.0'

make[3]: *** [Makefile:1446: grpc-1.10.0-build-stamp] Error 2

make[3]: Leaving directory '/home/spark/mesos-1.7.0/build/3rdparty'

make 2]: *** [Makefile:1035: all-recursive] Error 1

make[2]: Leaving directory '/home/spark/mesos-1.7.0/build/3rdparty'

make[1]: *** [Makefile:765: all] Error 2

make[1]: Leaving directory '/home/spark/mesos-1.7.0/build/3rdparty'

make: *** [Makefile:768: all-recursive] Error 1


Solution

  • Problem solved. The problem was because of GCC version. GCC version in Ubuntu 18.10 is 8.2.0. I installed gcc-5 and g++-5 with this instruction:

     sudo add-apt-repository ppa:ubuntu-toolchain-r/test
     sudo apt-get update
     sudo apt-get install gcc-5 g++-5
    

    Then to choose GCC version that I want, I have to install "update-alternatives" for gcc. Therefore, I run these commands:

    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 500 --slave 
    /usr/bin/g++ g++ /usr/bin/g++-5
    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave 
    /usr/bin/g++ g++ /usr/bin/g++-8
    

    After that I chose gcc-5 with this command :

    sudo update-alternatives --config gcc
    

    Moreover, I had an error related to OpenSSL; then I installed it via this command:

    sudo apt-get install libssl-dev
    

    After those modifications, I started to install Mesos and it installed without any errors. I hope this illustration was helpful for others.