Learning how to get started with Cryptlex and MATLAB (beginner)


I have a MATLAB code that I would like to distribute to clients as .p file (content-obscured, executable file).
I have seen there is an example (https://github.com/cryptlex/lexactivator-matlab) in which Cryptlex is used with MATLAB but I have never worked with libraries before and I cannot make it run (it gets stuck while evaluating
loadlibrary(sSharedLibrary,sHeaderFile, 'addheader',sStatusHeaderFile);).

Do you have any suggestion on how to systematically address this issue? In the long term, I would apply the same procedure also to make the clients choose the appropriate libraries based on their system (Windows and Linux).

Note that at the moment I am using Windows 10 with VS17 and I cannot change it due to other software compatibility requirements.



Have you included the dll files in your code folder?


Yes, I tried to include the .dll files for different VS (2015 and 2019) but with no luck. Indeed, I previously installed the Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019 but every time I try to load the library I continue to get the following error message:

Failed to parse type '( __cdecl__ )) Reset (' original input '( __cdecl__ )) Reset ('
Found on line 83331 of input from line 858 of file C:\\Users\\Riccardo\\Desktop\\lexactivator-matlab-master\\lexactivator-matlab-master\\examples\\LexActivator.h
Error parsing argument for function __attribute__ function may be invalid.
Error using loadlibrary
Building LexActivator_thunk_pcwin64 failed.  Compiler output is:
C:\ProgramData\MATLAB\SupportPackages\R2020b\3P.instrset\mingw_w64.instrset\bin\gcc -I"C:\Program Files\MATLAB\R2020b\extern\include"
-fexceptions -fno-omit-frame-pointer -I"C:\Users\Riccardo\Desktop\lexactivator-matlab-master\lexactivator-matlab-master\examples"
-I"C:\Users\Riccardo\Desktop\lexactivator-matlab-master\lexactivator-matlab-master\examples" "LexActivator_thunk_pcwin64.c" -o
"LexActivator_thunk_pcwin64.dll" -shared
In file included from LexActivator_thunk_pcwin64.c:27:0:
C:\Users\Riccardo\Desktop\lexactivator-matlab-master\lexactivator-matlab-master\examples/LexActivator.h:341:132: error: expected ';', ','
or ')' before '=' token
 LEXACTIVATOR_API int LA_CC GetLicenseMeterAttribute(CSTRTYPE name, uint32_t *allowedUses, uint32_t *totalUses, uint32_t *grossUses =
LexActivator_thunk_pcwin64.c: In function 'int32':
LexActivator_thunk_pcwin64.c:33:41: error: expected declaration specifiers before ')' token
 EXPORT_EXTERN_C int32_T int32(__cdecl__))SetProductFile(CSTRTYPEfilePathThunk(void fcn(),const char *callstack,int stacksize)

PS: I am using MATLAB 2020b with the compiler MinGW64 Compiler © and I would like to keep it because I will use it later on in the code I want to distribute (that part works). I also have installed MATLAB 2017b and I hope it’s not creating any conflict.


I guess MinGW64 won’t work as we don’t support this compiler. You need to use Visual Studio for this to work.


Thanks for your answer.
Unfortunately I find that the installation of the Visual Studio C compiler brings us too far from our idea of “just letting the users insert their license key and they will be good to go”.

We will now explore our plan B, so to compile a C++ executable and call it from MATLAB using encrypted messages.

Indeed, I am looking forward in case of any update regarding the integration with MATLAB!