fixstars / libSGM

Stereo Semi Global Matching by cuda
Apache License 2.0
623 stars 189 forks source link

Cannot find `lsgm` #61

Open bchao1 opened 4 years ago

bchao1 commented 4 years ago

After building libsgm by following the steps in README, I tested out code in sample/image. I executed the following:

mkdir build
cd build
cmake ../
make

and got the following error:

/usr/bin/ld: cannot find -lsgm
collect2: error: ld returned 1 exit status
CMakeFiles/stereo_test.dir/build.make:148: recipe for target 'stereo_test' failed
make[2]: *** [stereo_test] Error 1
CMakeFiles/Makefile2:75: recipe for target 'CMakeFiles/stereo_test.dir/all' failed
make[1]: *** [CMakeFiles/stereo_test.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

Why is this error happening?

ghost commented 4 years ago

Hi. @bchao1 Are you saying that building samples failed?

Try following build instruction:

developer@de01b56f2148:/tmp$ git clone https://github.com/fixstars/libSGM
Cloning into 'libSGM'...
remote: Enumerating objects: 2129, done.
remote: Total 2129 (delta 0), reused 0 (delta 0), pack-reused 2129
Receiving objects: 100% (2129/2129), 346.91 KiB | 595.00 KiB/s, done.
Resolving deltas: 100% (1384/1384), done.
developer@de01b56f2148:/tmp$ cd libSGM/
developer@de01b56f2148:/tmp/libSGM$ mkdir build
developer@de01b56f2148:/tmp/libSGM$ cd build/
developer@de01b56f2148:/tmp/libSGM/build$ cmake .. -DENABLE_SAMPLES=on
developer@de01b56f2148:/tmp/libSGM/build$ make
developer@de01b56f2148:/tmp/libSGM/build$ ls sample/image/
CMakeFiles  Makefile  cmake_install.cmake  stereo_test
bchao1 commented 4 years ago

After executing the above commands, I got the following error message:

[ 68%] Building CXX object sample/image/CMakeFiles/stereo_test.dir/stereosgm_image.cpp.o
[ 72%] Linking CXX executable stereo_test
CMakeFiles/stereo_test.dir/stereosgm_image.cpp.o: In function `std::string cv::CommandLineParser::get<std::string>(std::string const&, bool) const':
stereosgm_image.cpp:(.text._ZNK2cv17CommandLineParser3getISsEET_RKSsb[_ZNK2cv17CommandLineParser3getISsEET_RKSsb]+0x32): undefined reference to `cv::CommandLineParser::getByName(std::string const&, bool, cv::Param, void*) const'
CMakeFiles/stereo_test.dir/stereosgm_image.cpp.o: In function `main':
stereosgm_image.cpp:(.text.startup+0x87): undefined reference to `cv::CommandLineParser::CommandLineParser(int, char const* const*, std::string const&)'
stereosgm_image.cpp:(.text.startup+0xca): undefined reference to `cv::CommandLineParser::has(std::string const&) const'
stereosgm_image.cpp:(.text.startup+0x16f): undefined reference to `cv::imread(std::string const&, int)'
stereosgm_image.cpp:(.text.startup+0x1ec): undefined reference to `cv::imread(std::string const&, int)'
stereosgm_image.cpp:(.text.startup+0x273): undefined reference to `cv::CommandLineParser::getByName(std::string const&, bool, cv::Param, void*) const'
stereosgm_image.cpp:(.text.startup+0x2da): undefined reference to `cv::CommandLineParser::getByName(std::string const&, bool, cv::Param, void*) const'
stereosgm_image.cpp:(.text.startup+0x33c): undefined reference to `cv::CommandLineParser::getByName(std::string const&, bool, cv::Param, void*) const'
stereosgm_image.cpp:(.text.startup+0x3a1): undefined reference to `cv::CommandLineParser::getByName(std::string const&, bool, cv::Param, void*) const'
stereosgm_image.cpp:(.text.startup+0x40c): undefined reference to `cv::CommandLineParser::getByName(std::string const&, bool, cv::Param, void*) const'
CMakeFiles/stereo_test.dir/stereosgm_image.cpp.o:stereosgm_image.cpp:(.text.startup+0x46d): more undefined references to `cv::CommandLineParser::getByName(std::string const&, bool, cv::Param, void*) const' follow
CMakeFiles/stereo_test.dir/stereosgm_image.cpp.o: In function `main':
stereosgm_image.cpp:(.text.startup+0xfd1): undefined reference to `cv::setWindowTitle(std::string const&, std::string const&)'
stereosgm_image.cpp:(.text.startup+0x1048): undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)'
collect2: error: ld returned 1 exit status
sample/image/CMakeFiles/stereo_test.dir/build.make:149: recipe for target 'sample/image/stereo_test' failed
make[2]: *** [sample/image/stereo_test] Error 1
CMakeFiles/Makefile2:147: recipe for target 'sample/image/CMakeFiles/stereo_test.dir/all' failed
make[1]: *** [sample/image/CMakeFiles/stereo_test.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
ghost commented 4 years ago

CMake checks OpenCV exists before build. From your log, linking OpenCV failed. So I suspect that OpenCV installation failed.

Did you succeed to build any programs using OpenCV?

bchao1 commented 4 years ago

I'm using opencv4 and I'm sure that I've got opencv on my computer. I added some messages in the top-level CMakeLists.txt:

-- Found OpenCV: /usr/local (found version "4.2.0") 
-- OpenCV library status:
--     version: 4.2.0
--     libraries: opencv_calib3d;opencv_core;opencv_dnn;opencv_features2d;opencv_flann;opencv_gapi;opencv_highgui;opencv_imgcodecs;opencv_imgproc;opencv_ml;opencv_objdetect;opencv_photo;opencv_stitching;opencv_video;opencv_videoio;opencv_aruco;opencv_bgsegm;opencv_bioinspired;opencv_ccalib;opencv_cudaarithm;opencv_cudabgsegm;opencv_cudafeatures2d;opencv_cudafilters;opencv_cudaimgproc;opencv_cudalegacy;opencv_cudaobjdetect;opencv_cudaoptflow;opencv_cudastereo;opencv_cudawarping;opencv_cudev;opencv_datasets;opencv_dnn_objdetect;opencv_dnn_superres;opencv_dpm;opencv_face;opencv_freetype;opencv_fuzzy;opencv_hdf;opencv_hfs;opencv_img_hash;opencv_line_descriptor;opencv_optflow;opencv_phase_unwrapping;opencv_plot;opencv_quality;opencv_reg;opencv_rgbd;opencv_saliency;opencv_sfm;opencv_shape;opencv_stereo;opencv_structured_light;opencv_superres;opencv_surface_matching;opencv_text;opencv_tracking;opencv_videostab;opencv_xfeatures2d;opencv_ximgproc;opencv_xobjdetect;opencv_xphoto
--     include path: /usr/local/include/opencv4

Not sure why make is not successfully compiling though. Thanks!

bchao1 commented 4 years ago

How can I manually compile a single sample in the samples/ folder?

ghost commented 4 years ago

I haven't tried that. I think it needs to build after Add specify link instruction to CMakeLists.txt manually.

sisco0 commented 3 years ago

Hello @bchao1 , did you try to append at the file specified below, just after core, the words highgui and imgproc? Maybe that is what is left. Please tell me if that works for you. https://github.com/fixstars/libSGM/blob/b44351ba8a4ac61d3a87ae4e4224782674bab6b5/CMakeLists.txt#L28

Who knows if that should be added at the file below as well. https://github.com/fixstars/libSGM/blob/b44351ba8a4ac61d3a87ae4e4224782674bab6b5/sample/image_cv_gpumat/CMakeLists.txt#L11