Ask Your Question
0

Change build directory in cmake for opencv compiling

asked 2017-07-26 04:55:18 -0600

marcob88 gravatar image

Hi all,

i have a question (i suppose that it's stupid but i've difficult). I'm try to compile with cmake (not cmake-gui!!!) opencv. The problem is that i need to change the build folder. I give you an example:

I have the source code and the cmakelist on directory /home/xxx/opencv/

I would like to execute cmake and put the build into /home/yyy/lib_opencv/ and subsequently call make install....

With cmake-gui i don't have a problem. But i have to use the cmake command shell.

Can you help me? I hope that i have explained clearly the problem

Thanks

edit retag flag offensive close merge delete

3 answers

Sort by » oldest newest most voted
1

answered 2017-07-26 05:30:48 -0600

berak gravatar image

updated 2017-07-26 06:07:02 -0600

there are 3 folders involved here:

  1. the src folder
  2. the build folder (where all temporary files are built, you may delete it after successfully installing !)
  3. the install folder (final location for libs & headers, usually /usr/local on linux)

assuming, your src is in /home/xxx/opencv, and you would want to build in /home/yyy/opencv and finally install to /home/zzz/opencv, the cmdline would be:

mkdir /home/yyy/opencv
cd /home/yyy/opencv

cmake -D CMAKE_INSTALL_PREFIX=/home/zzz/opencv  /home/xxx/opencv

in other words: the src dir should be the last argument in the cmake cmdline.

edit flag offensive delete link more
-1

answered 2017-07-26 05:03:36 -0600

LBerger gravatar image

Use doc :

Building OpenCV from Source Using CMake

Create a temporary directory, which we denote as <cmake_build_dir>, where you want to put the generated Makefiles, project files as well the object files and output binaries and enter there.

For example
cd ~/opencv
mkdir build
cd build

Configuring. Run cmake [<some optional parameters>] <path to the OpenCV source directory>

For example
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..

or cmake-gui
    set full path to OpenCV source code, e.g. /home/user/opencv
    set full path to <cmake_build_dir>, e.g. /home/user/opencv/build
    set optional parameters
    run: “Configure”
    run: “Generate”
edit flag offensive delete link more

Comments

Why -1 on windows it works and in linux if doc is wrong a pr is necessary

and in windows using cmake 3.7.1 I can do this :

cmake g:\lib\opencv -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=f:\tmp\toto

and linux

pi@raspberrypi ~/build $ cmake ../opencv -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules

LBerger gravatar imageLBerger ( 2017-07-26 05:50:45 -0600 )edit
-1

answered 2017-07-26 05:07:36 -0600

Raki gravatar image

updated 2017-07-26 05:09:40 -0600

I am not sure if this is a good idea, since usually the libraries are not kept under such locations once they are built, but anyway let me tell you what you need to do:

You need to change the install prefix, which is given in the command you execute to build it:

cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/home/yyy/lib_opencv/ ..

Also, do not skip those dots at the end of the command, they are there for a reason.

For further information, I suggest you go through the tutorial by OpenCV itself.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-07-26 04:55:18 -0600

Seen: 14,422 times

Last updated: Jul 26 '17