Ask Your Question
0

Can't create lib files with CMake

asked 2016-01-14 07:32:41 -0600

busrakkk gravatar image

I'm using OpenCV 3.1.0, Cmake 3.4.1 and Visual Studio 2013. I'm trying to build libraries and following all steps exactly the same as tutorials but at configuration step at CMake there is no option that i can set library output path (e.g LIBRARY_OUTPUT_PATH) so lib files cannot generated.

How can I solve this problem?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2016-01-14 10:06:54 -0600

Kellerspeicher gravatar image

updated 2016-01-15 04:11:14 -0600

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.

edit flag offensive delete link more

Comments

sorry for the late reply. I tried your suggestion, after configuration cmake says "Install path: <build_path>/install" but there is no such a file so i cannot find libraries Thanx.

busrakkk gravatar imagebusrakkk ( 2016-01-15 00:18:32 -0600 )edit

cmake is just making the makefile for make to compile. And make install will copy the libraries to the install location. I added a recipe to the answer.

Kellerspeicher gravatar imageKellerspeicher ( 2016-01-15 03:01:22 -0600 )edit

Thank you for your solution, it works when I disable WITH_CUDA in CMAKE. However when I enable it, I get the same errors again.

busrakkk gravatar imagebusrakkk ( 2016-01-15 06:45:46 -0600 )edit

What do you mean by "same error"? Which one?

Kellerspeicher gravatar imageKellerspeicher ( 2016-01-15 06:51:23 -0600 )edit

I solved the problem with cuda that i mention but now i'm getting this error; "LNK4044: unrecognized option 'my cuda lib path'; ignored" and i'm sure that the path is correct. thanks again..

busrakkk gravatar imagebusrakkk ( 2016-01-15 07:03:18 -0600 )edit

Your linker is called with an unknown option or most common one with a wrong syntax. Usually cmake and later make knows how to pass such paths. I guess there is some thing happening with it, e.g. a not escaped backslash is ignored. Even if using Windows it is often better to use slash instead if backslash in paths. In the meantime even Microsoft has realized that it makes no sense to use backslash if the hole rest of the IT world has used slash long before DOS was made and until today.

Kellerspeicher gravatar imageKellerspeicher ( 2016-01-15 07:21:03 -0600 )edit

Thanks for your time and suggestions. After all, it wasn't backslash issue but i solved building libraries issue by adding 3rd parties one by one at each iteration and finally created libs correctly.

busrakkk gravatar imagebusrakkk ( 2016-01-18 06:19:22 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-01-14 07:32:41 -0600

Seen: 2,406 times

Last updated: Jan 15 '16