'Installing Mesos on ubuntu 20.04 causing makefile issue

I was trying to install mesos latest version(1.9.0) on the ubuntu 20.04 using Dockefile.

FROM ubuntu:20.04

ENV MESOS_VERSION 1.9.0
ENV MESOS_ARTIFACT_FILENAME mesos-${MESOS_VERSION}.tar.gz

# Install Mesos dependencies
# Compile and install Mesos (compilation phase uses 6 threads for speed up this process)
# Uninstall Mesos build dependencies
RUN apt-get update && apt-get install -y \
    openjdk-8-jdk \
    python-dev \
    libcurl4-nss-dev \
    libsasl2-dev \
    libsasl2-modules \
    maven \
    libapr1-dev \
    libsvn-dev \
    zlib1g-dev 
RUN wget http://archive.apache.org/dist/mesos/${MESOS_VERSION}/${MESOS_ARTIFACT_FILENAME} \
  && tar -xf ${MESOS_ARTIFACT_FILENAME} 
RUN cd mesos-${MESOS_VERSION} \
  && mkdir build \
  && cd build \
  && ../configure \ 
  && make -j 6 \
  && cp src/.libs/libmesos-${MESOS_VERSION}.so /usr/local/lib/libmesos-${MESOS_VERSION}.so \
  && cd ../.. \
  && rm -rf mesos-${MESOS_VERSION} ${MESOS_ARTIFACT_FILENAME} \
  && apt-get purge -y \
   openjdk-8-jdk \
    python-dev \
    libsasl2-dev \
    libsasl2-modules \
    maven \
   zlib1g-dev \
  && apt-get clean \
  && apt-get autoremove -y \
  && rm -rf /var/lib/apt/lists/*

RUN ln -s /usr/local/lib/libmesos-${MESOS_VERSION}.so /usr/lib/libmesos.so

It is working till configure command

../configure \ 
      && make -j 6 \

After configuring, the make commad is throwing out different errors. One of them is:

ar: 'u' modifier ignored since 'D' is the default (see 'U')

rc/core/lib/gpr/log_linux.cc:42:13: error: ambiguating new declaration of 'long int gettid()'
   42 | static long gettid(void) { return syscall(__NR_gettid); }
      |             ^~~~~~
In file included from /usr/include/unistd.h:1170,
                 from src/core/lib/gpr/log_linux.cc:40:
/usr/include/x86_64-linux-gnu/bits/unistd_ext.h:34:16: note: old declaration '__pid_t gettid()'
   34 | extern _pid_t gettid (void) _THROW;
      |                ^~~~~~
src/core/lib/gpr/log_linux.cc:42:13: warning: 'long int gettid()' defined but not used [-Wunused-function]
   42 | static long gettid(void) { return syscall(__NR_gettid); }
      |             ^~~~~~
make[4]: *** [Makefile:2650: /mesos-1.9.0/build/3rdparty/grpc-1.10.0/objs/opt/src/core/lib/gpr/log_linux.o] Error 1

What I am doing wrong here in building mesos-spark-docker image for seahorse?? Please help me.



Solution 1:[1]

You are masking the real problems from make by running the make -j 6. This will cause the make to run in 6 threads and all of them will output at the same time. Move to -j 1 to be able to troubleshoot.

To troubleshoot this type of problems, you need to stop the build before the stage it's failing. If you are using buildx, check this SO post how to create stages and intermediate images. Once you have the intermediate stage you will create container and to the manual steps and resolve problem-by-problem.

To check your issue, I build the image until the ./configure and create container to troubleshoot further. What I saw is that there are prerequisites that are missing such as build-essential, autogen, autoconf. I even needed the default-jdk, but this can be path issue since I see that you are installing openjdk-8-jdk. There are still issues with missing libraries, so you will need to continue from this point.

Solution 2:[2]

gcc version 10+ will give you this error, you can install gcc-9 g++-9 and change your current gcc and g++ to 9

sudo apt install gcc-9 g++-9

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 90 --slave /usr/bin/g++ g++ /usr/bin/g++-9 --slave /usr/bin/gcov gcov /usr/bin/gcov-9 

Solution 3:[3]

i find the method maybe Deprecated?replace with sys_gettid() in log_linux.cc.

Solution 4:[4]

This is a problem related to the declaration of the function in the source code maybe it is not compatible with newer version of compilers.We can edit the log_linux.cc file(if you cannot find the file use command locate "log_linux.cc" this will list out the file path copy that and use any text editor to edit it.in the file replace long gettid(void) with sys_gettid().and this should solve your problem.It solved mine.Cheers.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jordanvrtanoski
Solution 2 Arun VC
Solution 3 elpsy kongroo
Solution 4 Navodit Yadav