Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake build errors #1

Closed
billamiable opened this issue Sep 2, 2017 · 4 comments
Closed

cmake build errors #1

billamiable opened this issue Sep 2, 2017 · 4 comments

Comments

@billamiable
Copy link

Hi I tried to use cmake to build (mkdir build && cd build && cmake ..), it worked well. But errors happened in make. Anyone encountered same problem?

[100%] Linking CXX executable CPM
/usr/bin/ld: cannot find -lopencv_core310.lib
/usr/bin/ld: cannot find -lopencv_highgui310.lib
/usr/bin/ld: cannot find -lopencv_imgcodecs310.lib
/usr/bin/ld: cannot find -lopencv_imgproc310.lib
collect2: error: ld returned 1 exit status
CMakeFiles/CPM.dir/build.make:120: recipe for target 'CPM' failed
make[2]: *** [CPM] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/CPM.dir/all' failed
make[1]: *** [CMakeFiles/CPM.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

Please offer some help~ Thx~

@csukuangfj
Copy link
Contributor

csukuangfj commented Sep 7, 2017

@billamiable
You need to install OpenCV first.
If your OpenCV is installed inside the directory "C:/OpenCV", then the original CMakeLists.txt
works fine. Otherwise you need to change the following content in the CMakeLists.txt

INCLUDE_DIRECTORIES(
./include
C:/OpenCV/include
C:/OpenCV/include/opencv
C:/OpenCV/include/opencv2
)

LINK_DIRECTORIES(
C:/OpenCV/lib/x86/Debug
C:/OpenCV/lib/x86/Release
)

Change C:/OpenCV to your OpenCV installation directory.

The first one specifies the OpenCV headers and the second one is the OpenCV libraries.

If you are using Linux, then please replace the whole content of
the CMakeLists.txt with the following code (I assume that you have installed OpenCV corrrectly)

cmake_minimum_required(VERSION 2.6)
set(PROJ_NAME CPM)
project (${PROJ_NAME})

find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})

add_definitions(-DWITH_SSE)

include_directories(./include)

add_executable(${PROJ_NAME} main.cpp CPM.cpp)
target_link_libraries(${PROJ_NAME} ${OpenCV_LIBS})

@billamiable
Copy link
Author

@csukuangfj
Thanks for your reply !!!
The original CMakeLists.txt is for Windows, I am using linux and your approach works fine !!!
Many thanks!

@csukuangfj
Copy link
Contributor

This issue can be closed now.

@YinlinHu
Copy link
Owner

Thanks @csukuangfj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants