在C ++ Undefined函数checkRequiredMCRProducts中初始化matlab DLL库

时间:2017-10-03 05:47:50

标签: c++ dll matlab-compiler

我从Matlab代码中调用DLLs编译C++。我使用Matab 2015b进行开发,使用Matlab 9.0作为运行时。

Windows 10 64-bit机器中使用以下命令来编译Matlab应用程序

mcc -v -a .\+ismrmrd -W cpplib:libStdFourier -T link:lib StdFourier.m -d E:\dev\matlab\mfiles\StdFourier

DLL调用在开发机器中正常工作。但是当我在安装了Runtime 9.0的Windows 7 64-bit上运行的另一台机器上部署它时,库无法初始化。运行时初始化成功,并且在库初始化方法libStdFourierInitialize()

中发生跟随错误

我使用以下代码初始化运行时和库:

mclmcrInitialize();
const char *rtOptions[3];
rtOptions[0] = "-singleCompThread";
rtOptions[1] = "-logfile";
rtOptions[2] = "matlogfile.txt";

if (!mclInitializeApplication(rtOptions,3))
{
 std::cerr << "Could not initialize the application properly." << std::endl;
}

std::cout << "MCR initialized:" << mclIsMCRInitialized() << std::endl; //Returns true

std::cout << "Initialize libStdFourier" << << std::endl;

/* Call the library intialization routine and make sure that the
library was initialized properly. */
if(!libStdFourierInitialize())
{
  fprintf(stderr,"Could not initialize the library.\n");
}

错误控制台窗口 enter image description here

标题代码:

#ifndef __libStdFourier_h
#define __libStdFourier_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

#if defined(__SUNPRO_CC)
/* Solaris shared libraries use __global, rather than mapfiles
* to define the API exported from a shared library. __global is
* only necessary when building the library -- files including
* this header file to use the library do not need the __global
* declaration; hence the EXPORTING_<library> logic.
*/
#ifdef EXPORTING_libStdFourier
#define PUBLIC_libStdFourier_C_API __global
#else
#define PUBLIC_libStdFourier_C_API /* No import statement needed. */
#endif

#define LIB_libStdFourier_C_API PUBLIC_libStdFourier_C_API

#elif defined(_HPUX_SOURCE)

#ifdef EXPORTING_libStdFourier
#define PUBLIC_libStdFourier_C_API __declspec(dllexport)
#else
#define PUBLIC_libStdFourier_C_API __declspec(dllimport)
#endif

#define LIB_libStdFourier_C_API PUBLIC_libStdFourier_C_API

#else

#define LIB_libStdFourier_C_API

#endif

/* This symbol is defined in shared libraries. Define it here
* (to nothing) in case this isn't a shared library. 
*/
#ifndef LIB_libStdFourier_C_API 
#define LIB_libStdFourier_C_API /* No special import/export declaration */
#endif

extern LIB_libStdFourier_C_API 
bool MW_CALL_CONV libStdFourierInitializeWithHandlers(
   mclOutputHandlerFcn error_handler, 
   mclOutputHandlerFcn print_handler);

extern LIB_libStdFourier_C_API 
bool MW_CALL_CONV libStdFourierInitialize(void);

extern LIB_libStdFourier_C_API 
void MW_CALL_CONV libStdFourierTerminate(void);



extern LIB_libStdFourier_C_API 
void MW_CALL_CONV libStdFourierPrintStackTrace(void);

extern LIB_libStdFourier_C_API 
bool MW_CALL_CONV mlxStdFourier(int nlhs, mxArray *plhs[], int nrhs, mxArray    *prhs[]);


#ifdef __cplusplus
}
#endif

#ifdef __cplusplus

/* On Windows, use __declspec to control the exported API */
#if defined(_MSC_VER) || defined(__BORLANDC__)

#ifdef EXPORTING_libStdFourier
#define PUBLIC_libStdFourier_CPP_API __declspec(dllexport)
#else
#define PUBLIC_libStdFourier_CPP_API __declspec(dllimport)
#endif

#define LIB_libStdFourier_CPP_API PUBLIC_libStdFourier_CPP_API

#else

#if !defined(LIB_libStdFourier_CPP_API)
#if defined(LIB_libStdFourier_C_API)
#define LIB_libStdFourier_CPP_API LIB_libStdFourier_C_API
#else
#define LIB_libStdFourier_CPP_API /* empty! */ 
#endif
#endif

#endif

extern LIB_libStdFourier_CPP_API void MW_CALL_CONV StdFourier(int nargout, mwArray& bufferQ, mwArray& imageQ, const mwArray& xmlstr, const mwArray& recon_data);

#endif
#endif

感谢。

0 个答案:

没有答案