cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to build lmflex with Visual Studio 2015 for certificate licensing

How to build lmflex with Visual Studio 2015 for certificate licensing

Building the 32bit FNP toolkit for certificate use:

First, you’ll need to build the FNP toolkit (11.16.4.0_v6) via the command line using a Visual Studio Command Prompt.

1: Add your vendor keys and vendor name to the lm_code.h, then set your seed values and signature strength – this file can be found in the ‘..\i86_n3-11.16.4.0_v6\machind’ directory:

e.g.

#define VENDOR_KEY1 <XXXX>

#define VENDOR_KEY2 <XXXX>

#define VENDOR_KEY3 <XXXX>

#define VENDOR_KEY4 <XXXX>

#define VENDOR_KEY5 <XXXX>

 

#define VENDOR_NAME "demo"

 

#define LM_SEED1 <YYYY>

#define LM_SEED2 <YYYY>

#define LM_SEED3 <YYYY>

 

#define LM_STRENGTH LM_STRENGTH_239BIT

2: Edit the makefile and add your vendor name to the ‘VENDORNAME’ field - this file can be found in the ‘…\i86_n3-11.16.4.0_v6\i86_n3’ directory:

e.g.

VENDORNAME = demo

DAEMON = $(VENDORNAME).exe

3: in the ‘…\i86_n3-11.16.4.0_v6\i86_n3’ directory change ‘demo.rc’ to the name of your vendor daemon:

e.g.

demo.rc > Flexera.rc

4: In the VS command prompt run the following: …\i86_n3-11.16.4.0_v6\i86_n3> nmake -f makefile

Now your FNP toolkit is built to use certificate-based licensing. Follow the steps below to build lmflex using Visual Studio. 

 

Steps to build lmflex using Visual Studio 2015:

1: Create a Win32 Console Project called 'lmflex'.

2: Copy the lmflex.c code from the toolkit, found in the following location “..\i86_n3-11.16.4.0_v6\machind” and comment out the Trusted Storage code as shown below. Or you can copy the code below for just certificate only licensing:

/**************************************************************************************************

* Copyright (c) 1997-2018 Flexera. All Rights Reserved.

**************************************************************************************************/

/*

 *

 *            Description:        This is a sample application program, to illustrate

 *                                            the use of the Flexible License Manager.

 *

 */

 

#include "lmclient.h"

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <time.h>

#include "lm_attr.h"

#include "lm_redir_std.h"

 

#ifdef PC

#define LICPATH "@localhost"

#else

#define LICPATH "@localhost:license.dat:."

#endif /* PC */

 

#define FEATURE "f1"

VENDORCODE code;

LM_HANDLE *lm_job;

 

//JoeMC: Uncomment to use TS

//static void init(struct flexinit_property_handle **);

//static void cleanup(struct flexinit_property_handle *);

 

int

main(int argc, char * argv[])

{

                char feature[MAX_FEATURE_LEN * 2] = {'\0'};

                struct flexinit_property_handle *initHandle = NULL;

                int nlic = 1;

 

                //JoeMC: Uncomment to use TS

                //init(&initHandle);

 

                if (argc > 1)

                {

                                nlic = atoi(argv[1]);

                }

 

                if (lc_new_job(0, lc_new_job_arg2, &code, &lm_job))

                {

                                lc_perror(lm_job, "lc_new_job failed");

                                //JoeMC: Uncomment to use TS

                                //cleanup(initHandle);

                                exit(lc_get_errno(lm_job));

                }

 

                printf("Enter \"f1\" to demo floating functionality\n");

                printf("Enter \"f2\" to demo node-locked functionality\n");

                printf("Enter feature to checkout [default: \"%s\"]: ", FEATURE);

 

 

                fgets(feature, MAX_FEATURE_LEN + 2, lm_flex_stdin()); /*           add 2 for \n and \0          */

                feature[strlen(feature) - 1] = '\0';

                if(!*feature)

                                strcpy(feature, FEATURE);

 

                (void)lc_set_attr(lm_job, LM_A_LICENSE_DEFAULT, (LM_A_VAL_TYPE)LICPATH);

 

                if(lc_checkout(lm_job, feature, "1.0", nlic, LM_CO_NOWAIT, &code, LM_DUP_NONE))

                {

                                lc_perror(lm_job, "checkout failed");

                                //JoeMC: Uncomment to use TS

                                //cleanup(initHandle);

                                exit (lc_get_errno(lm_job));

                }

                printf("%s checked out...", feature);

                printf("press return to exit...");

 

                /*

                *             Wait till user hits return

                */

                getchar();

                lc_checkin(lm_job, feature, 0);

                lc_free_job(lm_job);

                //JoeMC: Uncomment to use TS

                //cleanup(initHandle);

                return 0;

}

 

//JoeMC: Uncomment to use TS

/*

static void init(struct flexinit_property_handle **handle)

{

#ifndef NO_ACTIVATION_SUPPORT

                struct flexinit_property_handle *ourHandle = NULL;

                int stat;

 

                if ((stat = lc_flexinit_property_handle_create(&ourHandle)))

                {

                                fprintf(lm_flex_stderr(), "lc_flexinit_property_handle_create() failed: %d\n", stat);

                                exit(1);

                }

                if ((stat = lc_flexinit_property_handle_set(ourHandle,

                                                (FLEXINIT_PROPERTY_TYPE)FLEXINIT_PROPERTY_USE_TRUSTED_STORAGE,

                                                (FLEXINIT_VALUE_TYPE)1)))

                {

                                fprintf(lm_flex_stderr(), "lc_flexinit_property_handle_set failed: %d\n", stat);

                    exit(1);

                }

                if ((stat = lc_flexinit(ourHandle)))

                {

                                fprintf(lm_flex_stderr(), "lc_flexinit failed: %d\n", stat);

                    exit(1);

                }

                *handle = ourHandle;

#endif // NO_ACTIVATION_SUPPORT

}

 

static void cleanup(struct flexinit_property_handle *initHandle)

{

#ifndef NO_ACTIVATION_SUPPORT

                int stat;

 

                if ((stat = lc_flexinit_cleanup(initHandle)))

                {

                                fprintf(lm_flex_stderr(), "lc_flexinit_cleanup failed: %d\n", stat);

                }

                if ((stat = lc_flexinit_property_handle_free(initHandle)))

                {

                                fprintf(lm_flex_stderr(), "lc_flexinit_property_handle_free failed: %d\n", stat);

                }

#endif // NO_ACTIVATION_SUPPORT

}

*/

3: Right click on the lmflex project and open “Properties”.

4: In the “General” settings change the ‘Character Set’ to ‘Use Multi-Byte Character Set’.

5: In the “C/C++” settings under the ‘General’ section add the following to the ‘Additional Include Directories: …\i86_n3-11.16.4.0_v6\machind and …\i86_n3-11.16.4.0_v6\machind\activation\include

6: In the “C/C++” settings under the ‘Preprocessors’ section add the following to the ‘Preprocessors Definitions’: _CRT_SECURE_NO_WARNINGS

7: In the “Linker” settings under the ‘General’ section add the following to the ‘Additional Library Directories: …\i86_n3-11.16.4.0_v6\i86_n3 and …\i86_n3-11.16.4.0_v6\i86_n3\activation\lib

8: In the “Linker” settings under the ‘Input’ section add the following libraries to the ‘Additional Dependencies’:

lm_new.obj

lmgr_trl.lib

libsb.lib

libcrvs.lib

.\activation\lib\libnoact.lib

libredir_std.lib

oldnames.lib

kernel32.lib

user32.lib

netapi32.lib

gdi32.lib

comdlg32.lib

comctl32.lib

wsock32.lib

shell32.lib

Rpcrt4.lib

oleaut32.lib

Ole32.lib

Wbemuuid.lib

wintrust.lib

crypt32.lib

Ws2_32.lib

iphlpapi.lib

Psapi.lib

advapi32.lib

Shlwapi.lib

userenv.lib

lmgr_dongle_stub.lib

msvcrt.lib

vcruntime.lib

legacy_stdio_definitions.lib

legacy_stdio_wide_specifiers.lib

ucrt.lib

Dhcpcsvc.lib

libvcruntime.lib

9: In the “Linker” settings under the ‘Ignore All Default Libraries’ set this to ‘Yes (/NODEFAULTLIB)’.

10: In your project change the lmflex.cpp filename to lmflex.c and the stdafx.cpp to stdafx.c then build lmflex.

Now, you should be able to run lmflex and perform a checkout from a license server.

Steps to set up a license server to serve a certificate license:

1: Edit ‘counted.lic’ from the ‘…\i86_n3-11.16.4.0_v6\i86_n3’ directory and change the vendor name ‘demo’ to your vendor name.

e.g.

SERVER this_host ANY

VENDOR demo

USE_SERVER

#a counted license

FEATURE f1 demo 1.0 permanent 4 SIGN="003D B062 54D1 47E3 1FF6 145F \

                59CE 0200 8002 FE69 0FBC F4FF AA10 FFB3 6EB3"

To

SERVER this_host ANY

VENDOR flexera

USE_SERVER

#a counted license

FEATURE f1 flexera 1.0 permanent 4 SIGN="003D B062 54D1 47E3 1FF6 145F \

                59CE 0200 8002 FE69 0FBC F4FF AA10 FFB3 6EB3"

 

2: encrypt ‘counted.lic’ license file using the VS command prompt:

e.g. …\i86_n3-11.16.4.0_v6\i86_n3> lmcrypt.exe counted.lic

3: Start the license server by running the following in the command prompt:

e.g. …\i86_n3-11.16.4.0_v6\i86_n3> lmgrd.exe -z -c counted.lic

4: Perform a checkout using the lmflex you built previously:

e.g. …\i86_n3-11.16.4.0_v6\i86_n3> lmflex.exe 

Enter "f1" to demo floating functionality

Enter "f2" to demo node-locked functionality

Enter feature to checkout [default: "f1"]: f1

 

 

 

 

 

 

 

 

 

 

 

Labels (1)
Was this article helpful? Yes No
No ratings
Version history
Last update:
‎Mar 04, 2021 05:52 AM
Updated by:
Contributors