Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

undefined reference to `cv::imread

$
0
0
Hi, I'm using CLion as IDE and trying to link OpenCV. But I'm having problem even with a very simple app. I prepared OpenCV binaries with these steps. 1. Extract OpenCV files (from official website) 2. Generate a build folder with CMake 3. In the directory generated by CMake, execute "mingw32-make" command 4. Add "OPENCV_DIR" to system variables. ("C:\OpenCV\mingw-build" in my case) 5. Add "%OPENCV_DIR%\bin" to system path My CPP Code: #include #include #include using namespace std; using namespace cv; int main() { string file = "image.jpg"; Mat img = imread(file.c_str(), 1); namedWindow("image", WINDOW_AUTOSIZE); imshow("image", img); waitKey(0); return 0; } My CMakeLists.txt cmake_minimum_required(VERSION 3.6) project(OpenCVFirstDemo) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") find_package(OpenCV REQUIRED) set(SOURCE_FILES main.cpp) add_executable(OpenCVFirstDemo ${SOURCE_FILES}) target_link_libraries(OpenCVFirstDemo ${OpenCV_LIBS}) And when I try to build, I'm getting the following messages. "C:\Program Files (x86)\JetBrains\CLion 2016.2.3\bin\cmake\bin\cmake.exe" --build C:\Users\CagdasX\.CLion2016.2\system\cmake\generated\OpenCVFirstDemo-f9ecc709\f9ecc709\Debug --target OpenCVFirstDemo -- -j 8 Scanning dependencies of target OpenCVFirstDemo [ 50%] Building CXX object CMakeFiles/OpenCVFirstDemo.dir/main.cpp.obj [100%] Linking CXX executable OpenCVFirstDemo.exe CMakeFiles\OpenCVFirstDemo.dir/objects.a(main.cpp.obj): In function `main': C:/Users/CagdasX/ClionProjects/OpenCVFirstDemo/main.cpp:9: undefined reference to `cv::imread(cv::String const&, int)' C:/Users/CagdasX/ClionProjects/OpenCVFirstDemo/main.cpp:10: undefined reference to `cv::namedWindow(cv::String const&, int)' C:/Users/CagdasX/ClionProjects/OpenCVFirstDemo/main.cpp:11: undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)' C:/Users/CagdasX/ClionProjects/OpenCVFirstDemo/main.cpp:12: undefined reference to `cv::waitKey(int)' CMakeFiles\OpenCVFirstDemo.dir/objects.a(main.cpp.obj): In function `ZN2cv6StringC1EPKc': C:/OpenCV/sources/modules/core/include/opencv2/core/cvstd.hpp:625: undefined reference to `cv::String::allocate(unsigned int)' CMakeFiles\OpenCVFirstDemo.dir/objects.a(main.cpp.obj): In function `ZN2cv6StringD1Ev': C:/OpenCV/sources/modules/core/include/opencv2/core/cvstd.hpp:667: undefined reference to `cv::String::deallocate()' CMakeFiles\OpenCVFirstDemo.dir/objects.a(main.cpp.obj): In function `ZN2cv3MatD1Ev': C:/OpenCV/sources/modules/core/include/opencv2/core/mat.inl.hpp:571: undefined reference to `cv::fastFree(void*)' CMakeFiles\OpenCVFirstDemo.dir/objects.a(main.cpp.obj): In function `ZN2cv3Mat7releaseEv': C:/OpenCV/sources/modules/core/include/opencv2/core/mat.inl.hpp:682: undefined reference to `cv::Mat::deallocate()' collect2.exe: error: ld returned 1 exit status CMakeFiles\OpenCVFirstDemo.dir\build.make:112: recipe for target 'OpenCVFirstDemo.exe' failed CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/OpenCVFirstDemo.dir/all' failed mingw32-make.exe[3]: *** [OpenCVFirstDemo.exe] Error 1 CMakeFiles\Makefile2:78: recipe for target 'CMakeFiles/OpenCVFirstDemo.dir/rule' failed mingw32-make.exe[2]: *** [CMakeFiles/OpenCVFirstDemo.dir/all] Error 2 mingw32-make.exe[1]: *** [CMakeFiles/OpenCVFirstDemo.dir/rule] Error 2 Makefile:117: recipe for target 'OpenCVFirstDemo' failed mingw32-make.exe: *** [OpenCVFirstDemo] Error 2

Viewing all articles
Browse latest Browse all 19555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>