Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 14:18
Show Gist options
  • Save ilyakava/6f22d458b9771e7ccc97 to your computer and use it in GitHub Desktop.
Save ilyakava/6f22d458b9771e7ccc97 to your computer and use it in GitHub Desktop.
# On: Ubuntu 14.10 (Utopic Unicorn), used with opencv 2.4.11 and cuda-7.0 for Quadro NVS 510
# Also successfuly tested On: Ubuntu 14.10 (Utopic Unicorn), used with opencv 3.0.0 and cuda-7.0 for Tesla K40c
set -o errexit
echo "Removing any pre-installed ffmpeg and x264"
sudo apt-get -qq remove ffmpeg x264 libx264-dev libavcodec-dev libavformat-dev libavdevice-dev libavutil-dev
echo "Installing ffmpeg from source"
sudo apt-get -qq install git
git clone git://
cd ffmpeg
./configure --enable-shared --disable-static
sudo make install
cd ..
echo "Installing Dependenices"
sudo apt-get -qq install libopencv-dev build-essential checkinstall cmake pkg-config yasm libjpeg-dev libjasper-dev libswscale-dev libdc1394-22-dev libxine2-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev python-dev python-numpy libtbb-dev libqt4-dev libgtk2.0-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils cmake qt5-default checkinstall
# additional packages (installed in desperation, not sure if all are necessary):
sudo apt-get -qq install ia32-libs lib32stdc++6 clang-3.5
# necessary symlinks
sudo ln -s /usr/bin/clang-3.5 /usr/bin/clang
sudo ln -s /usr/bin/clang++-3.5 /usr/bin/clang++
version="$(wget -q -O - | egrep -m1 -o '\"[0-9](\.[0-9]+)+' | cut -c2-)"
echo "Installing OpenCV" $version
mkdir OpenCV
cd OpenCV
echo "Downloading OpenCV" $version
wget -O OpenCV-$$version/opencv-"$version".zip/download
echo "Installing OpenCV" $version
unzip OpenCV-$
cd opencv-$version
mkdir build
cd build
make -j2
sudo checkinstall
sudo sh -c 'echo "/usr/local/lib" > /etc/'
sudo ldconfig
echo "Setting up OpenCV" $version
sudo ln -s /usr/local/cuda/lib64/ /usr/local/lib/
sudo ln -s /usr/local/cuda/lib64/ /usr/local/lib/
sudo ln -s /usr/local/cuda/lib64/ /usr/local/lib/
sudo ln -s /usr/local/cuda/lib64/ /usr/local/lib/
sudo ln -s /usr/local/cuda/lib64/ /usr/local/lib/
sudo cp unix-install/opencv.pc /usr/local/lib/pkgconfig/
sudo sh -c 'echo "export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig" >> ~/.bashrc'
source ~/.bashrc
echo "OpenCV" $version "ready to be used"
Copy link

note that with cuda-7.0 we no longer have to build with libstdc++ as requested for the udacity course,
see the comment after this question.
In fact, since -DCMAKE_CXX_FLAGS:STRING='-stdlib=libstdc++' is a clang
param, and b/c of this line in opencv
it seems that it was not even possible to build opencv with cuda versions earlier than 7.0 on ubuntu with libstdc++

Copy link

btw, needed to add deb precise main universe to /etc/apt/sources.list, and run sudo apt-get update

Copy link

finally was able to compile c++ opencv test using the *.sh file here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment