Ask Your Question
1

install multiple versions of OpenCV on ubuntu

asked 2015-06-29 20:05:53 -0600

maystroh10 gravatar image

I'm already using OpenCV version 2.8 with CMake but now I want to test some of the new functionalities which have been added in the version 3.0 so I installed it but I'm not able to link my QT project to new version installed. I already checked this link where they explain how to have 2 different versions of OpenCV on the same PC but it's not clear enough how to link the project to new one. Any hints on how to achieve it? what should I modify in the CMake file?

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2015-06-30 01:29:04 -0600

updated 2015-06-30 01:33:17 -0600

It shouldn't be very difficult. You should have different paths while "cmaking" it. For example, you should specify different install paths using -DCMAKE_INSTALL_PREFIX= flag.

For example,

for opencv 2.4.9,

-DCMAKE_INSTALL_PREFIX=/path/to/opencv2.4.9/

while

for opencv 3.0.0

-DCMAKE_INSTALL_PREFIX=/path/to/opencv3.0.0

Do not confuse this path with source path.

And then real "magic" is in the makefile to compile your own code. Linking path and include paths have to be specified as per the opencv version you want.

For example : You have opencv 2.4.9 installed in /path/to/opencv2.4.9/lib/ and opencv 3.0.0 install in /path/to/opencv3.0.0/lib/ as per mentioned in that link, you will have makefile as per below:

Makefile for opencv 2.4.9

 CPP = g++

# OpenCV 2.4.9
CPPFLAGS = -L/path/to/opencv2.4.9/lib \
       -I/path/to/opencv2.4.9/include

all: test

test: main.cpp
    $(CPP) $(CPPFLAGS) $^ -o $@

and Makefile for opencv 3.0.0

 CPP = g++

# OpenCV 2.4.9
CPPFLAGS = -L/path/to/opencv3.0.0/lib \
       -I/path/to/opencv3.0.0/include

all: test

test: main.cpp
    $(CPP) $(CPPFLAGS) $^ -o $@

You might be confused as in that link, there are two CPPFLAGS defined in the same file.

Hope it clears your doubt.

edit flag offensive delete link more

Comments

so what does exactly the flag "-DCMAKE_INSTALL_PREFIX"? Also, as I got it, I should have 2 separates Makefile files, right?

maystroh10 gravatar imagemaystroh10 ( 2015-06-30 03:41:32 -0600 )edit

This doesn’t seems to work anymore because at runtime it will load the library that it found on the runtime library path and compiling with rpath now issues RUNPATH links instead of the deprecated RPATH and those don’t work the same.

Help me

VillaggioCloud gravatar imageVillaggioCloud ( 2020-04-11 18:09:02 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-06-29 20:05:53 -0600

Seen: 11,795 times

Last updated: Jun 30 '15