I need to modfiy some OPENCV source files (VS 2019, C++) but get this error. I have OpenCV version 4.6. which is installed with CMAKE and it works well untill I try to add a new function in source files. More precilsely, I have performed the following
- I have modified source feature2d.cpp by adding the following test function
void mynewtest()
{
std::cout<<" this is opencv";
}
- Added in source features2d.hpp the following
void mynewtest();
Then I build ALL_BUILD and build INSTALL using OpenCV.sln in build folder
Next, I have tried to run the following standard code, which gives LNK 2001 Error
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/features2d.hpp>
#include <iostream>
using namespace cv;
int main()
{
mynewtest(); //--- ADDED FUNCTION
//-----------------------------------------------------------;
std::string image_path = samples::findFile("starry_night.jpg");
Mat img = imread(image_path, IMREAD_COLOR);
if (img.empty())
{
std::cout << "Could not read the image: " << image_path << std::endl;
return 1;
}
imshow("Display window", img);
int k = waitKey(0); // Wait for a keystroke in the window
if (k == 's')
{
imwrite("starry_night.png", img);
}
return 0;
}
If I comment mynewtest(); then the code starts normally. As I understand smth is with linking lib libriries but all the libs are linked well
have tried to re-build opencv using cmake