Matlab: C++ header file for dll -


i have simple header file dll library in c++. can me edit in way compatible "loadlibrary" command in matlab (native c)? realize not general problem more lack of knowledge. if solution simple, appreciate advice.

// following ifdef block standard way of creating macros make exporting  // dll simpler. files within dll compiled trackererrorsdll_exports // symbol defined on command line. symbol should not defined on project // uses dll. way other project source files include file see  // trackererrorsdll_api functions being imported dll, whereas dll sees symbols // defined macro being exported. #ifdef trackererrorsdll_exports #define trackererrorsdll_api __declspec(dllexport) #define trackererrorsdll_vb __declspec(dllexport) __stdcall #else #define trackererrorsdll_api __declspec(dllimport) #define trackererrorsdll_vb __declspec(dllimport) __stdcall #endif  #include <string> using namespace std;  bool trackererrorsdll_api gettpierrordescription_wstring(long errornumber,                                                   basic_string<__wchar_t> & shortdescription,                                                  basic_string<__wchar_t> & longdescription,                                                  basic_string<__wchar_t> & solutiondescription,                                                  bool & isautorecoverongreenstate);  bool trackererrorsdll_api gettpierrordescription_wstring(long errornumber,                                                   basic_string<unsigned short> & shortdescription,                                                  basic_string<unsigned short> & longdescription,                                                  basic_string<unsigned short> & solutiondescription,                                                  bool & isautorecoverongreenstate);  bool trackererrorsdll_api gettpierrordescription_string(long errornumber,                                                   string & shortdescription,                                                  string & longdescription,                                                  string & solutiondescription,                                                  bool & isautorecoverongreenstate);  bool trackererrorsdll_api gettpierrordescription_cstring(long errornumber,                                                   cstring & shortdescription,                                                  cstring & longdescription,                                                  cstring & solutiondescription,                                                  bool & isautorecoverongreenstate);  bool trackererrorsdll_vb gettpierrordescription_vb(int errornumber,                                                   lpstr* shortdescription,                                                  lpstr* longdescription,                                                  lpstr* solutiondescription,                                                  bool* isautorecoverongreenstate); 

link download library (64bit): https://docs.google.com/file/d/0bzzppv2cg8zldzfrvzjua252mhc/edit?usp=sharing

matlab r2013a 64bit

the function can call gettpierrordescription_vb. others use c++ classes cannot access. suggest following:

  1. remove other functions header file.
  2. remove #include , using lines.
  3. remove #ifdef , replace trackererrorsdll_vb __stdcall.
  4. either include windows.h or add #define statements win32 types.
  5. possibly deal bool type depending on whether or not matlab knows how deal it. if matlab won't recognise it, replace bool int.

at point call loadlibrary should work , need write code calls calllib.

the resulting header file might this:

#define lpstr char*  __declspec(dllimport) bool __stdcall gettpierrordescription_vb(     int errornumber,      lpstr* shortdescription,     lpstr* longdescription,     lpstr* solutiondescription,     bool* isautorecoverongreenstate ); 

finally, note lpstr* rather surprising type encounter. suggests dll going allocate char* c strings, , return them through 3 description parameters. presents memory allocation issue. going deallocate memory? need deallocated, or static? issues need resolved consulting documentation dll.


Comments