1

I am trying to run some code which requires openCV. The issue is that to compile this code and add the specific openCV features I need, I have to add those libraries to the given Makefile. I know that when compiling my openCV code via the command line I can just do

g++ opencv.cpp -lopencv_core -lopencv_imgproc -lopencv_highgui -o opencv

(Or some slight variant as well)

Now that I have this Makefile, I am a bit lost about where exactly I need to add

-lopencv_core -lopencv_imgproc -lopencv_highgui

My guess is that some of those three might already be linked, but not all three of them.

Could somebody help me out?

The Makefile in question: http://paste.ubuntu.com/25192259/ Or should I modify the original CMakeLists.txt file?

source: https://github.com/patrikhuber/eos

Thanks!

EDIT:

Actually for some reason it doesn't find those libs. When I compile my code I get a bunch of linking errors "undefined reference xyz". Because I need to add those 3 libs somehow. Whenever I write openCV code for another project I always compile it from the command line and add all the depencencies/libs/... manually.

So far I've also tried modifying CMakeCache.txt using:

cmake -DCMAKE_EXE_LINKER_FLAGS="-lopencv_core -lopencv_imgproc -lopencv_highgui" ../eos

result:

yalishanda@yalishanda-thinkpad-x200:~/Desktop/John/1/2/software/computerVision/myTests/2/build$ cmake -DCMAKE_EXE_LINKER_FLAGS="-lopencv_core -lopencv_imgproc -lopencv_highgui" ../eos
cmake: /home/yalishanda/anaconda2/lib/libcurl.so.4: no version information available (required by cmake)
-- Options:
-- EOS_BUILD_EXAMPLES: ON
-- EOS_BUILD_CERES_EXAMPLE: OFF
-- EOS_BUILD_UTILS: OFF
-- EOS_BUILD_DOCUMENTATION: OFF
-- EOS_GENERATE_PYTHON_BINDINGS: OFF
-- EOS_GENERATE_MATLAB_BINDINGS: OFF
-- Found OpenCV: /usr/local (found version "3.2.0") found components:  core 
-- Boost version: 1.58.0
-- Found the following Boost libraries:
--   system
-- Boost found at /usr/include
-- Eigen3 found: TRUE, version: 3.3.3
-- Eigen3 include dir found at /home/yalishanda/Desktop/John/1/2/software/computerVision/myTests/2/eos/3rdparty/eigen
-- OpenCV 3.x detected - including imgcodecs for compatibility
-- Found OpenCV: /usr/local (found suitable version "3.2.0", minimum required is "3") found components:  core imgproc imgcodecs 
-- Boost version: 1.58.0
-- Found the following Boost libraries:
--   system
--   filesystem
--   program_options
-- Boost found at /usr/include
-- Configuring done
-- Generating done
-- Build files have been written to: /home/yalishanda/Desktop/John/1/2/software/computerVision/myTests/2/build
yalishanda@yalishanda-thinkpad-x200:~/Desktop/John/1/2/software/computerVision/myTests/2/build$ make
/usr/bin/cmake: /home/yalishanda/anaconda2/lib/libcurl.so.4: no version information available (required by /usr/bin/cmake)
/usr/bin/cmake: /home/yalishanda/anaconda2/lib/libcurl.so.4: no version information available (required by /usr/bin/cmake)
/usr/bin/cmake: /home/yalishanda/anaconda2/lib/libcurl.so.4: no version information available (required by /usr/bin/cmake)
/usr/bin/cmake: /home/yalishanda/anaconda2/lib/libcurl.so.4: no version information available (required by /usr/bin/cmake)
[ 25%] Linking CXX executable myFaceFit
/usr/bin/cmake: /home/yalishanda/anaconda2/lib/libcurl.so.4: no version information available (required by /usr/bin/cmake)
CMakeFiles/myFaceFit.dir/myFaceFit.cpp.o: In function `main':
myFaceFit.cpp:(.text+0x20da): undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'
myFaceFit.cpp:(.text+0x2102): undefined reference to `cv::waitKey(int)'
collect2: error: ld returned 1 exit status
examples/CMakeFiles/myFaceFit.dir/build.make:100: recipe for target 'examples/myFaceFit' failed
make[2]: *** [examples/myFaceFit] Error 1
CMakeFiles/Makefile2:119: recipe for target 'examples/CMakeFiles/myFaceFit.dir/all' failed
make[1]: *** [examples/CMakeFiles/myFaceFit.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2

and

CMAKE_SHARED_LINKER_FLAGS as well:

$ cmake -DCMAKE_SHARED_LINKER_FLAGS="-lopencv_core -lopencv_imgproc -lopencv_highgui" ../eos
cmake: /home/john/anaconda2/lib/libcurl.so.4: no version information available (required by cmake)
-- Options:
-- EOS_BUILD_EXAMPLES: ON
-- EOS_BUILD_CERES_EXAMPLE: OFF
-- EOS_BUILD_UTILS: OFF
-- EOS_BUILD_DOCUMENTATION: OFF
-- EOS_GENERATE_PYTHON_BINDINGS: OFF
-- EOS_GENERATE_MATLAB_BINDINGS: OFF
-- Found OpenCV: /usr/local (found version "3.2.0") found components:  core 
-- Boost version: 1.58.0
-- Found the following Boost libraries:
--   system
-- Boost found at /usr/include
-- Eigen3 found: TRUE, version: 3.3.3
-- Eigen3 include dir found at /home/yalishanda/Desktop/john/1/2/software/computerVision/myTests/2/eos/3rdparty/eigen
-- OpenCV 3.x detected - including imgcodecs for compatibility
-- Found OpenCV: /usr/local (found suitable version "3.2.0", minimum required is "3") found components:  core imgproc imgcodecs 
-- Boost version: 1.58.0
-- Found the following Boost libraries:
--   system
--   filesystem
--   program_options
-- Boost found at /usr/include
-- Configuring done
-- Generating done
-- Build files have been written to: /home/yalishanda/Desktop/john/1/2/software/computerVision/myTests/2/build
yalishanda@yalishanda-thinkpad-x200:~/Desktop/john/1/2/software/computerVision/myTests/2/build$ make
/usr/bin/cmake: /home/yalishanda/anaconda2/lib/libcurl.so.4: no version information available (required by /usr/bin/cmake)
/usr/bin/cmake: /home/yalishanda/anaconda2/lib/libcurl.so.4: no version information available (required by /usr/bin/cmake)
/usr/bin/cmake: /home/yalishanda/anaconda2/lib/libcurl.so.4: no version information available (required by /usr/bin/cmake)
/usr/bin/cmake: /home/yalishanda/anaconda2/lib/libcurl.so.4: no version information available (required by /usr/bin/cmake)
[ 25%] Linking CXX executable myFaceFit
/usr/bin/cmake: /home/yalishanda/anaconda2/lib/libcurl.so.4: no version information available (required by /usr/bin/cmake)
CMakeFiles/myFaceFit.dir/myFaceFit.cpp.o: In function `main':
myFaceFit.cpp:(.text+0x20da): undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'
myFaceFit.cpp:(.text+0x2102): undefined reference to `cv::waitKey(int)'
collect2: error: ld returned 1 exit status
examples/CMakeFiles/myFaceFit.dir/build.make:100: recipe for target 'examples/myFaceFit' failed
make[2]: *** [examples/myFaceFit] Error 1
CMakeFiles/Makefile2:119: recipe for target 'examples/CMakeFiles/myFaceFit.dir/all' failed
make[1]: *** [examples/CMakeFiles/myFaceFit.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2

0

You must log in to answer this question.

Browse other questions tagged .