Errors when building glibc on Alpine Linux - docker

I am trying to install glibc on Alpine Linux. I am running Alpine Linux in the Docker. Here are the steps I am using:
docker pull alpine
docker run -it alpine /bin/sh
apk add --no-cache make gcc linux-headers bsd-compat-headers gawk bison binutils coreutils diffutils gettext bash grep sed texinfo perl
wget https://ftp.gnu.org/gnu/glibc/glibc-2.28.tar.gz
tar -xzf glibc-2.28.tar.gz
cd glibc-2.28
mkdir glibc-build
cd glibc-build
../configure --prefix=/usr \
--disable-profile --enable-add-ons \
--libexecdir=/usr/bin --with-headers=/usr/include \
--enable-static-pie
cat > /etc/ld.so.conf << "EOF"
# Begin /etc/ld.so.conf
/usr/local/lib
/opt/lib
# End /etc/ld.so.conf
EOF
make
make install
I am getting following error on 11th step:
/usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lssp_nonshared
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:129: /glibc-2.28/glibc-build/elf/sotruss-lib.so] Error 1
make[2]: Leaving directory '/glibc-2.28/elf'
make[1]: *** [Makefile:258: elf/subdir_lib] Error 2
make[1]: Leaving directory '/glibc-2.28'
make: *** [Makefile:9: all] Error 2
If I try to add --disable-shared flag than another errors occur.
The error could be solved by adding libc-dev with the following command: apk add --no-cache libc-dev. But this way I would have two C libraries but I need my application to use glibc specifically.
UPDATE
If I run apk add --no-cache libc-dev, make command passes successfully but make install fails with the following error:
Execution of gcc failed!
The script has found some problems with your installation!
Please read the FAQ and the README file and check the following:
Did you change the gcc specs file (necessary after upgrading from
Linux libc5)?
Are there any symbolic links of the form libXXX.so to old libraries?
Links like libm.so -> libm.so.5 (where libm.so.5 is an old library) are wrong,
libm.so should point to the newly installed glibc file - and there should be
only one such link (check e.g. /lib and /usr/lib)
You should restart this script from your build directory after you've
fixed all problems!
Btw. the script doesn't work if you're installing GNU libc not as your
primary library!

Eventually, I changed few steps in order to build glibc on Alpine Linux.
Here are the steps that worked for me:
docker pull alpine
docker run -it alpine /bin/sh
wget https://ftp.gnu.org/gnu/glibc/glibc-2.28.tar.gz
tar -xzf glibc-2.28.tar.gz
cd glibc-2.28
mkdir glibc-build
cd glibc-build
apk add --no-cache make gcc gawk bison linux-headers libc-dev
../configure --prefix=/usr \
--disable-profile --enable-add-ons \
--libexecdir=/usr/lib --with-headers=/usr/include \
--without-cvs --enable-static-pie
cat > /etc/ld.so.conf << "EOF" # Begin /etc/ld.so.conf
/usr/local/lib
/opt/lib
/usr/lib
/usr/lib64
/usr/libexec
# End /etc/ld.so.conf
EOF
make
make install
I hope these steps will work for everybody else also.

Installing musl-dev should get you past that build error, too, so you'll be building glibc against musl.
The musl-dev package has its own /usr/lib/libssp_nonshared.a:
https://pkgs.alpinelinux.org/contents?file=libssp_nonshared.a&path=&name=musl-dev&branch=v3.8&repo=main&arch=x86_64

Related

makefile:513: pod/perlintern.pod Segmentation fault (core dumped) When installing specific perl version in dockerfile

I am trying to install perl 5.12.3 onto a Fedora 33 Docker image in my dockerfile however when I attempt to build the image I am faced with this error:
/bin/sh: line 1: /dev/tty: No such device or address
make[1]: Leaving directory '/'
make[1]: [makefile:964: minitest] Error 1 (ignored)
./miniperl -Ilib autodoc.pl
make: *** [makefile:513: pod/perlintern.pod] Segmentation fault (core dumped)
This is how I am attempting to install it:
RUN wget https://www.cpan.org/authors/id/R/RJ/RJBS/perl-5.12.3.tar.gz
RUN tar -xzf perl-5.12.3.tar.gz
RUN perl-5.12.3/Configure -Dmksymlinks -des -Dprefix=/usr/local/ -d y &&\
make && \
make test && \
make install
RUN perl -v
I guess that the problem is that docker is running the build context with no stdin or tty. Does anyone know a fix for this? I tried to install perlbrew instead to accomplish this but that was already proving to have quite a few of its own issues. Thank you for any help or advice. I am open to any other methods to installing perl 5.12.3 in the image.
I was able to install Perl version 5.12.4 with perlbrew like this (building fedora:33 docker image from my Ubuntu 21.04 laptop):
Dockerfile:
FROM fedora:33
SHELL ["/bin/bash", "-c"]
RUN yum -y update \
&& yum -y install gcc gcc-c++ make curl \
vim wget zlib-devel openssl-devel bzip2 patch \
perl-CPAN perl-App-cpanminus
ARG user=root
ARG home=/$user
WORKDIR $home
USER $user
COPY entrypoint.sh .
RUN chmod +x entrypoint.sh
ENTRYPOINT ["./entrypoint.sh"]
entrypoint.sh:
curl -L https://install.perlbrew.pl | SHELL=/bin/bash bash
echo 'export PERLBREW_ROOT=$HOME/perl5/perlbrew' >> .bashrc
echo 'source $PERLBREW_ROOT/etc/bashrc' >> .bashrc
export PERLBREW_ROOT=$HOME/perl5/perlbrew
source $PERLBREW_ROOT/etc/bashrc
perlbrew install --notest --noman perl-5.12.4
perlbrew install-cpanm
perlbrew switch perl-5.12.4
perl --version
exec bash

undefined: grpc.SupportPackageIsVersion7 grpc.ServiceRegistrar

Inside docker, it seems that I cannot compile my gRPC micro-service due to this error:
Step 4/9 : RUN make build
---> Running in ceb6e4d0e19b
protoc --version
libprotoc 3.12.4
protoc --proto_path=pkg/proto/notify/ --go_out=pkg/proto/notify/ --go-grpc_out=pkg/proto/notify/ --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative notify.proto
plugin versions reported in *.pb.go files:
./pkg/proto/notify/notify.pb.go:// protoc-gen-go v1.25.0-devel
./pkg/proto/notify/notify.pb.go:// protoc v3.12.4
go build -o notify-service *.go
go: downloading github.com/lib/pq v1.7.0
go: downloading google.golang.org/grpc v1.27.0
go: downloading github.com/jinzhu/gorm v1.9.14
go: downloading github.com/aws/aws-sdk-go v1.33.7
go: downloading github.com/go-kit/kit v0.10.0
go: downloading google.golang.org/protobuf v1.25.0
go: downloading github.com/go-co-op/gocron v0.2.1
go: downloading github.com/sirupsen/logrus v1.6.0
go: downloading github.com/golang/protobuf v1.4.2
go: downloading github.com/matcornic/hermes/v2 v2.1.0
go: downloading github.com/jhillyerd/enmime v0.8.1
go: downloading golang.org/x/sys v0.0.0-20200523222454-059865788121
go: downloading github.com/jaytaylor/html2text v0.0.0-20190408195923-01ec452cbe43
go: downloading github.com/vanng822/go-premailer v0.0.0-20191214114701-be27abe028fe
go: downloading github.com/imdario/mergo v0.3.9
go: downloading github.com/russross/blackfriday/v2 v2.0.1
go: downloading github.com/jinzhu/inflection v1.0.0
go: downloading github.com/Masterminds/sprig v2.16.0+incompatible
go: downloading golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2
go: downloading github.com/PuerkitoBio/goquery v1.5.1
go: downloading github.com/pkg/errors v0.9.1
go: downloading golang.org/x/text v0.3.2
go: downloading github.com/vanng822/css v0.0.0-20190504095207-a21e860bcd04
go: downloading github.com/shurcooL/sanitized_anchor_name v1.0.0
go: downloading github.com/aokoli/goutils v1.0.1
go: downloading google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013
go: downloading gopkg.in/gormigrate.v1 v1.6.0
go: downloading github.com/gorilla/css v1.0.0
go: downloading github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf
go: downloading github.com/andybalholm/cascadia v1.1.0
go: downloading github.com/gogs/chardet v0.0.0-20150115103509-2404f7772561
go: downloading golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37
go: downloading github.com/olekukonko/tablewriter v0.0.1
go: downloading github.com/cention-sany/utf7 v0.0.0-20170124080048-26cad61bd60a
go: downloading github.com/huandu/xstrings v1.2.0
go: downloading github.com/Masterminds/semver v1.4.2
go: downloading github.com/google/uuid v1.1.1
go: downloading github.com/mattn/go-runewidth v0.0.4
go: downloading github.com/go-logfmt/logfmt v0.5.0
go: downloading github.com/jmespath/go-jmespath v0.3.0
# gitlab.com/kuecr/fero/backend/notify/pkg/proto/notify
pkg/proto/notify/notify_grpc.pb.go:14:11: undefined: grpc.SupportPackageIsVersion7
pkg/proto/notify/notify_grpc.pb.go:71:30: undefined: grpc.ServiceRegistrar
make: *** [Makefile:14: build] Error 2
ERROR: Service 'notify' failed to build: The command '/bin/sh -c make build' returned a non-zero code: 2
make: *** [Makefile:64: build/notify] Error 1
However, outside of Docker the thing is run and compile with success.
This is my base Docker image:
RG go_version
FROM golang:${go_version}-buster
ARG pb_version
RUN apt-get update && apt-get install -y build-essential curl git wget unzip && rm -rf /var/lib/apt/lists/*
RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v${pb_version}/protobuf-cpp-${pb_version}.zip && \
unzip protobuf-cpp-${pb_version}.zip && \
cd protobuf-${pb_version} && \
./configure && \
make && \
make check && \
make install && \
ldconfig && \
cd ../ && \
rm -rf protobuf-*
RUN go get github.com/githubnemo/CompileDaemon && \
go get github.com/golang/protobuf/protoc-gen-go && \
go get github.com/grpc/grpc-go/cmd/protoc-gen-go-grpc && \
go install github.com/golang/protobuf/protoc-gen-go && \
go install github.com/grpc/grpc-go/cmd/protoc-gen-go-grpc
This is the Docker image where the compilation is done:
FROM registry.gitlab.com/kuecr/devops/go-protobuf-base:1.14 as base
WORKDIR /app
COPY . .
RUN make build
FROM base as testing
ENTRYPOINT ["make", "test"]
FROM base as production
RUN make build
ENTRYPOINT CompileDaemon -log-prefix=false -build="go build -o notify-service" -command="./notify-service"
My docker and docker-compose and protoc versions:
✖ docker --version && docker-compose --version
Docker version 19.03.12-ce, build 48a66213fe
docker-compose version 1.26.2, build unknown
➜ protoc --version
libprotoc 3.12.4
This is what happens when I ran make build on my machine:
➜ make build
protoc --version
libprotoc 3.12.4
protoc --proto_path=pkg/proto/notify/ --go_out=pkg/proto/notify/ --go-grpc_out=pkg/proto/notify/ --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative notify.proto
plugin versions reported in *.pb.go files:
./pkg/proto/notify/notify.pb.go:// protoc-gen-go v1.25.0
./pkg/proto/notify/notify.pb.go:// protoc v3.12.4
go build -o notify-service *.go
I'm using Golang 1.15 while the Docker image use 1.14.
Already they have provided this solution in their documentation here. I had the same issue and here is my solution:
go get -u github.com/golang/protobuf/{proto,protoc-gen-go}
go get -u google.golang.org/grpc
protoc --go_out=plugins=grpc:. *.proto
Here is the explanation if you are not using Go modules:
The gist of this error is that the version of binary used to generate the code isn't compatible with the current version of code. A quick and easy solution would be to try updating the protoc-gen-go compiler and the gRPC library to the latest version.
go get -u github.com/golang/protobuf/protoc-gen-go
then regen the proto
heres a link to a reddit thread that discusses the issue
grpc.SupportPackageIsVersion is used to track the version of the protobuf generated code and is different from the grpc release version.
In short, Your generated GRPC code structure is newer than your google.golang.org/grpc package. So you must update your go grpc package to the new one.
SupportPackageIsVersion7 support after 1.32.0 versions. and they support old versions with go version >= 1.12
to update it you should
first, remove the current one, to find where it stored, you can use the echo $PATH command to find out where this file is. then remove it.
second, install the new one, for installing it you can run this command.
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc
Note If you have any problem to get it, use this command instead,
go get -u github.com/golang/protobuf/protoc-gen-go
after the update, you must edit your go.mod file.
change this line:
google.golang.org/grpc v1.21.1
to
google.golang.org/grpc v1.32.0// or newer
Note: You can find last releases from this URL
You can find versions supports of the package at the end of rpc_util.go in constants.
something like this:
const (
SupportPackageIsVersion3 = true
SupportPackageIsVersion4 = true
SupportPackageIsVersion5 = true
SupportPackageIsVersion6 = true
SupportPackageIsVersion7 = true
)
I solved this problem by specifying grpc-go version to v1.33.0-dev, but this version is not included in ver v1.31.1.
Even with go get -u my version for some reason didn't get updated to the last one. I had to update google.golang.org/grpc v1.27.0 to google.golang.org/grpc v1.34.0 (latest version attow) in my go.mod manually. Then it worked.
Complementary to #Jay Lane answer, I want to share the Dockerfile configuration I put together:
ARG go_version
FROM golang:${go_version}-buster
ARG pb_version
ARG grpc_version
ARG gen_version
ARG compile_daemon_version
ARG dlv_version
RUN apt-get update && apt-get install -y build-essential curl git wget unzip && rm -rf /var/lib/apt/lists/*
RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v${pb_version}/protobuf-cpp-${pb_version}.zip && \
unzip protobuf-cpp-${pb_version}.zip && \
cd protobuf-${pb_version} && \
./configure && \
make && \
make check && \
make install && \
ldconfig && \
cd ../ && \
rm -rf protobuf-*
WORKDIR /tmp
RUN GO111MODULE=on go get google.golang.org/protobuf/cmd/protoc-gen-go#v${gen_version} && \
GO111MODULE=on go get google.golang.org/grpc#v${grpc_version} && \
GO111MODULE=on go get github.com/githubnemo/CompileDaemon#v${compile_daemon_version} && \
GO111MODULE=on go get github.com/go-delve/delve/cmd/dlv#v${dlv_version}
RUN git clone https://github.com/grpc/grpc-go.git && \
cd grpc-go/cmd/protoc-gen-go-grpc && \
git checkout v${grpc_version} && go install . && \
cd /tmp && rm -rf grpc-go
WORKDIR /go
and I also updated google.golang.org/grpc to v1.31.1.
EDIT:
This is the Makefile I use to help me build this image, is included for the sake of completeness:
GO_VERSION=1.14
PROTOBUF_VERSION=3.12.4
GEN_VERSION=1.25.0
GRPC_VERSION=1.31.1
COMPILE_DAEMON_VERSION=1.2.1
DLV_VERSION=1.5.0
push: build
docker push registry.gitlab.com/kuecr/devops/go-protobuf-base:$(GO_VERSION)
build:
docker build \
--build-arg pb_version=$(PROTOBUF_VERSION) \
--build-arg go_version=$(GO_VERSION) \
--build-arg gen_version=$(GEN_VERSION) \
--build-arg grpc_version=$(GRPC_VERSION) \
--build-arg compile_daemon_version=$(COMPILE_DAEMON_VERSION) \
--build-arg dlv_version=$(DLV_VERSION) \
-t registry.gitlab.com/kuecr/devops/go-protobuf-base:$(GO_VERSION) .
history:
docker image history registry.gitlab.com/kuecr/devops/go-protobuf-base:$(GO_VERSION)
sh:
docker run --rm --interactive --tty --entrypoint /bin/sh registry.gitlab.com/kuecr/devops/go-protobuf-base:$(GO_VERSION)

Docker Build SofteWare using Alphine Linux with Error 'install: unrecognized option: strip-program=strip'

I'm building a mosquito docker image, when calling make install meet these error messages 'install: unrecognized option: strip-program=strip', please help, thanks.
install -d /usr/local/lib/
install -s --strip-program=strip libmosquitto.so.1
/usr/local/lib/libmosquitto.so.1
install: unrecognized option: strip-program=strip
BusyBox v1.27.2 (2017-12-12 10:41:50 GMT) multi-call binary.
Usage: install [-cdDsp] [-o USER] [-g GRP] [-m MODE] [-t DIR] [SOURCE]... DEST
Copy files and set attributes
-c Just copy (default)
-d Create directories
-D Create leading target directories
-s Strip symbol table
-p Preserve date
-o USER Set ownership
-g GRP Set group ownership
-m MODE Set permissions
-t DIR Install to DIR
make[1]: *** [Makefile:28: install] Error 1
make[1]: Leaving directory '/usr/local/src/mosquitto-1.4.15/lib'
make: *** [Makefile:38: install] Error 2
Part of My Dockfile:
FROM alpine:3.7
RUN apk add --update --no-cache build-base openssl openssl-dev c-ares-dev util-linux-dev libwebsockets-dev libxslt && \
cd /usr/local && \
mkdir src && \
cd src && \
wget https://mosquitto.org/files/source/mosquitto-1.4.15.tar.gz && \
tar -zxvf mosquitto-1.4.15.tar.gz && \
cd mosquitto-1.4.15 && \
make && make install
Call make the last several result lines:
cc -Wall -ggdb -O2 -c mosquitto_passwd.c -o mosquitto_passwd.o
cc mosquitto_passwd.o -o mosquitto_passwd -lcrypto
make[1]: Leaving directory '/usr/local/src/mosquitto-1.4.15/src'
set -e; for d in man; do make -C ${d}; done
make[1]: Entering directory '/usr/local/src/mosquitto-1.4.15/man'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/usr/local/src/mosquitto-1.4.15/man'
The problem is that you're installing a mosquitto tar.gz with /usr/bin/install version: BusyBox v1.27.2, and your mosquitto's tar.gz downloaded with wget needs /usr/bin/install version from GNU coreutils 8.25 for example, which includes your missing option strip-program.
So, solution is simple: install a mosquitto version for alpine, not for generic Linux:
FROM alpine:3.7
RUN apk add --update --no-cache build-base openssl openssl-dev c-ares-dev util-linux-dev libwebsockets-dev libxslt && \
apk add mosquitto
It'll install version 1.4.15.
EDIT: If you need to install a plugin and compile a generic linux tar.gz, you have to install apk add coreutils
Except for the answer #mulg0r gave me. I found there was another way to solve this. I think this is also useful when someone meets a similar problem. From https://git.alpinelinux.org/cgit/aports/tree/main/mosquitto?h=master this link. the package from alpine Linux. Click the Git repository button, inside that page, this package's build process instructions are there. And some code changes to suit alpine Linux.
For this question, find APKBUILD file from https://git.alpinelinux.org/cgit/aports/tree/main/mosquitto?h=master. this line also solved my question:
sed -i -e "s|(INSTALL) -s|(INSTALL)|g" \
-e 's|--strip-program=${CROSS_COMPILE}${STRIP}||' \
*/Makefile */*/Makefile
Above is just comment out --strip-program when excute make install

Building a Docker Image with rstan on rocker/verse

I am planning to run a customized Rstudio with both tidyverse, rmarkdown and rstan pre-installed on Digital Ocean's Docker 17.03.0-ce on 16.04.
On Docker Hub, there is already a pre-built image: Rocker/verse that has tidyverse and rmarkdown functionality. So my plan was to simply get the latest version of Rocker/verse and add a new layer of rstan. I use the dockerfile of jonzelner/rstan and jrnold/rstan and update them as below:
FROM rocker/verse:latest
# Install essentials
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
clang-3.6
# Global site-wide config
RUN mkdir -p $HOME/.R/ \
&& echo "\nCXX=clang++ -ftemplate-depth-256\n" >> $HOME/.R/Makevars \
&& echo "CC=clang\n" >> $HOME/.R/Makevars
# Install rstan
RUN install2.r --error \
inline \
RcppEigen \
StanHeaders \
rstan \
KernSmooth
# Config for rstudio user
RUN mkdir -p /home/rstudio/.R/ \
&& echo "\nCXX=clang++ -ftemplate-depth-256\n" >> /home/rstudio/.R/Makevars \
&& echo "CC=clang\n" >> /home/rstudio/.R/Makevars \
&& echo "CXXFLAGS=-O3\n" >> /home/rstudio/.R/Makevars \
&& echo "\nrstan::rstan_options(auto_write = TRUE)" >> /home/rstudio/.Rprofile \
&& echo "options(mc.cores = parallel::detectCores())" >> /home/rstudio/.Rprofile
# Install loo
RUN install2.r --error \
matrixStats \
loo
However, my attempt to build this image (docker build -t image_name .) ended in error. The results are provided below:
Sending build context to Docker daemon 2.56 kB
Step 1/6 : FROM rocker/verse:latest
---> 7ad7d994bffd
Step 2/6 : RUN apt-get update && apt-get install -y --no-install-recommends clang-3.6
---> Using cache
---> 77473c759438
Step 3/6 : RUN mkdir -p $HOME/.R/ && echo "\nCXX=clang++ -ftemplate-depth-256\n" >> $HOME/.R/Makevars && echo "CC=clang\n" >> $HOME/.R/Makevars
---> Using cache
---> a5b06d28b9fe
Step 4/6 : RUN install2.r --error inline RcppEigen StanHeaders rstan KernSmooth
---> Running in 86b52d5a76f3
trying URL 'https://cran.rstudio.com/src/contrib/inline_0.3.14.tar.gz'
Content type 'unknown' length 18002 bytes (17 KB)
==================================================
downloaded 17 KB
* installing *source* package ‘inline’ ...
** package ‘inline’ successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (inline)
The downloaded source packages are in
‘/tmp/downloaded_packages’
trying URL 'https://cran.rstudio.com/src/contrib/RcppEigen_0.3.2.9.0.tar.gz'
Content type 'unknown' length 1209128 bytes (1.2 MB)
==================================================
downloaded 1.2 MB
* installing *source* package ‘RcppEigen’ ...
** package ‘RcppEigen’ successfully unpacked and MD5 sums checked
** libs
clang++ -ftemplate-depth-256 -I/usr/local/lib/R/include -DNDEBUG -I/usr/local/include -I"/usr/local/lib/R/site-library/Rcpp/include" -I../inst/include -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c RcppEigen.cpp -o RcppEigen.o
/bin/bash: clang++: command not found
/usr/local/lib/R/etc/Makeconf:141: recipe for target 'RcppEigen.o' failed
make: *** [RcppEigen.o] Error 127
ERROR: compilation failed for package ‘RcppEigen’
* removing ‘/usr/local/lib/R/site-library/RcppEigen’
Error in install.packages(pkgs = f, lib = lib, repos = if (isMatchingFile(f)) NULL else rep, :
installation of package ‘RcppEigen’ had non-zero exit status
The command '/bin/sh -c install2.r --error inline RcppEigen StanHeaders rstan KernSmooth' returned a non-zero code: 1
Some similar questions about a package having non-zero exit status have to do with memory, so I tried to increase the Docker memory on my local machine, but still no luck. Is there any thing I can do to successfully build this image?
As you see in the error output, the installation process cannot find the compiler:
/bin/bash: clang++: command not found
Be aware that this is the output from trying to install clang-3.6 in a rocker/verse container:
root#8ea0d98e67c3:/# apt-get install -y --no-install-recommends clang-3.6
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'python-clang-3.6' for regex 'clang-3.6'
0 upgraded, 0 newly installed, 0 to remove and 15 not upgraded.
It appears that this image doesn't come with Clang 3.6 in its repositories. And this name instead points to python-clang-3.6; Clang bindings for the Python programming language.
Unless you absolutely want 3.6, I would install the plain clang package that points to 3.5, and then re-run the Docker build process.
apt-get install clang

Sudo make install permissions issue on Ubuntu 14.04

I have amended a script from https://github.com/jayrambhia/Install-OpenCV/blob/master/Ubuntu/2.4/opencv2_4_10.sh to try to install OpenCV 2.4.13 onto a vm running Ubuntu 14.04 where I have sudo permission. I'm new to openCV, cmake & make so any help getting this script to work would be appreciated as I have to install it on 20 vm's.
After a few minutes of running the script returns with an error saying can't
/bin/sh: 1: cd: can't cd to /home/myaccount/setups/OpenCV/opencv-2.4.13/build
and
make[2]: *** [3rdparty/libtiff/CMakeFiles/libtiff.dir/depend] Error 2
make[1]: *** [3rdparty/libtiff/CMakeFiles/libtiff.dir/all] Error 2
The last few lines of the output is included below and the script is before that.
Any ideas why the script wont complete successfully or how to correct the permissions issue?
Extra Details
I'm not sure if these are relevant but as I dig into the problem I'll update this section
cmake version 2.8
Makerfile mentions # The shell in which to execute make rules. SHELL
= /bin/sh but my terminal reports echo $0 as bash
when I run make install V=1 it builds 100% but then reports
-- Install configuration: "RELEASE" CMake Error at cmake_install.cmake:36 (FILE): file cannot create directory: /usr/local/include/opencv2. Maybe need administrative privileges
But when I run sudo make install V=1 I get can't cd error above
Adding Shebang #!/bin/bash to the start of my script didn't solve it
Running the script on a fresh ubuntu local machine alows the script to run but I need to get it running on the hosted vm
umask of setups folder (where script runs and creates a directory is 0022 . Permissions for setups folder is 755, group = Domain Users, Owner = myaccount Thats where the source files folder gets created as well as the build folder which is also 755 after it is created
Script
arch=$(uname -m)
if [ "$arch" == "i686" -o "$arch" == "i386" -o "$arch" == "i486" -o "$arch" == "i586" ]; then
flag=1
else
flag=0
fi
echo "Installing OpenCV 2.4.13"
mkdir OpenCV
cd OpenCV
echo "Removing any pre-installed ffmpeg and x264"
sudo apt-get -y remove ffmpeg x264 libx264-dev
echo "Installing unzip"
sudo apt-get -y install unzip
echo "Installing Dependenices"
sudo apt-get -y install libopencv-dev
sudo apt-get -y install build-essential checkinstall cmake pkg-config yasm
sudo apt-get -y install libtiff4-dev libjpeg-dev libjasper-dev
sudo apt-get -y install libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev
sudo apt-get -y install python-dev python-numpy
sudo apt-get -y install libtbb-dev libeigen3-dev
sudo apt-get -y install libqt4-dev libgtk2.0-dev
sudo apt-get -y install libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-core-dev
sudo apt-get -y install x264 v4l-utils ffmpeg
sudo apt-get -y install libgtk2.0-dev
echo "Downloading OpenCV 2.4.13"
if ! [ -f "OpenCV-2.4.13.zip" ]; then
wget -O OpenCV-2.4.13.zip http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.13/opencv-2.4.13.zip/download
fi
echo "Installing OpenCV 2.4.13"
if ! [ -d "opencv-2.4.13" ]; then
unzip OpenCV-2.4.13.zip
fi
rm OpenCV-2.4.13.zip
cd opencv-2.4.13
rm -rf build
mkdir build
cd build
cmake -D CUDA_ARCH_BIN=3.2 -D CUDA_ARCH_PTX=3.2 -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D BUILD_TIFF=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..
make -j$(nproc)
sudo make install
sudo sh -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig
echo "OpenCV 2.4.13 ready to be used"
Command Output
[100%] Build Java tests
Buildfile: /home/myaccount/setups/OpenCV/opencv-2.4.13/build/modules/java/test/.build/build.xml
build:
compile:
[mkdir] Created dir: /home/myaccount/setups/OpenCV/opencv-2.4.13/build/modules/java/test/.build/build/classes
[javac] Compiling 104 source files to /home/myaccount/setups/OpenCV/opencv-2.4.13/build/modules/java/test/.build/build/classes
jar:
[mkdir] Created dir: /home/myaccount/setups/OpenCV/opencv-2.4.13/build/modules/java/test/.build/build/jar
[jar] Building jar: /home/myaccount/setups/OpenCV/opencv-2.4.13/build/modules/java/test/.build/build/jar/opencv-test.jar
BUILD SUCCESSFUL
Total time: 6 seconds
[100%] Built target opencv_test_java
[sudo] password for myaccount:
Sorry, try again.
[sudo] password for myaccount:
/bin/sh: 1: cd: can't cd to /home/myaccount/setups/OpenCV/opencv-2.4.13/build
make[2]: *** [3rdparty/libtiff/CMakeFiles/libtiff.dir/depend] Error 2
make[1]: *** [3rdparty/libtiff/CMakeFiles/libtiff.dir/all] Error 2
make: *** [all] Error 2
OpenCV 2.4.13 ready to be used
myaccount#vm-20161023-002:~/setups$
What popped up into my head to explain the lack of permission problem: if your /home is on NFS, root may have nobody's permission on files there. There are quite a few related questions on StackExchange.
My solution would be not to try installing third-party software as root in the first place. Executing as root, your make install can do anything, including adding or overwriting files that are already managed by your software package manager. This may confuse the package manager or even render your system unusable. It's better to install the software somewhere else; /usr/local and /opt were created for this purpose. In order to make sure your installation procedure doesn't deviate from this, you can create a different user (which I call local), chown -R these directories to that user, and install using sudo -u local instead of sudoing to root. This will be fine for most installations, and should you run into one that tries to do something requiring root permissions (such as writing files to /etc or /usr/bin, restarting system services, doing tricky things with permissions, etc.), it will fail with an error message, allowing you to decide whether you want this before it has already happened. I have no idea whether OpenCV requires any such steps.

Resources