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

Hi,

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.

Thanks,
Riccardo

Hi,

Have you included the dll files in your code folder?

Hi,

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 =
 NULL);
                                                                                                                                    ^
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.

Hi,

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

Hi,

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!

Was this issue ever resolved? We too are hoping to integrate licensing into MATLAB this way.

Hi Joshua,

Visual studio is needed during compilation, not by your end users. We have many users using our solution for Matlab.

@adnan-kamili thanks for the quick reply. Is it possible for us to implement http requests directly in matlab. I have experience (and scripts) doing this with another platform, the only thing that isn’t clear from the Cryptlex documentation is the full request information required, such as format for including the authorization tokens. I am happy to try compiling in VS Code if not. Is there any detailed information on how to do this for Cryptlex?

Hi Joshua,

LexActivator is simply a libcurl based HTTP client, but it does something more than just sending HTTPS requests. Please refer to the following:

https://docs.cryptlex.com/node-locked-licenses/overview#what-is-lexactivator

We don’t recommend using the Web API directly as you will have to handle device fingerprinting, encryption, RSA verification etc. on your own. Here is the guide to using the Web API directly:

https://docs.cryptlex.com/node-locked-licenses/using-web-api.

We have many customers using MATLAB happily with LexActivator. We can share few contacts over email in case you want.

Ok, I’ve sent you email.

We have replied to your query.