Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Usually libraries are installed in ${CMAKE_INSTALL_PREFIX}/lib so if you call cmake e.g. with -D CMAKE_INSTALL_PREFIX=../inst the libs, includes and all you need are installed in a directory inst beside your build directory.

Usually libraries are installed in ${CMAKE_INSTALL_PREFIX}/lib so if you call cmake e.g. with -D CMAKE_INSTALL_PREFIX=../inst the libs, includes and all you need are installed in a directory inst beside your build directory.

You can also use -D OPENCV_LIB_INSTALL_PATH=mylib which is appended to CMAKE_INSTALL_PREFIX and will install to ../inst/mylib instead of ../inst/lib. So you first select the overall location using CMAKE_INSTALL_PREFIX and then append the directory for the libraries with OPENCV_LIB_INSTALL_PATH.

Usually libraries are installed in ${CMAKE_INSTALL_PREFIX}/lib so if you call cmake e.g. with -D CMAKE_INSTALL_PREFIX=../inst the libs, includes and all you need are installed in a directory inst beside your build directory.

You can also use -D OPENCV_LIB_INSTALL_PATH=mylib which is appended to CMAKE_INSTALL_PREFIX and will install to ../inst/mylib instead of ../inst/lib. So you first select the overall location using CMAKE_INSTALL_PREFIX and then append the directory for the libraries with OPENCV_LIB_INSTALL_PATH.

As an example if we want to build in a subdirectory build of the source tree root and want to install in inst beside, the recipe is:

# Go to openCV source directory
cd opencv-3.0.0
# Create a build directory (can be anywhere with any name)
mkdir build
# Go to the build directory
cd build
# Create the makefiles (referencing the source directory .. )
cmake -D CMAKE_INSTALL_PREFIX=../inst -D CMAKE_BUILD_TYPE=RELEASE ..
# Run make to compile and link the sources
make
# Copy the libraries, binaries, includes to ${CMAKE_INSTALL_PREFIX}
make install
# Go to your install directory
cd ../inst

Compiling takes a lot of time and can be done parallel using several cores of your CPU by make -j8.

Usually libraries are installed in ${CMAKE_INSTALL_PREFIX}/lib so if you call cmake e.g. with -D CMAKE_INSTALL_PREFIX=../inst the libs, includes and all you need are installed in a directory inst beside your build directory.

You can also use -D OPENCV_LIB_INSTALL_PATH=mylib which is appended to CMAKE_INSTALL_PREFIX and will install to ../inst/mylib instead of ../inst/lib. So you first select the overall location using CMAKE_INSTALL_PREFIX and then append the directory for the libraries with OPENCV_LIB_INSTALL_PATH.

As an example if we want to build in a subdirectory build of the source tree root and want to install in inst beside, the recipe is:

# Go to openCV source directory
cd opencv-3.0.0
# Create a build directory (can be anywhere with any name)
mkdir build
# Go to the build directory
cd build
# Create the makefiles (referencing the source directory .. )
cmake -D CMAKE_INSTALL_PREFIX=../inst -D CMAKE_BUILD_TYPE=RELEASE ..
# Run make to compile and link the sources
make
# Copy the libraries, binaries, includes to ${CMAKE_INSTALL_PREFIX}
make install
# Go to your install directory
cd ../inst

Compiling takes a lot of time and can be done parallel using several cores of your CPU by make -j8.

The answer is in the question: "Can't create lib files with CMake". You can never make libraries with cmake. CMale is a tool for creating Makefiles to tell make how to create the libraries.

Usually libraries are installed in ${CMAKE_INSTALL_PREFIX}/lib so if you call cmake e.g. with -D CMAKE_INSTALL_PREFIX=../inst the libs, includes and all you need are installed in a directory inst beside your build directory.

You can also use -D OPENCV_LIB_INSTALL_PATH=mylib which is appended to CMAKE_INSTALL_PREFIX and will install to ../inst/mylib instead of ../inst/lib. So you first select the overall location using CMAKE_INSTALL_PREFIX and then append the directory for the libraries with OPENCV_LIB_INSTALL_PATH.

As an example if we want to build in a subdirectory build of the source tree root and want to install in inst beside, the recipe is:

# Go to openCV source directory
cd opencv-3.0.0
# Create a build directory (can be anywhere with any name)
mkdir build
# Go to the build directory
cd build
# Create the makefiles (referencing the source directory .. )
cmake -D CMAKE_INSTALL_PREFIX=../inst -D CMAKE_BUILD_TYPE=RELEASE ..
# Run make to compile and link the sources
make
# Copy the libraries, binaries, includes to ${CMAKE_INSTALL_PREFIX}
make install
# Go to your install directory
cd ../inst

Compiling takes a lot of time and can be done parallel using several cores of your CPU by make -j8.