用MATLAB2019封装好了dll,按照网上的步骤配置好了VS2017的环境,把.lib .dll .文件拷贝到了VS的工程目录下,但是在调用的时候却出现了问题。
#ifndef __testlib_h
#define __testlib_h 1
#if defined(__cplusplus) && !defined(mclmcrrt_h) && defined(__linux__)
# pragma implementation "mclmcrrt.h"
#endif
#include "mclmcrrt.h"
#include "mclcppclass.h"
#ifdef __cplusplus
extern "C" {
#endif
/* This symbol is defined in shared libraries. Define it here
* (to nothing) in case this isn't a shared library.
*/
#ifndef LIB_testlib_C_API
#define LIB_testlib_C_API /* No special import/export declaration */
#endif
/* GENERAL LIBRARY FUNCTIONS -- START */
extern LIB_testlib_C_API
bool MW_CALL_CONV testlibInitializeWithHandlers(
mclOutputHandlerFcn error_handler,
mclOutputHandlerFcn print_handler);
extern LIB_testlib_C_API
bool MW_CALL_CONV testlibInitialize(void);
extern LIB_testlib_C_API
void MW_CALL_CONV testlibTerminate(void);
extern LIB_testlib_C_API
void MW_CALL_CONV testlibPrintStackTrace(void);
/* GENERAL LIBRARY FUNCTIONS -- END */
/* C INTERFACE -- MLX WRAPPERS FOR USER-DEFINED MATLAB FUNCTIONS -- START */
extern LIB_testlib_C_API
bool MW_CALL_CONV mlxTest(int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[]);
/* C INTERFACE -- MLX WRAPPERS FOR USER-DEFINED MATLAB FUNCTIONS -- END */
#ifdef __cplusplus
}
#endif
/* C++ INTERFACE -- WRAPPERS FOR USER-DEFINED MATLAB FUNCTIONS -- START */
#ifdef __cplusplus
/* On Windows, use __declspec to control the exported API */
#if defined(_MSC_VER) || defined(__MINGW64__)
#ifdef EXPORTING_testlib
#define PUBLIC_testlib_CPP_API __declspec(dllexport)
#else
#define PUBLIC_testlib_CPP_API __declspec(dllimport)
#endif
#define LIB_testlib_CPP_API PUBLIC_testlib_CPP_API
#else
#if !defined(LIB_testlib_CPP_API)
#if defined(LIB_testlib_C_API)
#define LIB_testlib_CPP_API LIB_testlib_C_API
#else
#define LIB_testlib_CPP_API /* empty! */
#endif
#endif
#endif
extern LIB_testlib_CPP_API void MW_CALL_CONV test(int nargout, mwArray& b, const mwArray& a);
/* C++ INTERFACE -- WRAPPERS FOR USER-DEFINED MATLAB FUNCTIONS -- END */
#endif
#endif
这个是MATLAB生成的头文件,这个函数主要就是首先b=a+1的功能;这里可以有两种调用,第一种是调用mlxTest(int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[])这个函数,调用这个函数成功实现,没有问题。
但是在调用test(int nargout, mwArray& b, const mwArray& a)这个函数的时候,C++编译出错,告诉我无法解析test这个符号,尴尬,尝试了很多方法都无果,难道是dll文件或是.lib文件的问题?还是什么别的问题,有没有学霸或是遇到过此类问题的友友。
无法解析,test这个方法,可能是库的路径配置不对,或者是vs编译的版本问题,都有可能