Static linking on windows

Hello,

I’ve successfully gotten LexActivator working for OS X, now I’m trying to get things up and running for windows distribution. Form another forum post I saw that I need to do some extra work to link LexActivator statically, but it wasn’t clear to me exactly what to do. I was hoping someone could give me a quick walk-through of the extra steps involved.

Currently I’ve added the respective libs for x86 and x84 like this:

#if _WIN32
#if _WIN64
#pragma comment(lib,"…\\…\\Cryptlex\\x64\\LexActivator.lib")
#pragma comment(lib,"…\\…\\Cryptlex\\x64\\libcurl_MD.lib")
#else
#pragma comment(lib,"…\\…\\Cryptlex\\x84\\LexActivator.lib")
#pragma comment(lib,"…\\…\\Cryptlex\\x84\\libcurl_MD.lib")
#endif
#endif

And I’ve included the header file in my project. When I build I’m getting some unresolved symbol errors, which I’m assuming are from not correctly linking the libraries.

I’m using VS 2017 on Windows 7, and I don’t have much experience with Visual Studio/ developing for windows, so any help/info would be greatly appreciated.

Thanks!
MSK

Hi,

Please post the error message

These are the errors:

Error LNK2019 unresolved external symbol __imp_ActivateProduct referenced in function “public: virtual void __cdecl ActivationScreen::TextFromTextEntry(char const *)” (?TextFromTextEntry@ActivationScreen@@UEAAXPEBD@Z) cmprssr-app C:\Users\Max\Desktop\IPlug-Youlean-master\IPlugExamples\cmprssr-master\cmprssr.obj 1

Error LNK2019 unresolved external symbol __imp_IsProductGenuine referenced in function “public: __cdecl cmprssr::cmprssr(struct IPlugInstanceInfo)” (??0cmprssr@@QEAA@UIPlugInstanceInfo@@@Z) cmprssr-app C:\Users\Max\Desktop\IPlug-Youlean-master\IPlugExamples\cmprssr-master\cmprssr.obj 1

Error LNK2019 unresolved external symbol __imp_SetProductKey referenced in function “public: virtual void __cdecl ActivationScreen::TextFromTextEntry(char const *)” (?TextFromTextEntry@ActivationScreen@@UEAAXPEBD@Z) cmprssr-app C:\Users\Max\Desktop\IPlug-Youlean-master\IPlugExamples\cmprssr-master\cmprssr.obj 1

Hi MKant,

Please refer to following post:

What wasn’t clear to me from that post (almost certainly because of my inexperience) is how and where exactly to define LEXACTIVATOR_STATIC. Do I just need to add #define LEXACTIVATOR_STATIC before I include the libraries and header? I’ll give it a go tomorrow on my windows machine.

Thanks!

In the header file that macro is already present which you need to uncomment.

Hmmm, not seeing where it’s commented.

#ifdef _WIN32
/*
Make sure you’re using the MSVC or Intel compilers on Windows.
*/
#include <windows.h>

#ifdef LEXACTIVATOR_EXPORTS
	#ifdef LEXACTIVATOR__STATIC
        #define LEXACTIVATOR_API extern "C"
    #else
        #define LEXACTIVATOR_API extern "C" __declspec(dllexport)
    #endif
#else
	#ifdef __cplusplus
        #ifdef LEXACTIVATOR_STATIC
            #define LEXACTIVATOR_API extern "C"
        #else
            #define LEXACTIVATOR_API extern "C" __declspec(dllimport)
        #endif
    #else
        #ifdef LEXACTIVATOR_STATIC
            #define LEXACTIVATOR_API
        #else
            #define LEXACTIVATOR_API __declspec(dllimport)
        #endif
    #endif
#endif

#if defined(USE_STDCALL_DLL) && !defined(LEXACTIVATOR_STATIC)
    #define LA_CC __stdcall
#else
    #define LA_CC __cdecl
#endif
typedef const wchar_t* CSTRTYPE;
typedef wchar_t* STRTYPE;

What should I change in the above code?

Thanks!

Just add following at the top:

#define LEXACTIVATOR__STATIC