12-06-2023 02:09 PM
I have recently been asked to assist other developers that are using LabVIEW. The trouble is that I use LabWindows/CVI or VB.NET.
In order to launch, I would like to know how I could make the simplest library possible:
1. Call DLL in LabVIEW
2. DLL outputs a string "Hello World!"
This is two steps. I need to make the program in CVI with a function to return a string holding the value "Hello World!", and I need to have a colleague call that function in LabVIEW. Let's focus on the CVI side step 1 since this is the CVI forum.
How can I do this?
Note: My current experience with CVI is writing a program with no UI for real time PXI targets.
Solved! Go to Solution.
12-07-2023 02:13 AM
It's not particularly hard, and it's been discussed before: https://forums.ni.com/t5/LabWindows-CVI/Create-dll-for-use-in-Labview/td-p/3226349
12-11-2023 08:08 AM
That link has two links to the CVI help site and neither go to their original sources. They just go to the top.
The forum post says you need to put your code into a "Function Panel." I don't know what a function panel is. Because my only experience with CVI is writing for real time targets, I always have a main function and some program flow with no UI. For a dll to add functionality to LabVIEW, is it only a set of functions without main, or do I still need main? I also have to have a .h file. What would this .h file hold? Currently my .c file holds everythign wrt the real time application.
12-11-2023 08:36 AM
I have opened an example in CVI. If I don't need a GUI would I just remove the panel parts of the example like I do for other sample code I import for real time targets?
12-11-2023 09:11 AM - edited 12-11-2023 09:12 AM
You can start by examining the examples of DLL projects that ship with CVI.
Start the Example Finder by executing Help >> Find examples... menu item, next open Search tab and search for "DLL": this will list in the middle section of the window all the examples related to DLLs that are present on your disk. Click on each of them to read a short description in the Information box. Double-click on an example to open it in the CVI IDE. I suggest you to start from cvidll.prj example.
12-11-2023 01:05 PM
I am trying cvidll.
I tried to run it and it said I needed to go to Run->Specify Executable and Command Line. It doesn't really tell me what it's looking for here, so I tried to Google it. No good examples.
So here is what I tried:
Still not happy:
12-12-2023 04:09 AM
This is the readme file in the project:
These samples require you to do the following:
1. Generate the LabWindows/CVI DLL and Import Library using cvidll.prj
2. Add the generated Import Library to the usecvidll.prj project
3. Run the usecvidll.prj project.
It works for me (CVI2017) and it does not ask for anything!
As you can see, the example consists of two projects: Cvidll.prj and Usecvidll.prj; both are listed in the workspace tree.
You should:
12-12-2023 07:54 AM
OK that worked. I was pressing the play button when I should have just built it. I followed your instructions and it worked perfectly.
Thank you!
12-13-2023 08:13 AM - edited 12-13-2023 08:14 AM
The saga continues...
I opened LabVIEW and ran the Import Shared Library Wizard.
Didn't add any include paths.
It finds the functions.
Seems OK so far:
Errors!?!
Your generated files are installed in the following folder:
C:\Program Files (x86)\National Instruments\LabVIEW 2018\user.lib\cvidll
Parsing header file warnings:
No errors/warnings occurred when parsing the header file.
The following errors/warnings occurred when generating the wrapper VIs for this shared library.
VI Not Executable
The VI is not executable because of one of the following reasons:
1. The shared library or a dependent file is not installed. To make the VI executable, you must install the shared library and all support files on the computer on which you run the VI.
2. A required custom control might be empty or cannot be found. To make the VI executable, update the custom control manually.
3. The VI contains a parameter with an unsupported data type. To make the VI executable, you must replace the empty cluster that the wizard generates with a control or indicator that uses supported data types.
DLL Func1.vi
DLL Func2.vi
Trying to drop it in the block diagram of LabVIEW.
Any ideas?
12-13-2023 10:53 AM
OK. Disregard all of that. I found a youtube link where some kind gentleman has dumbed it down for me. He made a library with a single function. Following his instructions, though they were actually to call the dll from CVI, I got it to work easily in LV using the same process from the prior post. That means the DLL doesn't really need to have a special format (main, etc.). It ONLY needs to have the functions required in it.
https://www.youtube.com/watch?v=RqgEdenkBRs