LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

how to call functions of one dll from another dll

Solved!
Go to solution

Hi, could someone please point me to some examples or instructions on how you go about calling functions of one dll from another dll including UIR's. Both dll's were created using labwindows cvi.

 

Thanks !

0 Kudos
Message 1 of 7
(9,265 Views)

There are many whitepapers written by NI about this.

I also am sure that there are example programs in the CVI installation.

 

Here are some links to give you a quick start:

 

Linking to Functions Defined in a DLL From LabWindows/CVI

Rules for Using DLL Files

Exporting Variables and Functions from a DLL in LabWindows/CVI

S. Eren BALCI
IMESTEK
0 Kudos
Message 2 of 7
(9,258 Views)
Solution
Accepted by sinnas

Hi Sinnas,

 

You mention that you are using a UIR.  A DLL will not have a UIR file as part of it. 

 

DLL1

Instead, when you build the first DLL, we'll call it DLL1, you will create a header file(s) containing functions that you wish client code to be able to call.  When you go to build DLL1, you must export DLL1's function header file for its client code to call.  Whatever the calling code is (a GUI or another DLL) you will include in the project DLL1's exported header files AND DLL1's .lib file generated when you built it. 

 

DLL2

DLL2 will contain in its project, DLL1's exported header file, DLL1's .lib file - that gives it the functionality in DLL1.  The code can then call whatever DLL1 function you want, but like DLL1, you now have to have a header file that exports DLL2's functions that you want ITS client code to be able to call.  When you build DLL2, you will create a .lib file for THAT DLL to be included in the final client code.

 

GUI

The final client code will be some GUI you create to call the top layer DLL2 functions  That will have the UIR file.  It will include the exported DLL2 header file and the DLL2 .lib file in its project.  It can then call any DLL2 function.  This is the cleanest way to have 2 DLLs working together.

 

NOTE: You can create a GUI to test out the lower level DLL1 functions before placing DLL2 in the system.  In fact it's a good idea to do so - you want to make sure your lower level DLL1 code works properly before building on top of it.

 

Simple diagram

 

Client Code (calls functions from DLL2 exported header files)

--------------------------------------------------------------------------

DLL2 (calls functions from DLL1 exported header files)

--------------------------------------------------------------------------

DLL1      <--------------------  you can also create a GUI that only calls DLL1 exported header files to test out functions

 

 

One suggestion... I build my DLLs in debug mode and use them to test out my code.  But I also build them as static libraries.  When I do the final build of the system, I use the static libs.  They are built in with the final executable and don't require extra files to install like the DLLs do.  When you install your system with DLLs, you must include ALL DLLs and they have to be installed in the target machine's Windows/System32 folder.

 

Hope this helps...

 

Judy

0 Kudos
Message 3 of 7
(9,254 Views)

oh great ! thank you judy.. it was with the UIR's that i was facing a problem..

thanks eren for the links.. much appriciated..  

0 Kudos
Message 4 of 7
(9,231 Views)

Hi judy in my case dll1 contains the UIR that i want dll2 to call..

dll2 is calling the functions of ddl1 perfectly but the functions are supposed to bring up the UIR which is not happening. 

dll2 contains the header file and .lib of dll1.. 

how do i get dll2 to bring up the UIR of dll1 ? 

0 Kudos
Message 5 of 7
(9,226 Views)

Sorry your explanation was perfect.. its working beautifully.. Thank you !!

0 Kudos
Message 6 of 7
(9,221 Views)

You're very welcome!!! Smiley Happy

0 Kudos
Message 7 of 7
(9,212 Views)