Unresolved externals when creating a mex function
I am creating a simple mex function for the OpenCV imread() function. This will allow me to read freames from a camera stream.
I receive an error stating that I have two, unresolved externals as shown below:
error LNK2019: unresolved external symbol "class cv::Mat __cdecl cv::imread(class std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> > const &,int)"
I am able to use the imread() functionality directly from Visual Studio in my Python and C++ scripts so there is no problem with my OpenCV download. In the code that I have pasted below, all functionallity with the cv::createBackgroundSubtractorMOG2() works perfectly. ie: when I compile the mex function with only that functionallity, it works fine.
Why is it that functionallity with the cv::createBackgroundSubtractorMOG2() works fine but when I add in the imread() function it gives me the errors.
This is my code:
#include "opencvmex.hpp"
using namespace cv;
static Ptr<BackgroundSubtractorMOG2> ptrBackgroundModel = cv::createBackgroundSubtractorMOG2();
// Static smart pointer to hold the loaded image
static Ptr<Mat> ptrImage = makePtr<Mat>();
// Function to load an image from a file
void loadImageFromFile(const std::string& filename) {
// Load the image from file
Mat image = cv::imread(filename);
// Assign the loaded image to the static smart pointer
*ptrImage = image;
}I am creating a simple mex function for the OpenCV imread() function. This will allow me to read freames from a camera stream.
I receive an error stating that I have two, unresolved externals as shown below:
error LNK2019: unresolved external symbol "class cv::Mat __cdecl cv::imread(class std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> > const &,int)"
I am able to use the imread() functionality directly from Visual Studio in my Python and C++ scripts so there is no problem with my OpenCV download. In the code that I have pasted below, all functionallity with the cv::createBackgroundSubtractorMOG2() works perfectly. ie: when I compile the mex function with only that functionallity, it works fine.
Why is it that functionallity with the cv::createBackgroundSubtractorMOG2() works fine but when I add in the imread() function it gives me the errors.
This is my code:
#include "opencvmex.hpp"
using namespace cv;
static Ptr<BackgroundSubtractorMOG2> ptrBackgroundModel = cv::createBackgroundSubtractorMOG2();
// Static smart pointer to hold the loaded image
static Ptr<Mat> ptrImage = makePtr<Mat>();
// Function to load an image from a file
void loadImageFromFile(const std::string& filename) {
// Load the image from file
Mat image = cv::imread(filename);
// Assign the loaded image to the static smart pointer
*ptrImage = image;
} I am creating a simple mex function for the OpenCV imread() function. This will allow me to read freames from a camera stream.
I receive an error stating that I have two, unresolved externals as shown below:
error LNK2019: unresolved external symbol "class cv::Mat __cdecl cv::imread(class std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> > const &,int)"
I am able to use the imread() functionality directly from Visual Studio in my Python and C++ scripts so there is no problem with my OpenCV download. In the code that I have pasted below, all functionallity with the cv::createBackgroundSubtractorMOG2() works perfectly. ie: when I compile the mex function with only that functionallity, it works fine.
Why is it that functionallity with the cv::createBackgroundSubtractorMOG2() works fine but when I add in the imread() function it gives me the errors.
This is my code:
#include "opencvmex.hpp"
using namespace cv;
static Ptr<BackgroundSubtractorMOG2> ptrBackgroundModel = cv::createBackgroundSubtractorMOG2();
// Static smart pointer to hold the loaded image
static Ptr<Mat> ptrImage = makePtr<Mat>();
// Function to load an image from a file
void loadImageFromFile(const std::string& filename) {
// Load the image from file
Mat image = cv::imread(filename);
// Assign the loaded image to the static smart pointer
*ptrImage = image;
} mex, opencv, c++ MATLAB Answers — New Questions