Using RLM with Languages other than C/C++

If the language you are implementing your application in can link to the RLM static library, then that is the recommended approach. Other languages must use the RLM dynamic library:

  • rlm<vvmm>.dll on Windows

  • rlm<vvmm>.so on Unix/Linux

<vvmm> indicates RLM version, e.g., the DLL for v15.1BL2 is rlm1512.dll.

In all cases, you will need to download the RLM SDK and build it with the correct C compiler. On Windows, you can download Microsoft Visual Studio Express for free and use it to do the RLM build.

The following sections explain how to use RLM with various languages.


Using RLM with Fortran

The examples/unsupported directory on the RLM SDK contains a Fortran interface for RLM.


Using RLM with Java

RLM Java is a number of Java classes presenting an object interface to underlying native code. The actual work in RLM Java is done by platform-dependent code accessed via the Java Native Interface (JNI). As such, RLM Java requires that a non-Java RLM kit be installed and configured before RLM Java can be used. The functionality available to a Java program is the same as that available to a C program. The RLM Java API is completely documented in Javadoc. Open doc/index.html with a browser to access that documentation.

The platforms that contain support for RLM Java are as follows:

  • All Windows (x86_w3, x86_w4, x64_w3, x64_w4)

  • Linux Intel (x86_l2, x64_l1)

  • Solaris Sparc (sun_s1, sun64_s1)

  • Solaris Intel (x86_s1, x64_s1)

  • Mac/Intel (x86_m1, x64_m1)

If you would like to see the Java interface in action, follow these steps, after installing RLM on one of the platforms listed above:

On Unix, Linux, Mac systems:

  1. Download the java_unix.tar.gz kit from the website.

  2. In the platform directory, run “make shared”. This builds the shared object necessary for supporting RLM Java. The name of the shared object is librlm<ver>.<shared>, where:

    <ver> is the major and minor version numbers and the build level. <shared> is the file type of a shared library. This is “so” on all platforms except Mac where it is “jnilib”.

    For example, in RLM version 11.1BL2 on a Linux system the name would be “librlm1112.so”; on Mac it would be “librlm1112.jnilib”.

  3. Download the java_unix kit - java_unix.tar.gz.- and place it in your RLM SDK directory (i.e., in the same directory as “src”, “examples”, etc.).

  4. Perform these steps:

    % gunzip java_unix.tar.gz
    % tar xvf java_unix.tar
    % cd java_inix
    % ./INSTALL
    

    INSTALL will ask you which platform to install if more than one of the supported platforms is present. Select the platform corresponding to the machine you are running on.

  5. In another window, in the platform directory, start up the RLM License server:

    % rlm &
    
  6. In the java_unix window, set the environment variable that lets the Java VM find the native library:

    On Mac:

    [export | setenv | etc] DYLD_LIBRARY_PATH[=]`pwd`
    

    All others:

    [export | setenv | etc] LD_LIBRARY_PATH[=]`pwd`
    
  7. Run the example Java program:

    % make runclient
    

This program, whose source code is in the java_unix directory, checks out a license from the license server and keeps it checked out until you hit enter.

On Windows systems:

  1. Start the RLM license server:

    > cd <platform>
    > rlm
    
  2. In another window, go into the java_win directory and configure the makefile if necessary. The makefile as shipped refers to the x86_w3 sibling directory. If you are running on a different Windows platform, edit the makefile and change the definition of “NATIVE_PLATFORM” to match the platform you’re on. For example, if using 64-bit VC2015, change it to read:

    NATIVE_PLATFORM = x64_w3

  3. Run the example Java program:

    > nmake runclient
    

This program, whose source code is in the java_unix directory, checks out a license from the license server and keeps it checked out until you hit enter.


Using RLM with MinGW

You need to use the RLM DLL with MinGW, as the RLM library is compiled with Visual C++ and those object modules can’t coexist with MinGW object modules in the same executable. Link your application with rlm<vvmm>.lib, and at runtime make sure that rlm<vvmm>.dll is in your PATH. <vvmm> indicates RLM version, e.g., the DLL for v11.0BL2 is rlm1102.dll.

Here is a makefile example, which builds the demo client rlmclient.exe with MinGW. Here rlmclient is analogous to your application. (Note that using gcc to perform the link instead of ld means that gcc finds all the right system libraries rather than you having to enumerate them on the ld command line):

rlmclient.o:    ..\\examples\\rlmclient.c
                gcc -I..\\src -o rlmclient.o -c ..\\examples\\rlmclient.c

rlmclient.exe:  rlmclient.o rlm1102.lib
                gcc -o rlmclient.exe rlmclient.o rlm1102.lib

Using RLM with Visual Basic (outside .NET)

For information on integrating RLM with Visual Basic 6 applications see here.

The following material covers later versions of Visual Basic.

Visual Basic provides a means to make calls to functions in a DLL. This can be used to call RLM functions in rlmVVVV.dll. This is done by declaring the RLM functions you need to use in Visual Basic’s “Declare Function” statements, identifying the location of the DLL and how to pass each argument.

Note

VVVV signifies the RLM version, such as 1512 for 15.1BL2

Write Declare Function statements for the RLM functions you want to call. To figure out the mapping between basic data types and C data types, first look at src\license.h on the SDK, to see how each function is declared in C, then use the corresponding datatype and calling convention in Basic. Some guidelines:

  • Where an RLM function returns some sort of handle, like RLM_HANDLE or RLM_LICENSE, declare the function in Basic “As IntPtr”.

  • Where an RLM function returns an int, declare the function in Basic “As Integer”.

  • Where an RLM function argument is a handle type (RLM_HANDLE, RLM_LICENSE, etc.), pass it as “ByVal … As IntPtr”

  • Where an RLM function argument is type “char \*”, pass it as “ByVal … As String”.

  • Where an RLM function argument is type “int”, pass it as “ByVal … As Integer”.

Here is a simple example Visual Basic program that checks out a license and checks it back in:

Module Module1
        Declare Function rlm_init Lib "rlm.dll" (ByVal path As String, ByVal appPath As String, ByVal
license As String) As IntPtr
        Declare Function rlm_stat Lib "rlm.dll" (ByVal handle As IntPtr) As Integer
        Declare Function rlm_checkout Lib "rlm.dll" (ByVal handle As IntPtr, ByVal name As String, ByVal
version As String, ByVal count As Integer) As IntPtr
        Declare Function rlm_license_stat Lib "rlm.dll" (ByVal license As IntPtr) As Integer
        Declare Function rlm_checkin Lib "rlm.dll" (ByVal license As IntPtr) As Integer
        Declare Function rlm_close Lib "rlm.dll" (ByVal handle As IntPtr) As Integer

        Sub Main()

                Dim response As String
                Dim path$ = "."
                Dim nullstring$ = ""
                Dim handle As IntPtr
                Dim license As IntPtr
                Dim product$ = "test1"
                Dim ver$ = "1.0"
                Dim stat As Integer

                handle = rlm_init(path$, nullstring, nullstring)
                stat = rlm_stat(handle)
                If stat = 0 Then
                        license = rlm_checkout(handle, product, ver, 1)
                        stat = rlm_license_stat(license)
                        If stat = 0 Then
                                Console.WriteLine("Checkout succeeded, hit CR to check in...")
                                response = Console.ReadLine
                                stat = rlm_checkin(license)
                Else
                                Console.WriteLine("rlm_checkout error " + stat.ToString("d"))
                        End If
                        stat = rlm_close(handle)
                Else
                        Console.WriteLine("rlm_init error " + stat.ToString("d"))
                End If

                Console.WriteLine("Hit CR to exit...")
                response = Console.ReadLine
        End Sub
End Module

Using RLM with .NET

Overview

RLM provides a solution for .NET developers who want to use RLM to license their applications. It consists of a simple Interop layer that defines the RLM functions in .NET terms, and a DLL containing the native code. Here is the high-level overview of how to use this capability:

  • Install, configure and build a Windows RLM SDK. This provides the license server, utilities, and the actual RLM code packaged in a DLL.

  • Build the VS project “Reprise” in the dotnet folder on the SDK.

  • Add calls to the RLM methods to the .NET application to be licensed.

Building the RLM .NET package

If you have VS2013 or later, simply double click on dotnet\Reprise\Reprise.sln to open the project in Visual Studio, then build the project. You can build Debug or Release or both. If you have a prior version of Visual Studio, then create a project for the RLM .NET code manually, copy dotnet\Reprise\Reprise\RLMInterop.cs into it, and build.

Running the Example Program

The example program expects the example license file from the SDK (example.lic) to be correctly signed and to be available. The example program will check out v1.0 of the license “test1”. Here are the steps to run the example program:

  1. Open dotnet\RLMTest\RLMTest.sln in Visual Studio 2013 or later. If you have an earlier version of Visual Studio, create a new project for RLMTest, as described above for Reprise.

  2. Build the project, either Release or Debug or both, but in the same configuration(s) as you built the Reprise project.

  3. Copy rlmVVVV.dll, which contains the actual RLM code, from your platform folder (x86_w* or x64_w*) to some folder which is on your PATH, so that it can be found at runtime by the application.

    Note

    VVVV signifies the RLM version, such as 1512 for 15.1BL2)

  4. Copy example.lic, which is the signed license file, from your platform folder (x86_w* or x64_w*) to the same folder containing the application.

  5. Run the application. It opens a command window for its output, which will look like this if it runs successfully:

rlm_init successful
hostid of this machine is <your machine's hostid>
test1
version 1.0
expiration permanent
test2
version 1.0
expiration permanent
test3
version 1.0
expiration permanent
rlm_license_center
version 7.0
expiration permanent
rlm_act_admin
version 7.0
expiration permanent
rlm_act_view
version 7.0
expiration permanent
rlm_gen_license
version 7.0
expiration permanent
rlm_roam
version 1.0
expiration permanent
checkout of test1 OK
attributes of test1
expiration: permanent
days until expiration: 0
checkout of not_there failed: License server does not support this product (-18)

If the checkout of test1 fails, it is likely that either the license server is not running, or rlmVVVV.dll cannot be found.

Integrating RLM .NET into your Application

The RLM Reference manual (src\RLM_Reference.pdf) serves as a description of the routines available for a license application to call and how they behave. Refer to dotnet\Reprise\Reprise\RLMInterop.cs for the argument types and return value types in the .NET world.

Include a:

using Reprise;

statement with any classes that invoke RLM and precede RLM function names and constants with “RLM.”, for example, “RLM.rlm_checkout”. See the example program RLMTest.cs for an example.

You will need to include a reference to RLM in your application’s project. The object to reference is: <platform>\Reprise\Reprise\bin\<Debug or Release>\Reprise.dll

Several RLM functions are not supported in RLM .NET. They are:

  • rlm_isv_cfg*

  • rlm_sign_license

  • rlm_add_isv_hostid

  • rlm_add_isv_compare

  • rlm_add_isv_multiple

  • rlm_all_hostids

  • rlm_auto_hb

  • rlm_act_refresh