We have an application that requires opencv in a recent version with pkg-config visibility and shared libraries to build. However, the Amazon EC2 AMI instances we are deploying on does not include the yum packages for codecs nor the opencv package.
Other pages describe how to use centOS og rpm packages to get to a working installation. We need a clean install with no yum/rpm cross over.
These steps are most likely one of the shorter paths to the target. Starting directory location is irrelevant as first line ensures a sane (~/build) initial working directory:
cd ~/ && mkdir build && cd build/
sudo yum install git cmake gcc-c++
Build libav for the codecs (the --prefix option is probably not necessary, but this is the tested and working version)
wget https://libav.org/releases/libav-12.3.tar.xz
tar xzf libav-12.3.tar.gz
mkdir libav-12.3-build && cd libav-12.3-build
/home/ec2-user/build/libav-12.3/configure --prefix=/usr --enable-shared --disable-static
make && sudo make install
The amazon default pkg-config thing-a-magic does not look at all standard paths so the next lines symlinks the relevant *.pc files to a location where pkg-config (used by opencv) can find them.
cd /usr/share/pkgconfig
for t in `find /usr -name "libav*.pc"`; do sudo ln -s $t .; done
cd ~/build
The libav shared libraries have to be available to the linker as well
echo /usr/lib/ > libav.conf
sudo mv libav.conf /etc/ld.so.conf.d/
sudo ldconfig
Check the pkg-config libav availability by the command pkg-config --list-all and check that the libavcodec, libavformat, libav... etc. packages are listed.
At this point the opencv library can be built and installed with the default tooling
git clone https://github.com/Itseez/opencv.git
mv opencv opencv.git
cd opencv.git/
git branch -r
git checkout 3.4
cd .. && mkdir opencv && cd opencv
cmake ../opencv.git/ && make && sudo make install
cd ..
The final binary requires the linker path to contain the '''/usr/local/lib64''' path.
echo /usr/local/lib64 > opencv.conf
sudo mv opencv.conf /etc/ld.so.conf.d/
sudo ldconfig
The last trick is to enable pkg-config for opencv as well
cd /usr/share/pkg-config && ln -s `find /usr/local/ -name "opencv.pc"` . && cd ~/build
Check the pkg-config availability by the command
pkg-config --list-all
and check that opencv is listed.
Done
Related
I'm trying to build OpenModelica from Git using docker-compose. I've downloaded all the dependencies that they have listed here. Now I'm using their build instructions as a RUN statement, and getting an error when I launch /.configure. The full sequence of commands to execute is
> autoconf
> ./configure CC=clang CXX=clang++
> make -j8
> build/bin/omc --version
> (cd testsuite/partest && ./runtests.pl)
I've tried dropping the clang options from the ./configure step, but that didn't resolve the error.
My Docker file and supporting files are:
Dockerfile
FROM python:3.7
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
COPY pips.txt /code/
COPY gets.txt /code/
RUN pip install -r pips.txt \
&& apt-get update \
&& xargs -a gets.txt apt-get -y install \
&& apt update \
&& apt install -y openscenegraph-3.4
COPY OpenModelica /code/OpenModelica
RUN cd /code/OpenModelica \
&& autoconf \
&& autoreconf -i
RUN cd /code/OpenModelica \
&& ./configure CC=clang-3.8 CXX=clang++-3.8
RUN make -j8 \
&& build/bin/omc --version \
&& (cd testsuite/partest && ./runtests.pl)
COPY . /code/
pips.txt
Django==2.2
psycopg2==2.8.2
gets.txt
...
clang-3.8
clang++-3.8
...
I'm getting these error messages when I launch docker-compose build
ln: failed to create symbolic link '.git/hooks/pre-commit': File exists
which I don't think is a fatal error, then the code continues to execute for a few lines, then
configure: error: no
The full error message in context is
Step 10/12 : RUN cd /code/OpenModelica && ./configure CC=clang-3.8 CXX=clang++-3.8
---> Running in 9da205a757d3
checking for gcc... clang-3.8
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether clang-3.8 accepts -g... yes
checking for clang-3.8 option to accept ISO C89... none needed
checking whether we are using the GNU C++ compiler... yes
checking whether clang++-3.8 accepts -g... yes
checking how to run the C preprocessor... clang-3.8 -E
configure: OpenModelica pre-commit hook has been installed
ln: failed to create symbolic link '.git/hooks/pre-commit': File exists
configure: OpenModelica commit-msg hook has been installed
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
build_short: x86_64-linux-gnu
host_short: x86_64-linux-gnu
checking if cppruntime is requested... no
checking for omlibrary target... core
checking for libraries directory... configure: error: no
I haven't been able to find any useful info on the error since it's so vague. I'm new to Docker, so I'm not sure if it's a Docker thing or something specific to OpenModelica.
The error
checking for libraries directory... configure: error: no
suggests that the folder libraries from submodule OpenModelica/OMLibraries is missing.
How did you clone the OpenModelica repository? You need to clone it recursively with all submodules.
# Faster pulling by using openmodelica.org read-only mirror (low latency in Europe; very important when updating all submodules)
# Replace the openmodelica.org pull URL with https://github.com/OpenModelica/OpenModelica.git if you want to pull directly from github
# The default choice is to push to your fork on github.com (SSH). Replace MY_FORK with OpenModelica to push directly to the OpenModelica repositories (if you have access)
>MY_FORK=MyGitHubUserName ; git clone https://openmodelica.org/git-readonly/OpenModelica.git --recursive && (cd OpenModelica && git remote set-url --push origin git#github.com:$MY_FORK/OpenModelica.git && git submodule foreach --recursive 'git remote set-url --push origin `git config --get remote.origin.url | sed s,^.*/,git#github.com:'$MY_FORK'/,`')
To see the docker files used for building and distributing OpenModelica on various systems you can have a look into OpenModelica/OpenModelicaBuildScripts.
I tried to compile vlc on a ubuntu docker container.
(In host)
git clone --depth=1 vlc
docker run -v ~/vlc:/root/vlc -it ubuntu:17.04
(In container)
# install dependencies
apt update && apt upgrade
apt install git build-essential pkg-config libtool automake autopoint gettext
apt-get build-dep vlc
# install ffmpeg
cd /root
git clone --depth=1 https://github.com/FFmpeg/FFmpeg.git
cd FFmpeg
./configure
make
make install
# build vlc
cd /root/vlc
./configure --disable-wayland --disable-chromecast
make
Then this error
make[4]: Entering directory '/root/vlc/modules'
CCLD libavio_plugin.la
/usr/local/lib/libavutil.a(hwcontext_vaapi.o): In function `vaapi_device_free':
/root/FFmpeg/libavutil/hwcontext_vaapi.c:899: undefined reference to `XCloseDisplay'
....
I barely knows C. It seems that it has some problem with XCB, how do I proceed?
Followed the instruction and installed Apache Singa v1.0.0 from the wheel successfully, but failed to run it below,
(singa) $ pip list | grep singa
singa (1.0.0)
(singa) $ python
> import singa
> ImportError: No module named '_singa_wrap'
(singa) $ find -name "*singa_wrap*"
singa_wrap.py
singa_wrap.pyc
_singa_wrap.so
Seemed something suspicious with Swig module extension. Any suggestions?
#EDIT
Verified that protobuf 2.6.1 already installed globally below,
(singa) $ python -c "from singa import _singa_wrap"
undefined symbol: _ZNK6google8protobuf7Message11GetTypeNameEv
$ ldd _singa_wrap.so
libprotobuf.so.9 => /usr/lib/x86_64-linux-gnu/libprotobuf.so.9
$ dpkg -S libprotobuf.so.9
libprotobuf9v5
$ apt-cache policy libprotobuf9v5
Installed: 2.6.1-1.3
#Solution
Singa starts dancing now after protobuf 2.6.1 being successfully installed locally on Ubuntu 16.04 below,
$ sudo apt-get install python-pip # gcc-5 required thus installed
$ sudo apt-get install gcc-4.8
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 60 --slave /usr/bin/g++ g++ /usr/bin/g++-5
$ sudo update-alternatives --config gcc # to choose gcc-4.8
The rest then follows the answer #Wei below. Thanks again.
I think you can try the approaches in the first FAQ http://singa.apache.org/en/docs/installation.html#faq
In addition, you can check the dependent libs of _singa_wrap.so (go to /Python2.7/site-packages/singa/, and ldd _singa_wrap.so. If any library (e.g. cudnn or protobuf) is not found, then try to install it or export the library path.
There is a ticket for your issue https://issues.apache.org/jira/browse/SINGA-255.
Will update you once it is done.
Thanks.
UPDATE:
It seems your error is related to protobuf (could be caused by multiple versions of protobuf on your computer). Here is the solution,
Download protobuf (protobuf-2.6.1.tar.gz on github) and decompress the tar file
Install protobuf into /home//local/ by
./configure --prefix=/home/<yourname>/local
make && make install
echo "export LD_LIBRARY_PATH=/home/<yourname>/local/lib:$LD_LIBRARY_PATH" >> ~/.bashrc
source ~/.bashrc
pip uninstall singa
pip install <path to the wheel file>
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.
I am trying to get s3fs-fuse installed on my Docker container. Here is my Dockerfile so far.
FROM centos:centos6
RUN yum -y update; yum clean all; \
yum groupinstall -y "Web Server" "MySQL Database" "PHP Support"; \
service httpd start; \
chkconfig httpd on;
RUN yum install -y openssh; \
yum install -y openssh-clients;
ADD ssh/ /root/.ssh/
RUN chmod 600 /root/.ssh/*; \
touch /root/.ssh/known_hosts; \
ssh-keyscan github.com >> /root/.ssh/known_hosts;
RUN yum install -y git;
RUN yum install -y autoconf libtool gcc libstdc++-devel curl-devel mailcap; \
yum install -y automake fuse-devel gcc-c++ git libcurl-devel libxml2-devel make openssl-devel;
Then after following the instructions at https://github.com/s3fs-fuse/s3fs-fuse I perform the following commands:
git clone https://github.com/s3fs-fuse/s3fs-fuse.git
cd s3fs-fuse
./autogen.sh
./configure
Then I get this:
checking s3fs build with NSS... no
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for common_lib_checking... configure: error: Package requirements (fuse >= 2.8.4 libcurl >= 7.0 libxml-2.0 >= 2.6) were not met:
Requested 'fuse >= 2.8.4' but version of fuse is 2.8.3
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables common_lib_checking_CFLAGS
and common_lib_checking_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
So, I presume I need to get the right fuse version as yum fuse-devel isn't cutting it. So I go to https://github.com/libfuse/libfuse and follow the instructions there with do the following:
git clone https://github.com/libfuse/libfuse.git;
cd libfuse;
./configure
Then I get this issue:
bash: ./configure: No such file or directory
I have been all around the internet and have tried the whole autoconf and autoreconf -i thing that lead to m4 directory missing errors. I have also tried adding the --prefix=/your/chosen/directory to the ./configure --prefix=/your/chosen/directory command that lead me no where. No luck with a super sad face.
Run makeconf.sh in your libfuse clone which creates configure.