LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

intefacing external file like *.h and *.c

 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 

0 Kudos
Message 1 of 8
(3,466 Views)

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

Message Edited by MikeS81 on 08-22-2008 09:06 AM
Message 2 of 8
(3,463 Views)

If you have built a DLL from your .c file you can use the .h file to import the DLL interface.

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 3 of 8
(3,460 Views)

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 

0 Kudos
Message 4 of 8
(3,443 Views)

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

Message 5 of 8
(3,441 Views)

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 

 

0 Kudos
Message 6 of 8
(3,431 Views)

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 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 7 of 8
(3,429 Views)

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. 

0 Kudos
Message 8 of 8
(3,406 Views)