08-22-2008 01:37 AM
Hi,
Is there any facility in LabVIEW to interface other programing files like *.c and *.h?. If so could you please help me out how to do the same.
Thanks
Haneef
08-22-2008 02:05 AM - edited 08-22-2008 02:06 AM
Hi Haneef,
can you explain what you try to do with *.c and *.h files?
You can use the "call library nodes", "code interface nodes" or ActiveX functions, ...!
Mike
08-22-2008 02:07 AM
If you have built a DLL from your .c file you can use the .h file to import the DLL interface.
Ton
08-22-2008 04:24 AM
Hello Mike,
I am having the files *.c file and header of that (*.h).
I am going to do some program in labVIEW, mean while i need the help of this *.c file. So now tell me how to get the access of this file in current labVIEW file.
Further clear : Let us say I am having files called "sub.c" and "sub.h", I need the help of these two files in "sort.c" for sorting the aaray. What we are going to do in C is just including the header (#include "sub.h") in "sort.c". But I need the same thing to include "sub.c" or "sub.h" in labVIEW file called "sort.vi".
Thanks
Haneef
08-22-2008 04:31 AM
Hi Haneef,
to use your c code in LabVIEW, you have to write a dll of it .You can then use the call library node to use the exported function. If you only want to sort an array, then you can use the build in functions from LabVIEW.
Mike
08-22-2008 04:53 AM
Hi Mike
Well, how to create DLL file using Microsoft VC++ 6.0. Please explain what are the steps involved in this process or give me any documents, links which helps me to solve the same. I am beginner with LabView, pls help Mike....
Regards
Haneef
08-22-2008 04:55 AM
To extend Mike's answer:
It is not possible to include any type of non-executable code in LabVIEW. You always have to create an executable version of your code before including this in LV.
The executable version could be a dll (most common for this purpose) or an .exe which is called by "System Exec.vi" or if you compile it to be an ActiveX-server and use ActiveX for interfacing. Each method has its own advantages and disadvantages.
There is, as almost always, one exception:
The Code Interface Node (CIN) is capable to be connected to C-files. But those have to be created especially for this. Please read the documentation in the CIN if you are interested in going that way. And please note the following sentence:
However, National Instruments recommends using a shared library rather than a CIN if you want to use a language other than C or C++.
hope this helps,
Norbert
08-22-2008 09:40 AM
Indiranagar wrote:Hi Mike
Well, how to create DLL file using Microsoft VC++ 6.0. Please explain what are the steps involved in this process or give me any documents, links which helps me to solve the same. I am beginner with LabView, pls help Mike....
Regards
Haneef
Creating a DLL is not something you do with LabVIEW. You need to look at the documentation that comes with MS VC++ 6.0 to create the DLL. There's plenty of examples on the internet on how to create DLLs. MS VC++ also has project wizards for creating DLLs. You can look at the "Call DLL" example that ships with LabVIEW. That has many examples that show you how to call a DLL from LabVIEW. All of the code, including the C code that is used to make the DLL is provided with LabVIEW in the examples folder. There's also a chapter in the LabVIEW Help on how to call DLLs. You can also look at this KB article: Building a DLL with Visual C++
One gotcha that you must be aware of: You must make sure that you make a C DLL, and not a C++ DLL. LabVIEW does not handle C++ DLLs. If you compile the DLL using V++ then you must adorn all of your functions with the extern "C" modifier so that LabVIEW will be able to access the function.