02-13-2012 03:30 AM
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 !
Solved! Go to Solution.
02-13-2012 05:51 AM
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
Exporting Variables and Functions from a DLL in LabWindows/CVI
02-13-2012 07:54 AM
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
02-14-2012 02:43 AM
oh great ! thank you judy.. it was with the UIR's that i was facing a problem..
thanks eren for the links.. much appriciated..
02-14-2012 02:58 AM
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 ?
02-14-2012 04:24 AM
Sorry your explanation was perfect.. its working beautifully.. Thank you !!
02-14-2012 07:29 AM
You're very welcome!!!