Controlling Flux2D from Matlab

User: "Ruud"
Altair Community Member
Updated by Ruud

Hi,

 

I am trying to set up communication between Matlab (version 2019a) and Flux2D (as a server, using version 2019.1). I have been able to do this succesfully in the past with older versions of Flux2D (12.3). However, for the new version, I found that a library needs to be loaded for this in Matlab using the following command:

 [notfound,warnings]=loadlibrary(strcat(installFlux,'\Bin\dll\win64\',fluxmp,'.dll'), strcat(installFlux,'\Api\win64\include\flux_mp_matlab.h'));

I have made sure that the variable 'installFlux' is set correctly (manually checked the result of strcat). Also, I am using MinGW as a C/C++ compiler in Matlab (recommended by Matlab). However, when I try to run the command above, I get some errors:

 Error loading library intermediate output follows. The actual error is at the end of this output. ********* Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.30), passed through in regex; marked by <-- HERE in m/struct([^;,{(]*){ <-- HERE (.*?)\}([^;])*;/ at C:\Program Files\MATLAB\R2019a\toolbox\matlab\general\private\prototypes.pl line 912.  Failed to parse type '( __cdecl__ )) FMP_stopServer_Matlab ( int serverUid' original input '( __cdecl__ )) FMP_stopServer_Matlab ( int serverUid ' Found on line 12 of input from line 8 of file C:\\Altair\\2019\\flux\\Flux\\Api\\win64\\include\\flux_mp_matlab.h Error parsing argument for function __attribute__ function may be invalid.  Failed to parse type '( __cdecl__ )) FMP_killServer_Matlab ( int serverUid' original input '( __cdecl__ )) FMP_killServer_Matlab ( int serverUid ' Found on line 13 of input from line 9 of file C:\\Altair\\2019\\flux\\Flux\\Api\\win64\\include\\flux_mp_matlab.h Error parsing argument for function __attribute__ function may be invalid.  Failed to parse type '( __cdecl__ )) FMP_closeProject_Matlab ( int serverUid' original input '( __cdecl__ )) FMP_closeProject_Matlab ( int serverUid ' Found on line 17 of input from line 13 of file C:\\Altair\\2019\\flux\\Flux\\Api\\win64\\include\\flux_mp_matlab.h Error parsing argument for function __attribute__ function may be invalid.  Failed to parse type '( __cdecl__ )) FMP_saveProject_Matlab ( int serverUid' original input '( __cdecl__ )) FMP_saveProject_Matlab ( int serverUid ' Found on line 18 of input from line 14 of file C:\\Altair\\2019\\flux\\Flux\\Api\\win64\\include\\flux_mp_matlab.h Error parsing argument for function __attribute__ function may be invalid.  Failed to parse type '( __cdecl__ )) FMP_solveCurrentStep_Matlab ( int serverUid' original input '( __cdecl__ )) FMP_solveCurrentStep_Matlab ( int serverUid ' Found on line 34 of input from line 30 of file C:\\Altair\\2019\\flux\\Flux\\Api\\win64\\include\\flux_mp_matlab.h Error parsing argument for function __attribute__ function may be invalid.  Failed to parse type '( __cdecl__ )) FMP_solveActiveNextStep_Matlab ( int serverUid' original input '( __cdecl__ )) FMP_solveActiveNextStep_Matlab ( int serverUid ' Found on line 36 of input from line 32 of file C:\\Altair\\2019\\flux\\Flux\\Api\\win64\\include\\flux_mp_matlab.h Error parsing argument for function __attribute__ function may be invalid.  Failed to parse type '( __cdecl__ )) FMP_getErrorMessage_Matlab ( int errorId' original input '( __cdecl__ )) FMP_getErrorMessage_Matlab ( int errorId ' Found on line 43 of input from line 39 of file C:\\Altair\\2019\\flux\\Flux\\Api\\win64\\include\\flux_mp_matlab.h Error parsing argument for function __attribute__ function may be invalid.  Failed to parse type '( __cdecl__ )) FMP_freeError_Matlab ( int errorId' original input '( __cdecl__ )) FMP_freeError_Matlab ( int errorId ' Found on line 44 of input from line 40 of file C:\\Altair\\2019\\flux\\Flux\\Api\\win64\\include\\flux_mp_matlab.h Error parsing argument for function __attribute__ function may be invalid. ********* Error using loadlibrary Building flux_mp_thunk_pcwin64 failed.  Compiler output is: C:\ProgramData\MATLAB\SupportPackages\R2019a\3P.instrset\mingw_w64.instrset\bin\gcc -I'C:\Program Files\MATLAB\R2019a\extern\include' -fexceptions -fno-omit-frame-pointer -I'C:\SIM_TOOLS\TOOLS\HSM_geometry_optimization' -I'C:\Altair\2019\flux\Flux\Api\win64\include' 'flux_mp_thunk_pcwin64.c' -o 'flux_mp_thunk_pcwin64.dll' -shared flux_mp_thunk_pcwin64.c:33:37: error: expected '=', ',', ';', 'asm' or '__attribute__' before ')' token  EXPORT_EXTERN_C long long(__cdecl__))FMP_stopServer_Matlab(intserverUidThunk(void fcn(),const char *callstack,int stacksize)                                      ^ flux_mp_thunk_pcwin64.c:42:37: error: expected '=', ',', ';', 'asm' or '__attribute__' before ')' token  EXPORT_EXTERN_C long long(__cdecl__))FMP_killServer_Matlab(intserverUidThunk(void fcn(),const char *callstack,int stacksize)                                      ^ flux_mp_thunk_pcwin64.c:51:37: error: expected '=', ',', ';', 'asm' or '__attribute__' before ')' token  EXPORT_EXTERN_C long long(__cdecl__))FMP_closeProject_Matlab(intserverUidThunk(void fcn(),const char *callstack,int stacksize)                                      ^ flux_mp_thunk_pcwin64.c:60:37: error: expected '=', ',', ';', 'asm' or '__attribute__' before ')' token  EXPORT_EXTERN_C long long(__cdecl__))FMP_saveProject_Matlab(intserverUidThunk(void fcn(),const char *callstack,int stacksize)                                      ^ flux_mp_thunk_pcwin64.c:69:37: error: expected '=', ',', ';', 'asm' or '__attribute__' before ')' token  EXPORT_EXTERN_C long long(__cdecl__))FMP_solveCurrentStep_Matlab(intserverUidThunk(void fcn(),const char *callstack,int stacksize)                                      ^ flux_mp_thunk_pcwin64.c:78:37: error: expected '=', ',', ';', 'asm' or '__attribute__' before ')' token  EXPORT_EXTERN_C long long(__cdecl__))FMP_solveActiveNextStep_Matlab(intserverUidThunk(void fcn(),const char *callstack,int  stacksize)                                      ^ flux_mp_thunk_pcwin64.c: In function 'cstring': flux_mp_thunk_pcwin64.c:87:42: error: expected declaration specifiers before ')' token  EXPORT_EXTERN_C char * cstring(__cdecl__))FMP_getErrorMessage_Matlab(interrorIdThunk(void fcn(),const char *callstack,int  stacksize)                                           ^ flux_mp_thunk_pcwin64.c:5:26: error: expected declaration specifiers before '__attribute__'    #define DLL_EXPORT_SYM __declspec(dllexport)                           ^ flux_mp_thunk_pcwin64.c:19:25: note: in expansion of macro 'DLL_EXPORT_SYM'  #define EXPORT_EXTERN_C DLL_EXPORT_SYM                          ^~~~~~~~~~~~~~ flux_mp_thunk_pcwin64.c:96:1: note: in expansion of macro 'EXPORT_EXTERN_C'  EXPORT_EXTERN_C long long(__cdecl__))FMP_freeError_Matlab(interrorIdThunk(void fcn(),const char *callstack,int stacksize)  ^~~~~~~~~~~~~~~ flux_mp_thunk_pcwin64.c:87:24: warning: type of '__cdecl__' defaults to 'int' [-Wimplicit-int]  EXPORT_EXTERN_C char * cstring(__cdecl__))FMP_getErrorMessage_Matlab(interrorIdThunk(void fcn(),const char *callstack,int  stacksize)                         ^~~~~~~ flux_mp_thunk_pcwin64.c:102:1: error: expected '{' at end of input  }  ^   Error in flux_link (line 9) [notfound,warnings]=loadlibrary(strcat(installFlux,'\Bin\dll\win64\',fluxmp,'.dll'), strcat(installFlux,'\Api\win64\include\flux_mp_matlab.h'));

Do you have any idea what is causing this problem? Is MinGW the right compiler for loading this library, or do I need a different one?

 

Thanks in advance for the reply.

 

Best regards,

Ruud

 

Find more posts tagged with