Click here to Skip to main content
15,886,835 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have one C++ dll and want wrap that by another C++ dll and call functions of this first dll.
How I can wrap that?
Regards,
Posted
Comments
chaau 1-Nov-12 17:10pm    
What do you mean by wrap? Do you want to call exported functions from that dll?
Rezame 1-Nov-12 17:13pm    
Want call exported function and compile my dll included slave dll.

1 solution

There is no much difference when you call the exported function of a dll regardless whether you are calling from an exe or from another dll.

To call exported functions of a dll you have two options: explicit or implicit linking.

I think this MSDN Article[^] could be a good starting point for you.

I recommend you start with Implicit Linking[^]. You will need a header (h) file and an import library file (lib) of the dll you would like to link.

For example, you have a test.exe, dll1.dll and dll2.dll, that are linked like this:
test.exe->dll1.dll->dll2.dll. I believe the link between test.exe and dll1.dll is established (otherwise you wouldn't ask). So, to link dll1 with dll2 you need the h and lib file from dll2. For example you have dll2_exports.h and dll2.lib. In this case within a cpp file of your dll1 add this line:
C++
#include "dll1_exports.h"

Then call the functions from dll2 as you would normally do.

In the link options of dll1 you would need to add a reference to your dll2.lib. Provided you use Visual Studio, Right click on project of "dll1" in the Solution Explorer and select Properties. Navigate to Linker->Input. In the Additional Dependencies type dll2.lib.

Now build dll1. It should now be linked with dll2
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 1-Nov-12 22:46pm    
Good reply, a 5.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900