我正在尝试在本地安装并编译我的程序。我已经使用cmake配置安装了OpenCV-2.4.10:
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=~/opencv/installation/ -D CUDA_GENERATION=Kepler -D CMAKE_CXX_COMPILER=/usr/bin/g++-4.9 -D CMAKE_C_COMPILER=/usr/bin/gcc-4.9 -DWITH_FFMPEG=OFF ..
在文件夹~/opencv/opencv-2.4.10/build
然后我设置了环境变量export OpenCV_DIR=/lhome/home/golda/opencv/opencv-2.4.10/build
之前尝试使用cmake编译我的程序。设置OpenCV_DIR
后,cmake返回没有错误。这是与OpenCV连接的CMakeCache.txt片段(带有我的主目录的完整路径。我用它替换它
'〜'):
//Path where debug 3rdpaty OpenCV dependencies are located
OpenCV_3RDPARTY_LIB_DIR_DBG:PATH=
//Path where release 3rdpaty OpenCV dependencies are located
OpenCV_3RDPARTY_LIB_DIR_OPT:PATH=
OpenCV_CONFIG_PATH:FILEPATH=~/opencv/opencv-2.4.10/build
//The directory containing a CMake configuration file for OpenCV.
OpenCV_DIR:PATH=~/opencv/opencv-2.4.10/build
//Path where debug OpenCV libraries are located
OpenCV_LIB_DIR_DBG:PATH=
//Path where release OpenCV libraries are located
OpenCV_LIB_DIR_OPT:PATH=
最后在make
之后我收到了undefined reference to 'cv::imread'
我尝试过添加路径:
~/opencv/opencv-2.4.10/build/lib:
~/opencv/opencv-2.4.10/include/opencv:
分别为变量:LD_LIBRARY_PATH
和INCLUDE_PATH
我的问题是我应该怎么做才能解决这个问题?我现在缺乏想法。