Trouble building caffe from source - c++

I am trying to install caffe by building it from source
After issuing the following command from the caffe root directory
$ make all -j4
I am getting an error
...
CXX src/caffe/layer_factory.cpp
CXX src/caffe/blob.cpp
AR -o .build_release/lib/libcaffe.a
LD -o .build_release/lib/libcaffe.so.1.0.0
/usr/bin/x86_64-linux-gnu-ld: cannot find -lpython3.6
collect2: error: ld returned 1 exit status
Makefile:582: recipe for target '.build_release/lib/libcaffe.so.1.0.0' failed
make: *** [.build_release/lib/libcaffe.so.1.0.0] Error 1
Dependencies installed
$ sudo apt install python3-opencv
$ sudo apt-get install libatlas-base-dev
$ sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
$ sudo apt-get install --no-install-recommends libboost-all-dev
$ sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
$ sudo apt-get install the python3-dev
CUDA: CUDA 9 CuDnn 7.4
Ubuntu: Ubuntu 18.04
Makefile.config
I have looked at all the issues in the source Github repository but couldn't find anything useful.

Therefore that your error states cannot find -lpython3.6 you are missing the libpython3.6.so on your system.
Try to:
sudo apt-get install libpython3.6-dev

The issue is resolved, I had to make the following changes in Makefile.config file
From
PYTHON_LIBRARIES := boost_python3 python3.6
PYTHON_INCLUDE := /usr/include/python3.6 \
/usr/lib/python3.6/dist-packages/numpy/core/include
To
PYTHON_LIBRARIES := boost_python3 python3.6m
PYTHON_INCLUDE := /usr/include/python3.6m \
/usr/lib/python3.6/dist-packages/numpy/core/include

Related

How to build Opencv code in a docker file

I want to build and run a c++ opencv code using docker. Here is my dockerfile:
FROM nvidia/cuda:11.5.0-cudnn8-runtime-ubuntu20.04
FROM ubuntu
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y \
g++ git wget cmake sudo
RUN apt-get install -y \
build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev \
python3-dev python3-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev \
libcanberra-gtk-module libcanberra-gtk3-module
RUN git clone https://github.com/opencv/opencv.git && \
cd /opencv && mkdir build && cd build && \
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local .. && \
make -j"$(nproc)" && \
make install && ldconfig
The above commands makes my opencv libs, but I don't how to use it to run the actual code. I added this two lines at the end of the dockerfile (wav.cpp is the name of my cpp file that I want to run):
COPY . .
RUN g++ -o wav wav.cpp
But at the end I get this error, which obviously says it can't find the opencv headers.
wav.cpp:2:10: fatal error: opencv2/imgproc.hpp: No such file or
directory
2 | #include "opencv2/imgproc.hpp"
| ^~~~~~~~~~~~~~~~~~~~~ compilation terminated.
Now how should I resolve this header (and lib) dependency problem?
Thank you.
You didn't specify the location for the headers and which libraries should be linked by gcc. Please take a look at the manual of gcc/g++ for the flags -I and -L. Should be something like this:
RUN g++ -o wav wav.cpp -I <opencv header location> -L <opencv libs location> -lopencv_core ....
Using #emrhzc's answer I could build my code inside the dockerfile. Now my final working command is:
RUN g++ -o wav wav.cpp `pkg-config --cflags --libs opencv4`

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
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.

How to install aclocal in ubuntu14.04

I want to install aclocal -I m4 in ubuntu 14.04 when i run the command its showing
First installed
sudo apt-get install autotools-dev
then,
sudo apt-get install aclocal
same error also getting.
I needed to install all of the following packages to get aclocal running:
apt install automake
apt install autoconf
apt install m4
apt install perl
apt install libtool
This was the error message that I received when I tried to install ssdeep:
WARNING: 'aclocal-1.13' is missing on your system.
You should only need it if you modified 'acinclude.m4' or
'configure.ac' or m4 files included by 'configure.ac'.
The 'aclocal' program is part of the GNU Automake package:
<http://www.gnu.org/software/automake>
It also requires GNU Autoconf, GNU m4 and Perl in order to run:
<http://www.gnu.org/software/autoconf>
<http://www.gnu.org/software/m4/>
<http://www.perl.org/>
Makefile:426: recipe for target 'aclocal.m4' failed
make: *** [aclocal.m4] Error 127
/bin/sh: 1: libtoolize: not found
/usr/bin/m4:aclocal.m4:1069: cannot open `m4/libtool.m4': No such file or directory
/usr/bin/m4:aclocal.m4:1070: cannot open `m4/ltoptions.m4': No such file or directory
/usr/bin/m4:aclocal.m4:1071: cannot open `m4/ltsugar.m4': No such file or directory
/usr/bin/m4:aclocal.m4:1072: cannot open `m4/ltversion.m4': No such file or directory
/usr/bin/m4:aclocal.m4:1073: cannot open `m4/lt~obsolete.m4': No such file or directory
autom4te: /usr/bin/m4 failed with exit status: 1
automake: error: autoconf failed with exit status: 1
Failed while building ssdeep lib with configure and make.
Retry with autoreconf ...
Failed to reconfigure the project build.
Install it from source, you avoid a lot of troubles compiling other software in the future. aclocal package does NOT exist, and is part of automake package.
$ sudo apt-get install automake
Will install aclocal
I recommend compiling from script, it will update to the latest version
#!/bin/bash
VERSION=1.15
wget ftp://ftp.gnu.org/gnu/automake/automake-${VERSION}.tar.gz &> /dev/null
if [ -f "automake-${VERSION}.tar.gz" ]; then
tar -xzf automake-${VERSION}.tar.gz
cd automake-${VERSION}/
./configure
make && make install
echo -e "\e[1;39m[ \e[1;32mOK\e[39m ] automake-${VERSION} installed\e[0;39m"
else
echo -e "\e[1;39m[ \e[31mError\e[39m ] cannot fetch file from ftp://ftp.gnu.org/gnu/automake/ \e[0;39m"
exit 1
fi

make not found with Dockerfile and centos:7 image

I have a very basic Dockerfile which uses FROM centos:7, then downloads Python-2.7.9.tar.xz, and attempts to ./configure && make && make altinstall.
I get the following error upon make:
creating Makefile
/bin/sh: make: command not found
The command '/bin/sh -c cd /root/Python-2.7.9 && ./configure -- prefix=/usr/local && make && make altinstall' returned a non-zero code: 127
I've installing the following libs prior to running make
yum install -y zlib-dev openssl-devel sqlite-devel bzip2-devel xz-libs gcc g++ build-essential kernel-headers kernel-devel
Yet error still persists. How can I resolve this?
A simple RUN yum -y install make solved the problem

Cannot add QtWebWidgets to project

As the title says I can't add QtWebWidgets to any QT project. I'm running QT creator 3.2.0 based on Qt 5.3.1 run in Linux Mint 17. When I add
QT += webkitwidgets
to my .pro file I'm getting a lot of errors, which say that the compiler can't find file here's the compiler output:
/usr/bin/ld: cannot find -lgio-2.0
/usr/bin/ld: cannot find -lgstapp-0.10
/usr/bin/ld: cannot find -lgstinterfaces-0.10
/usr/bin/ld: cannot find -lgstpbutils-0.10
/usr/bin/ld: cannot find -lgstvideo-0.10
/usr/bin/ld: cannot find -lgstbase-0.10
/usr/bin/ld: cannot find -lgstreamer-0.10
/usr/bin/ld: cannot find -lgobject-2.0
/usr/bin/ld: cannot find -lgmodule-2.0
/usr/bin/ld: cannot find -lxml2
/usr/bin/ld: cannot find -lgthread-2.0
/usr/bin/ld: cannot find -lglib-2.0
collect2: error: ld returned 1 exit status
make: *** [web_browser] Error 1
21:24:24: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project web_browser (kit: Desktop Qt 5.2.1 GCC 64bit)
When executing step "Make"
Any ideas what's causing those errors?
Install in Ubuntu (or like)
Install g++
sudo apt-get install build-essential
Install OpenGL libraries
sudo apt-get install mesa-common-dev
sudo apt-get install libglu1-mesa-dev -y
After perform this:
sudo apt-get install libgstreamer1.0-dev
sudo apt-get install libgstreamer0.10-dev
sudo apt-get install libgstreamer-plugins-base1.0-dev
sudo apt-get install libgstreamer-plugins-base0.10-dev
And
sudo apt-get install qtbase5-dev
Other distros (like Debian)
After install QT perform this commands in terminal with su or sudo
First update (with su or sudo):
apt-get update
After install packages (with su or sudo):
apt-get install libxslt
apt-get install libxml2
apt-get install libgio2.0
apt-get install libgstapp0.10
apt-get install libgstinterfaces0.10
apt-get install libgstpbutils0.10
apt-get install libgstvideo0.10
apt-get install libgstbase0.10
apt-get install libgstreamer0.10
apt-get install libgobject2.0
apt-get install libgmodule2.0
apt-get install libgthread2.0
apt-get install libglib2.0
apt-get install libgl