2
votes

When i create a project to pass a path of an image to my matlab project and i created the initialization:

#include "feautresPoints.h"


int main(int argc, char* argv[])
{
    mxArray* result;
    mxArray* x;
    double myArray[5]={10.2, 3, 6.3, 5.4, 5.9};

    x=mxCreateDoubleMatrix(1, 5, mxREAL);
    memcpy(mxGetPr(x), myArray, 5 * sizeof(double));

    feautresPointsInitialize();

    feautresPointsTerminate();


    return 0;
}

it gives me 3 errors

Error 1

error LNK2019: unresolved external symbol _mxGetPr_proxy referenced in function _main

Error 2

error LNK2019: unresolved external symbol _mxCreateDoubleMatrix_730_proxy referenced in function _main

Error 3

error LNK1120: 2 unresolved externals

so how can i solve these errors??

I include the matlab project library produced during compilation in C++ project and libmx.lib and also add the include file for matlab and also i add matlab library for additional library Directories

1

1 Answers

0
votes

You need to include the MATLAB libs for your linker. In my case: "C:\Program Files\MATLAB\MATLAB Compiler Runtime\v714\extern\lib\win32\microsoft*"

Also you are not initializing the MATLAB environment correctly see "Initializing and Terminating Your Application with mclInitializeApplication and mclTerminateApplication" in the MATLAB help.

mxArray* result;
mxArray* x;

mclInitializeApplication(NULL,0);
feautresPointsInitialize();

/* Your c++ code here */

feautresPointsTerminate();
mclTerminateApplication();

return 0;

Note feautresPointsInitialize() will return a bool indicating that everything is initialized, you should check it.