Tag Archives: cmake - Page 2

Install collada-dom library in Ubuntu 10.04, 10.11, 11.04, 11.10 and 12.04

I wanted to install collada-dom to add support for DAE files on OpenSceneGraph. I used the SVN from 2011/03/12 (I already had it downloaded and knew it worked fine). You can download the same code for that date with this commnad:

svn co -r {20110312} https://collada-dom.svn.sourceforge.net/svnroot/collada-dom/trunk collada-dom

The last trunk code in SVN repository fails to compile rt and fx projects and even does not work with OpenSceneGraph (looks like some types disapeared from Collada DOM and OpenSceneGraph plugin for DAE files expects them). Anyway if you want to try you can download running this command:

svn co https://collada-dom.svn.sourceforge.net/svnroot/collada-dom/trunk collada-dom

Install the following dependencies for Ubuntu 10.04:

sudo apt-get install libboost1.40-dev libpcre++-dev nvidia-cg-toolkit libboost-filesystem1.40-dev libglut3-dev

For Ubuntu 10.10 and 11.04 install those:

sudo apt-get install libboost1.42-dev libpcre++-dev nvidia-cg-toolkit libboost-filesystem1.42-dev libglut3-dev

And for Ubuntu 11.10 and 12.04 install those:

sudo apt-get install libboost1.46-dev libpcre++-dev nvidia-cg-toolkit libboost-filesystem1.46-dev freeglut3-dev

To compile execute, inside the collada-dom folder, those commands:

make os=linux project=minizip -C dom
make os=linux project=dom -C dom
make os=linux project=rt -C rt
make os=linux project=fx -C fx

We can now just copy the libraries and includes we need to “/usr/local/lib” and “/usr/local/include“:

sudo cp dom/build/linux-1.4/libminizip.* /usr/local/lib/
sudo cp dom/build/linux-1.4/libcollada14dom.* /usr/local/lib/
sudo cp -R dom/include /usr/local/include/colladadom
sudo cp rt/build/linux-1.4/libcollada14rt.* /usr/local/lib/
sudo cp fx/build/linux-1.4/libcollada14fx.* /usr/local/lib/

UPDATE: Fixed the compilation and installation process to bypass the problems with domTest and viewer. Also excluded rt and fx because they are not necessary. Ignore rest of the post.

But there have been some changes in the Boost library used in Ubuntu 12.04: the function native_file_string() has been deleted and we have to change “dom/test/1.4/domTest.cpp” file code on lines 91 and 95 to call c_str() instead of native_file_string(). So change this:

string lookupTestFile(const string& fileName) {
        return (dataPath() / fileName).native_file_string();
}

string getTmpFile(const string& fileName) {
        return (tmpPath() / fileName).native_file_string();
}

To this:

string lookupTestFile(const string& fileName) {
        return (dataPath() / fileName).c_str();
}

string getTmpFile(const string& fileName) {
        return (tmpPath() / fileName).c_str();
}

I got another error while compiling domTest complaining about not being able to locate a reference to libboost_system:

make[1]: Entering directory `/home/user/compilations/collada-dom/dom'
Linking build/linux-1.4/domTest
/usr/bin/ld: build/linux-1.4/obj/domTest.o: undefined reference to symbol 'boost::system::system_category()'
/usr/bin/ld: note: 'boost::system::system_category()' is defined in DSO /usr/lib/libboost_system.so.1.46.1 so try adding it to the linker command line
/usr/lib/libboost_system.so.1.46.1: could not read symbols: Invalid operation

I added -lboost_system -lboost_filesystem to the libOpts variable in “dom/make/common.mk” file (line 25) and it worked.

libOpts := -lboost_system -l boost_filesystem

I also had a similar error while compiling the “viewer” library, but we don’t need this.

Install OpenCV 2.3.1a in Mac OS X 10.6

Download OpenCV 2.3.1a and unpack it:

curl -L -O http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.3.1/OpenCV-2.3.1a.tar.bz2
tar xzvpf OpenCV-2.3.1a.tar.bz2

Then configure and compile it:

cd OpenCV-2.3.1
mkdir build
cd build
cmake -G "Unix Makefiles" ..
make
sudo make install

You can use different options when executing cmake:

  • -D BUILD_EXAMPLES=ON -> Compile example programs.
  • -D BUILD_TESTS=OFF -> Don’t compile tests.
  • -D BUILD_NEW_PYTHON_SUPPORT=OFF -> Don’t compile new Python support.
  • -D WITH_CARBON=ON -> (mostly for Leopard and below) To use Carbon instead of Cocoa (since version r2909).
  • -D WITH_QUICKTIME=ON -> (mostly for Leopard and below) To use QuickTime for the I/O of Video instead of QTKit (since version r2924). If you use Snow Leopard and need Carbon and QuickTime, you must also specify -D CMAKE_OSX_ARCHITECTURES=i386, -D CMAKE_C_FLAGS=-m32 and -D CMAKE_CXX_FLAGS=-m32.

If you don’t have cmake installed download a “binary distribution” from cmake.org. For example http://www.cmake.org/files/v2.8/cmake-2.8.7-Darwin64-universal.dmg.

You can compile OpenCV for an specific architecture using CMAKE_OSX_ARCHITECTURES with those values:

i386
x86_64
ppc
ppc64

For example:

cmake -G "Unix Makefiles" -D CMAKE_OSX_ARCHITECTURES=i386 ..

To create a “universal build” use both i386 and ppc:

cmake -G "Unix Makefiles" -D CMAKE_OSX_ARCHITECTURES=i386 ppc ..

If you want to compile for a 32 bit architecture is mandatory to add -m32 to C and CXX flags. If you don’t add it you could end up with this warning:

created and used with differing settings of '-m32'

To solve this use -m32 option in CMAKE_C_FLAGS and CMAKE_CXX_FLAGS:

cmake -G "Unix Makefiles" -D CMAKE_OSX_ARCHITECTURES=i386 -D CMAKE_C_FLAGS=-m32 -D CMAKE_CXX_FLAGS=-m32 ..

Install OpenCV 2.3.1a in Ubuntu 11.10

If you want to install OpenCV 2.1 you can just use apt-get to do the work:

sudo apt-get install libcv-dev libcv2.1 libcvaux-dev libcvaux2.1 libhighgui-dev libhighgui2.1 opencv-doc python-opencv

Some changes introduced in Ubuntu 11.10 causes OpenCV 2.3.1a not to compile because of ffmpeg. This makes the installation more complicated as we have to compile some libraries on our own. The other option would be just disabling ffmpeg in OpenCV with ccmake in WITH_FFMPEG option or using “-DWITH_FFMPEG=NO” with cmake.

First we have to uninstall some libraries:

sudo apt-get remove ffmpeg x264 libx264-dev

Get all the dependencies we need (run sudo apt-get update before this just in case):

sudo apt-get install build-essential checkinstall git cmake libfaac-dev libjack-jackd2-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libva-dev libvdpau-dev libvorbis-dev libx11-dev libxfixes-dev libxvidcore-dev texi2html yasm zlib1g-dev libtiff4-dev

Install gstreamer:

sudo apt-get install libgstreamer0.10-0 libgstreamer0.10-dev gstreamer0.10-tools gstreamer0.10-plugins-base libgstreamer-plugins-base0.10-dev gstreamer0.10-plugins-good gstreamer0.10-plugins-ugly gstreamer0.10-plugins-bad gstreamer0.10-ffmpeg

Download, compile and install a stable and recent version of x264 (in my case it was x264-snapshot-20111213-2245-stable):

wget ftp://ftp.videolan.org/pub/videolan/x264/snapshots/last_stable_x264.tar.bz2
tar -xjvf last_stable_x264.tar.bz2
cd `ls -1d */ | grep x264-snapshot-`
./configure --enable-static
make
sudo make install

If you are compiling for x64 arquitecture it may be necessary to use the --enable-pic and --enable-shared option when running ./configure:

./configure --enable-static --enable-pic --enable-shared

Download, compile and install a 0.8.x version of ffmpeg (in my case it was 0.8.7) (for versions prior to OpenCV 2.3.1 use a 0.7.x version), although with versión 0.10.x works too:

wget http://ffmpeg.org/releases/ffmpeg-0.8.7.tar.bz2
tar -xjvf fmpeg-0.8.7.tar.bz2
cd ffmpeg-0.8.7
./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab
make
sudo make install

As it happend with x264 it may be necessary to use the –enable-pic and –enable-shared option when running ./configure:

./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab --enable-pic --enable-shared

Install gtk:

sudo apt-get install libgtk2.0-0 libgtk2.0-dev

Install libjpeg:

sudo apt-get install libjpeg62 libjpeg62-dev

Download, compile and install a 0.8.x version of v4l (in my case it was 0.8.5 but the, as of april 2012, 0.8.8 version works too):

wget http://www.linuxtv.org/downloads/v4l-utils/v4l-utils-0.8.5.tar.bz2
tar -xjvf v4l-utils-0.8.5.tar.bz2
cd v4l-utils-0.8.5
make
sudo make install

Download, compile and install OpenCV 2.3.1a:

wget http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.3.1/OpenCV-2.3.1a.tar.bz2
tar -xjvf OpenCV-2.3.1a.tar.bz2
cd OpenCV-2.3.1
mkdir build
cd build
cmake ..
make
sudo make install

Beyond this point you can look at how to install OpenCV in Ubuntu 10.10 for more configuration options of OpenCV installation.

Sources: http://ozbots.org/opencv-installation/

http://thebitbangtheory.wordpress.com/2011/10/23/how-to-install-opencv-2-3-1-in-ubuntu-11-10-oneiric-ocelot-with-python-support/

Install OpenCV in Ubuntu 10.10

If you want to install OpenCV 2.1 you can just use apt-get to do the work:

sudo apt-get install libcv-dev libcv2.1 libcvaux-dev libcvaux2.1 libhighgui-dev libhighgui2.1 opencv-doc python-opencv

To install the latest stable version, which now is 2.3.1a, it’s necessary to compile the source code. We will need to install first some libraries and programs to be able to compile OpenCV:

sudo apt-get install cmake cmake-data cmake-curses-gui emacsen-common libxmlrpc-core-c3 g++ libv4l-dev libdc1394-22-dev libraw1394-dev libswscale-dev libavutil-dev libavformat-dev libavcodec-dev libjasper-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libgtk2.0-dev libtiff4-dev libopenexr-dev libunicap2-dev libeigen2-dev python-dev python-numpy libucil2 libucil2-dev

Now we download OpenCV 2.3.1a source code somewhere in our computer. I usually have a “compilations” directory in my home folder so everything is in place.

wget http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.3.1/OpenCV-2.3.1a.tar.bz2

You could also download the from the SVN repository, but it may not be 2.3.1a compatible version. The stable version:

svn co https://opencvlibrary.svn.sourceforge.net/svnroot/opencvlibrary/trunk

And the latest tested version:

svn co https://opencvlibrary.svn.sourceforge.net/svnroot/opencvlibrary/tags/latest_tested_snapshot

After downloading the source code and extracting it we cd to the folder and execute:

mkdir build
cd build
cmake ..
make
sudo make install

This would configure and compile OpenCV with standard options, but we can change them by CMAKE parameters. For example to use the TBB (Threaring Building Blocks) it would be necessary to install them and activate that library when we execute cmake:

sudo apt-get install libtbb-dev libtbb2
cmake -D WITH_TBB=ON ..

OpenCV is configured by default to use CUDA (to use the GPU for some operations), but if we don’t have it installed you will see an error when configuring with cmake.

CUDA_TOOLKIT_ROOT_DIR not found or specified
-- Could NOT find CUDA (missing:  CUDA_TOOLKIT_ROOT_DIR CUDA_NVCC_EXECUTABLE CUDA_INCLUDE_DIRS CUDA_CUDART_LIBRARY) (Required is at least version "4.0")

To prevent this error (although it will compile without problems) just configure CUDA as OFF on cmake:

cmake -D WITH_CUDA=OFF ..

As you can se many options can be configured before compiling OpenCV. Look at this example and try to figure out what each one configures:

cmake -D CMAKE_BUILD_TYPE=DEBUG -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON -D WITH_UNICAP=ON ..

There is also a more visual way to configure all this options using ccmake (that why we installed cmake-curses-gui). If you run “ccmake ..” instead of “cmake ..” you will be presented with a ncurses user interface with many other options. If you want to see them all toggle to expert mode by pressing letter “t“. When you are ready with your options press “c” to configure (and see if there is any error or warning) and finish pressing “g” to generate the CMAKE files. Then you will be able to compile using “make” as ussual.

If you want to uninstall OpenCV go to your “build” folder and execute:

sudo make uninstall

If you get an error like this when running any OpenCV program:

error while loading shared libraries: libopencv_core.so.2.1: cannot open shared object file: No such file or directory

You should create a file called ”/etc/ld.so.conf.d/opencv.conf” and put inside the location of the folder with the OpenCV libraries, which should be /usr/local/lib/ (this is an option that can be changed during configuration with CMAKE_INSTALL_PREFIX option). Then reload the library configurations running this command:

sudo ldconfig /etc/ld.so.conf

If you are using OpenCV 2.1 and have messages about ”mmap invalid argument” running OpenCV programs, you will need to compile the source code but changing before the file ”/src/highgui/cvcap_libv4l.cpp” on line 785 from:

mmap (NULL /* start anywhere */,

to:

v4l2_mmap (NULL /* start anywhere */,

This bug is solved in SVN repository.

  • Page 2 of 2
  • <
  • 1
  • 2