Compiling Sample.cpp under Linux with g++

The Sample.cpp file does not compile on my Ubuntu 16.04 Linux box.

g++ --version
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609

g++ Sample.cpp
Sample.cpp: In function ‘int main()’:
Sample.cpp:16:40: error: cannot convert ‘const wchar_t*’ to ‘CSTRTYPE {aka const char*}’ for argument ‘1’ to ‘HRESULT SetProductFile(CSTRTYPE)’
status = SetProductFile(L"Product.dat");
^
Sample.cpp:22:74: error: cannot convert ‘const wchar_t*’ to ‘CSTRTYPE {aka const char*}’ for argument ‘1’ to ‘HRESULT SetVersionGUID(CSTRTYPE, uint32_t)’
status = SetVersionGUID(L"59A44CE9-5415-8CF3-BD54-EA73A64E9A1B", LA_USER);
^
Sample.cpp:40:76: error: cannot convert ‘const wchar_t*’ to ‘CSTRTYPE {aka const char*}’ for argument ‘1’ to ‘HRESULT SetTrialKey(CSTRTYPE)’
trialStatus = SetTrialKey(L"CCEAF69B-144EDE48-B763AE2F-A0957C93-98827434");
^
Sample.cpp:57:59: error: cannot convert ‘const wchar_t*’ to ‘CSTRTYPE {aka const char*}’ for argument ‘1’ to ‘HRESULT SetProductKey(CSTRTYPE)’
status = SetProductKey(L"986D8-DE8AF-C2B37-50BF5-03EA1");
^
Sample.cpp:63:41: error: cannot convert ‘const wchar_t*’ to ‘CSTRTYPE {aka const char*}’ for argument ‘1’ to ‘HRESULT SetExtraActivationData(CSTRTYPE)’
SetExtraActivationData(L"sample data");
^

Hi,

Remove “L” (Windows specific) from the set functions:

status = SetProductFile(L"Product.dat");

should be

status = SetProductFile(“Product.dat”);

Removing the L modifier worked. Thanks.

But why would you ship sample code in a file called LexActivator-Linux.zip that you KNOW will not compile under Linux? You could have fixed this with a few #ifdef lines. At the very least you should put in a README explaining the problem.

Will update the samples in the next release