i just got started with c++ and have been trying to use OpenCV for an GUI.
I installed Cmake, Ninja and OpenCV into my C:/ directory. I now planned to Build the Project but i get an error in the Linking stage of Compilation.
Here is the log:
[main] Building folder: opencvtest [main] Configuring project: opencvtest [proc] Executing command: "C:Program FilesCMakebincmake.EXE" --no-warn-unused-cli - DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -SC:/opencvtest -Bc:/ opencvtest/build -G Ninja [cmake] Not searching for unused variables given on the command line. [cmake] -- Configuring done (0.2s) [cmake] -- Generating done (0.1s) [cmake] -- Build files have been written to: C:/opencvtest/build [build] Starting build [proc] Executing command: chcp [proc] Executing command: "C:Program FilesCMakebincmake.EXE" --build c:/opencvtest/build -- config Debug --target all -- [build] [1/1 100% :: 0.205] Linking CXX executable opencvtest.exe [build] FAILED: opencvtest.exe [build] C:Windowssystem32cmd.exe /C "cd . && C:msys64ucrt64binc++.exe -g CMakeFiles/ opencvtest.dir/main.cpp.obj -o opencvtest.exe -Wl,--out-implib,libopencvtest.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -LC:/PROGRA~1/opencv/build/x64/vc16/lib -lopencv_world4100d -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ." [build] C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/ bin/ld.exe: CMakeFiles/opencvtest.dir/main.cpp.obj: in function
main’:
[build] C:/opencvtest/main.cpp:8: undefined reference to cv::Mat::Mat()' [build] C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/opencvtest/main.cpp:19: undefined reference to
cv::Mat::~Mat()’
[build] collect2.exe: error: ld returned 1 exit status
[build] ninja: build stopped: subcommand failed.
[proc] The command: “C:Program FilesCMakebincmake.EXE” –build c:/opencvtest/build –config Debug –target all — exited with code: 1
[driver] Build completed: 00:00:00.360
[build] Build finished with exit code 1
`
My CMake List file looks like this (although i dont think the problem inherits from there):
`cmake_minimum_required(VERSION 3.10)
project(opencvtest)
set(CMAKE_CXX_STANDARD 11)
Specify the path to OpenCV headers
include_directories(“C:/Program Files/opencv/build/include”)
Specify the path to OpenCV library directories
link_directories(“C:/Program Files/opencv/build/x64/vc16/lib”)
Add the executable
add_executable(opencvtest main.cpp)
Link against the OpenCV libraries
target_link_libraries(opencvtest opencv_world4100d)
`
And finally the main.cpp:
`#include <stdio.h>
#include <opencv2/opencv.hpp>
int main(int argc, char** argv )
{
cv::Mat image;
/**image = imread("C:\opencvtest\1.jpg");
if ( !image.data )
{
printf("No image data n");
return -1;
}**/
//namedWindow("Display Image", WINDOW_AUTOSIZE );
//imshow("Display Image", image);
//waitKey(0);
return 0;
}`
Thanks in advance
I`ve already checked the System variables (opencv_version outputs the version number)
Intelisense gets that the include is legid (if the lib folder is deletet it males Squiggles)
user25670157 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.