Question about mexfunction link to dll
Mostrar comentarios más antiguos
Hello there,
Does anyone have idea about how to link dll or lib in the Mex command?
I have a C code link a external function from GHXDLL.dll and GHXDLL.lib. I defined the external function in header that the same one i used to generate the dll and lib.
typedef struct GHX{
double output[28];
int val;
}GHX;
#ifdef __cplusplus
extern "C" { // only need to export C interface if
// used by C++ source code
#endif
#ifdef GHXDLL_EXPORTS
#define MATHFUNCSDLL_API __declspec(dllexport)
#else
#define MATHFUNCSDLL_API __declspec(dllimport)
#endif
MATHFUNCSDLL_API void GHXfunction(double *XIN, double *parameter, int mode, int hour, GHX *result);
#ifdef __cplusplus
}
#endif
I wrote a test code to call this function with linking to the lib and dll, and it works. Meanwhile, I wrote a simple test code for the Mex API, then I compile it from command line by
mex test.c,
and it works.
Then, I met problem. When I add the external function to the Mex API and compile in matlab with the following command, it fails.
mex -largeArrayDims -I'c:\Users\zzhang\API' -L'c:\Users\zzhang\API' -lGHXDLL GHXCmexAPI.c
The errors are:
Error using mex
Creating library GHXCmexAPI.lib and object GHXCmexAPI.exp
GHXCmexAPI.obj : error LNK2019: unresolved external symbol __imp_GHXfunction referenced in function mexFunction
GHXCmexAPI.mexw64 : fatal error LNK1120: 1 unresolved externals
I know this error means the mexfunction did not link to the lib with external function, but i have tried many different ways, and still cannot deal with it.
I hope someone can help me figure out how to mex it.
Thanks.
Zhicheng
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre C Shared Library Integration en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!