Highlighted
Absent Member.
Absent Member.
1728 views

Calling C++ member functions from ext dll in loadrunner

Can we call any C++ member functions from an external dll in loadrunner?

I am recording an application using web(http/html) protocol. Now i need to modify the script and use some member functions from a dll. I am not sure how to call these functions.

Can someone please help?
0 Likes
10 Replies
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: Calling C++ member functions from ext dll in loadrunner

Hi Ramanadham,

Do you want to use the functionality available in the external dll? If yes, use lr_load_dll and load the external dll. then you can all the functions available in dll.

**
0 Likes
Highlighted
Absent Member.
Absent Member.

Re: Calling C++ member functions from ext dll in loadrunner

I know we can load external dlls. But the problem is if the code of external dll is in C++, i have to create objects etc to call those functions in my LR script. ANd loadrunner doesnt even recognize "new"


ADODB.Recordset rs5 = new ADODB.Recordset();


After i load the dlls, i call a simple function like GetDate(); from the dll and lr throws an error.
0 Likes
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: Calling C++ member functions from ext dll in loadrunner

I think you did something wrong. Please check the attached one with an example.
0 Likes
Highlighted
Absent Member.
Absent Member.

Re: Calling C++ member functions from ext dll in loadrunner

No we can't usee c++ in LR.

As LR only support "c" Methods...

LR compiler will support only C Functions and Variables....

0 Likes
Highlighted
Absent Member.
Absent Member.

Re: Calling C++ member functions from ext dll in loadrunner

Hi madthrt ,

I checked the zip file. But the c++ code of the dll doesnt have any classes or objects of the class. I want to know that if the Cpp code of the dll has a class and we need to create objects of the class and use the functions, how do we do that?

Thanks,
Radhika
0 Likes
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: Calling C++ member functions from ext dll in loadrunner

Radhika,

I don't have environment to write a sample for you but, it should work.

Thanks!!
0 Likes
Highlighted
Absent Member.
Absent Member.

Re: Calling C++ member functions from ext dll in loadrunner

Hi Madthrt,
Could you take the zip file? It has the source code1 for dll (with error, see below) and source code 2 without error and the code i have in vuser_init.c. Could you tell what I am doing wrong?

If i add "C:\Program Files\Mercury\LoadRunner\lib\lrun50.lib" under project properties->linker->input->additionaldependencies

i get the error:
=====
temp fatal error LNK1181: cannot open input file 'C:\Program.obj'
=====

if i remove this (src code 2), the dll is built, yet i cant successfully call the functions from LR.

Thanks,
Radhika
0 Likes
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: Calling C++ member functions from ext dll in loadrunner

Radhika,

Please use DOS path convention in the first case and see how it goes.

Also, i suggest to keep your dlls in LR\bin directory and see it may solve this linking problems. 🙂

-M
0 Likes
Highlighted
Absent Member.
Absent Member.

Re: Calling C++ member functions from ext dll in loadrunner

Hi,
I gave the relative path and the dll got built.

Now when i try to run the lr script, it gives me an error

Action.c(8): Error: C interpreter run time error: Action.c (8): Error -- Unresolved symbol : Add.

Can you tell me how i need to call the add function in lr script i have in my dll? is this right?

Add a(10,20) or

Add(10,20)

nothing works. Also i saved this dll in lr bin directory..

didnt work.
0 Likes
Highlighted

Re: Calling C++ member functions from ext dll in loadrunner

excuse me, have you solve your problem? I've the same issue... 

thanks

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.