How to Load a DLL Locally

This task describes how to use the lr_load_dll function to load a DLL into your Vuser script. Once the DLL is loaded, you can call any function defined within the DLL without having to declare it in your script.

To load a DLL locally:

  1. In a C Vuser script, add an lr_load_dll function to load the DLL at the beginning of your script. Place the statement at the beginning of the vuser_init section. lr_load_dll replaces the ci_load_dll function.

  2. Use the following syntax:

    lr_load_dll( library_name);
    

    Note that for Linux platforms, DLLs are known as shared libraries. The extension of the libraries is platform dependent.

  3. Call the function defined in the DLL in the appropriate place within your script.

    In the following example, the insert_vals function, defined in orac1.dll, is called, after the creation of the Test_1 table.

    Example: int LR_FUNC Actions(LR_PARAM p) { lr_load_dll("orac1.dll");


    lrd_stmt(Csr1, "create table Test_1 (name char(15), id integer)\n", -1,
               1 /*Deferred*/, 1 /*Dflt Ora Ver*/, 0); lrd_exec(Csr1, 0, 0, 0, 0, 0);


    /* Call the insert_vals function to insert values into the table. */
    insert_vals();

    lrd_stmt(Csr1, "select * from Test_1\n", -1, 1 /*Deferred*/, 1 /*Dflt Ora Ver*/, 0); lrd_bind_col(Csr1, 1, =;NAME_D11, 0, 0); lrd_bind_col(Csr1, 2, =;ID_D12, 0, 0); lrd_exec(Csr1, 0, 0, 0, 0, 0); lrd_fetch(Csr1, -4, 15, 0, PrintRow14, 0); ...

  4. Note: You can specify a full path for the DLL. If you do not specify a path, lr_load_library searches for the DLL using the standard sequence used by the C++ function, LoadLibrary on Windows platforms. On Linux platforms you can set the LD_LIBRARY_PATH environment variable (or the platform equivalent). The lr_load_dll function uses the same search rules as dlopen. For more information, see the Unix help 'man' page for dlopen.

Back to top