error LNK2019 mexOpenCV

1 visualizzazione (ultimi 30 giorni)
Lukas Capan
Lukas Capan il 5 Mag 2022
Risposto: Abhishek Chakram il 19 Dic 2023
I get the failure LNK2019 when creating a mex file. The problem is the row "icp.registerModelToScene(fix,moving,residual,pose);"
As soon as i decomment the row, the creating of the mex file and the executing is successfull.
I downloaded the OpenCV library from the Homepage and copied it in the installation folder, because some hpp files were missing (maybe old version?).
I´m using Microsoft Visual C++ 2019 Compiler.
#include "mex.h"
#include "opencvmex.hpp"
#include "matrix.h"
#include <opencv2/surface_matching/pose_3d.hpp>
#include <opencv2/surface_matching/ppf_helpers.hpp>
#include <opencv2/surface_matching/ppf_match_3d.hpp>
#include <opencv2/surface_matching/t_hash_int.hpp>
#include <opencv2/surface_matching/icp.hpp>
#include "opencv2/core/cvstd.hpp"
#define _DO_NOT_EXPORT
#if defined(_DO_NOT_EXPORT)
#define DllExport
#else
#define DllExport __declspec(dllexport)
#endif
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
double residual;
int i;
cv::Matx44d pose;
cv::Mat* tempMat;
ocvMxArrayToMat_double(prhs[1], tempMat);
cv::Mat fix;
tempMat->assignTo(fix,CV_32F);
ocvMxArrayToMat_double(prhs[0], tempMat);
cv::Mat moving;
tempMat->assignTo(moving,CV_32F);
cv::ppf_match_3d::ICP icp(200, 0.001f, 2.5f, 8);
// Problem
icp.registerModelToScene(fix,moving,residual,pose);
}

Risposte (1)

Abhishek Chakram
Abhishek Chakram il 19 Dic 2023
Hi Lukas Capan,
It is my understanding that you are facing the error LNK2019, when trying to create a mex file. The error LNK2019 is a linker error indicating that the linker cannot find an external symbol that was referenced in the code. Here, the linker cannot find the implementation of “registerModelToScene” method in the linked libraries.
Here are some steps to troubleshoot and resolve this issue:
  • Ensure OpenCV is Properly Linked: Make sure that you have correctly set up the linker to include the OpenCV libraries that contain the implementation of “registerModelToScene”.
  • Check OpenCV Version: Make sure you are using the correct version of OpenCV that includes the “ppf_match_3d” module.
  • OpenCV with MATLAB: If you are using a pre-built OpenCV with MATLAB, make sure that it is compatible with the version of MATLAB you are using.
  • Recompile and Link: After making sure all paths and libraries are correctly set up, recompile the mex file and ensure that all necessary libraries are linked.
Best Regards,
Abhishek Chakram

Prodotti


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by