Closed ziyouchutuwenwu closed 5 years ago
cmake是clion自带的,当然我手动用debian自带的cmake,结果也是一样的,系统的cmake版本是
cmake --version
cmake version 3.7.2
CMake suite maintained and supported by Kitware (kitware.com/cmake).
改成下面这样,解决了
cmake_minimum_required(VERSION 3.7)
project(car_plate)
set(CMAKE_CXX_STANDARD 11)
find_package(OpenCV REQUIRED)
message(STATUS "OpenCV library status:")
message(STATUS " version: ${OpenCV_VERSION}")
message(STATUS " libraries: ${OpenCV_LIBS}")
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
include_directories(${OpenCV_INCLUDE_DIRS} "./easypr_sdk/include/")
link_directories(./easypr_sdk/lib/ /usr/bin/lib)
# link_libraries用在add_executable之前,target_link_libraries用在add_executable之后
# link_libraries用来链接静态库,target_link_libraries用来链接倒入库,即按照header file + .lib + .dll方式隐式调用动态库的.lib库
#link_libraries(libeasypr.a libthirdparty.a ${OpenCV_LIBS})
add_executable(car_plate main.cpp)
target_link_libraries(car_plate ${OpenCV_LIBS} libeasypr.a libthirdparty.a)
** debian下,编译opencv 3.2成功,easypr的项目也成功跑起来了,但是自己建立demo项目,抄的说明文档内的几行代码,编译错误,具体如下
using namespace cv; using namespace std; using namespace easypr;
int main() { CPlateRecognize pr; pr.setResultShow(false); pr.setDetectType(PR_DETECT_CMSER);
}
cmake_minimum_required(VERSION 3.7) project(car_plate)
set(CMAKE_CXX_STANDARD 11)
add_executable(car_plate main.cpp)
find_package(OpenCV REQUIRED) include_directories("./easypr_sdk/include/" ${OpenCV_INCLUDE_DIRS}) link_directories("./easypr_sdk/lib" ${OpenCV_LIBRARY_DIRS}) link_libraries(libeasypr.a ${OpenCV_LIBS})
├── CMakeLists.txt ├── easypr_sdk │ ├── include │ │ ├── easypr │ │ │ ├── api.hpp │ │ │ ├── config.h │ │ │ ├── core │ │ │ ├── train │ │ │ ├── util │ │ │ └── version.h │ │ └── easypr.h │ └── lib │ ├── libeasypr.a │ └── libthirdparty.a ├── main.cpp
====================[ Build | all | Debug ]===================================== /home/mmc/downloads/clion/bin/cmake/linux/bin/cmake --build /home/mmc/downloads/car_plate --target all -- -j 1 Scanning dependencies of target car_plate [ 50%] Building CXX object CMakeFiles/car_plate.dir/main.cpp.o [100%] Linking CXX executable car_plate CMakeFiles/car_plate.dir/main.cpp.o:在函数‘easypr::api::plate_judge(char const, char const)’中: /home/mmc/downloads/car_plate/./easypr_sdk/include/easypr/api.hpp:17:对‘cv::imread(cv::String const&, int)’未定义的引用 /home/mmc/downloads/car_plate/./easypr_sdk/include/easypr/api.hpp:21:对‘easypr::PlateJudge::instance()’未定义的引用 /home/mmc/downloads/car_plate/./easypr_sdk/include/easypr/api.hpp:21:对‘easypr::PlateJudge::plateJudge(cv::Mat const&)’未定义的引用 CMakeFiles/car_plate.dir/main.cpp.o:在函数‘easypr::api::plate_locate(char const, bool)’中: /home/mmc/downloads/car_plate/./easypr_sdk/include/easypr/api.hpp:27:对‘cv::imread(cv::String const&, int)’未定义的引用 /home/mmc/downloads/car_plate/./easypr_sdk/include/easypr/api.hpp:31:对‘easypr::CPlateLocate::CPlateLocate()’未定义的引用 /home/mmc/downloads/car_plate/./easypr_sdk/include/easypr/api.hpp:33:对‘easypr::CPlateLocate::setLifemode(bool)’未定义的引用 /home/mmc/downloads/car_plate/./easypr_sdk/include/easypr/api.hpp:36:对‘easypr::CPlateLocate::plateLocate(cv::Mat, std::vector<cv::Mat, std::allocator >&, int)’未定义的引用
CMakeFiles/car_plate.dir/main.cpp.o:在函数‘easypr::api::plate_recognize(char const , char const, char const, bool)’中:
/home/mmc/downloads/car_plate/./easypr_sdk/include/easypr/api.hpp:43:对‘cv::imread(cv::String const&, int)’未定义的引用
/home/mmc/downloads/car_plate/./easypr_sdk/include/easypr/api.hpp:46:对‘easypr::CPlateRecognize::CPlateRecognize()’未定义的引用
/home/mmc/downloads/car_plate/./easypr_sdk/include/easypr/api.hpp:54:对‘easypr::CPlateRecognize::plateRecognize(cv::Mat const&, std::vector<easypr::CPlate, std::allocator >&, int)’未定义的引用
/home/mmc/downloads/car_plate/./easypr_sdk/include/easypr/api.hpp:65:对‘cv::imwrite(cv::String const&, cv::_InputArray const&, std::vector<int, std::allocator > const&)’未定义的引用
CMakeFiles/car_plate.dir/main.cpp.o:在函数‘easypr::api::get_plate_color(char const)’中:
/home/mmc/downloads/car_plate/./easypr_sdk/include/easypr/api.hpp:73:对‘cv::imread(cv::String const&, int)’未定义的引用
/home/mmc/downloads/car_plate/./easypr_sdk/include/easypr/api.hpp:77:对‘easypr::getPlateType(cv::Mat const&, bool)’未定义的引用
CMakeFiles/car_plate.dir/main.cpp.o:在函数‘cv::String::String(char const)’中:
/usr/local/include/opencv2/core/cvstd.hpp:622:对‘cv::String::allocate(unsigned long)’未定义的引用
CMakeFiles/car_plate.dir/main.cpp.o:在函数‘cv::String::~String()’中:
/usr/local/include/opencv2/core/cvstd.hpp:664:对‘cv::String::deallocate()’未定义的引用
CMakeFiles/car_plate.dir/main.cpp.o:在函数‘cv::String::operator=(cv::String const&)’中:
/usr/local/include/opencv2/core/cvstd.hpp:672:对‘cv::String::deallocate()’未定义的引用
CMakeFiles/car_plate.dir/main.cpp.o:在函数‘cv::Mat::Mat(cv::Mat const&)’中:
/usr/local/include/opencv2/core/mat.inl.hpp:421:对‘cv::Mat::copySize(cv::Mat const&)’未定义的引用
CMakeFiles/car_plate.dir/main.cpp.o:在函数‘cv::Mat::~Mat()’中:
/usr/local/include/opencv2/core/mat.inl.hpp:592:对‘cv::fastFree(void*)’未定义的引用
CMakeFiles/car_plate.dir/main.cpp.o:在函数‘cv::Mat::operator=(cv::Mat const&)’中:
/usr/local/include/opencv2/core/mat.inl.hpp:613:对‘cv::Mat::copySize(cv::Mat const&)’未定义的引用
CMakeFiles/car_plate.dir/main.cpp.o:在函数‘cv::Mat::release()’中:
/usr/local/include/opencv2/core/mat.inl.hpp:704:对‘cv::Mat::deallocate()’未定义的引用
CMakeFiles/car_plate.dir/main.cpp.o:在函数‘cv::String::String(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)’中:
/usr/local/include/opencv2/core/cvstd.inl.hpp:81:对‘cv::String::allocate(unsigned long)’未定义的引用
CMakeFiles/car_plate.dir/main.cpp.o:在函数‘easypr::CPlateDetect::setPDLifemode(bool)’中:
/home/mmc/downloads/car_plate/./easypr_sdk/include/easypr/core/plate_detect.h:42:对‘easypr::CPlateLocate::setLifemode(bool)’未定义的引用
CMakeFiles/car_plate.dir/main.cpp.o:在函数‘easypr::CPlateRecognize::~CPlateRecognize()’中:
/home/mmc/downloads/car_plate/./easypr_sdk/include/easypr/core/plate_recognize.h:23:对‘easypr::CCharsRecognise::~CCharsRecognise()’未定义的引用
/home/mmc/downloads/car_plate/./easypr_sdk/include/easypr/core/plate_recognize.h:23:对‘easypr::CPlateDetect::~CPlateDetect()’未定义的引用
collect2: error: ld returned 1 exit status
CMakeFiles/car_plate.dir/build.make:94: recipe for target 'car_plate' failed
make[2]: [car_plate] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/car_plate.dir/all' failed
make[1]: [CMakeFiles/car_plate.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2