开发者

MX Create double matrix error when integrating matlab with VC++

开发者 https://www.devze.com 2023-03-15 15:30 出处:网络
When i create a project to pass a path of an image to my matlab project and i created the initialization:

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开发者_如何学C: 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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号