LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

can i call a dll developed by labview 6.1 in Borland c++ builder?

Someome want to call my dll file generated by labview 6.1 in Borland c++ builder. i don't know if is possible. if so,should he install the run-time engine ?
0 Kudos
Message 1 of 14
(4,941 Views)
wbl,

Yes, he can call the DLL and yes, he will need the Run-time Engine. Other than that, it is just like calling any other DLL from C++. (Here is a link to a tutorial for doing it in Microsoft Visual C++.)

Randy Hoskin
Applications Engineer
National Instruments
http://www.ni.com/ask
0 Kudos
Message 2 of 14
(4,939 Views)
Borland cannot read the .lib files generated by LabVIEW although Visual C++ can. Therefore the tutorial is not of much use!
0 Kudos
Message 3 of 14
(4,939 Views)
Use implib in the borland bin directory.
Note copy it the the dir that the dll is in.

Asuming you used the c calling convention when creating DLL in labview.
Implib -a mylib.lib Labview.dll
0 Kudos
Message 4 of 14
(4,939 Views)
I guess I wasn't that clear, if I understand your comment correctly.

Creating MyLV_DLL.lib for Borland from MyLV_DLL.dll is fine using implib. However, for the Borland project to compile for use with the LVRTE it also needs to read Labview.lib, which it can't. There is no matching labview.dll. The runtime engine has various DLLs, of which the most obvious is lvrte.dll. I created a Labview.lib from lvrte.dll using implib and this lib file works for many, but not all MyLV_DLL.dll (it's only certain types of operation which break, but I can't recall which - the project compiles but generates funky errors at run time); the identical DLL runs fine from within a similar compiled Visual C++ project which can use the Labview.lib file pro
vided by NI. Getting the DLL dependencies shows it calls some of the other LV DLLs, so I created libraries for these as well which further improves matters. Implib doesn't know how to make all these connections properly automatically I guess.

From my point of view I've found a happy medium of things I can do in MyLV_DLL.dll which are compatible with my Borland project and my collection of implib created Labview library files.

NI tech support have confirmed that there is no support for Borland within LV and no Borland compatible version of Labview.lib exists (v7+ at least), thus I'm on my own...
0 Kudos
Message 5 of 14
(4,939 Views)
If you compile a labview project as a DLL there are no real problems calling that DLL from Borland.

You do not need any Labview DLL's compiled with Borland other that the DLL you created.
You do need the Labview Runtime on the target machine.

Create DLL in Labview, compiled using the c calling converntion (tick the box)
Compile vi in DLL (tick box) so you do not need external vi's.

The lib file created is not Borland compatable so you need to create your own from the DLL.

implib -a mylib.lib mydll.dll

mydll.dll is the dll you created, you should not need any other dll.

Copy the dll and mylib.lib + header file to your borland project directory.
You my need copy other header files as well which are call
from the header you just included.
These can be found under the cin directory.(some where)

As I tend not to use NI defines I rem the extra headers out.

>>Labview.lib
It does not need this.

You call your DLL, your DLL call the labview DLL's so you dont need them in Borland.

Hope that helps

Home time
0 Kudos
Message 6 of 14
(4,939 Views)
My apologies, I may have merged two issues here as it was a while since my original comment. As I'm not the Borland developer I'm working from memory.

I wanted to work with arrays in my DLL, and so ideally require access to the LabVIEW memory manager functions which are partly in lvtre.dll and partly in other NI LV dlls. I seem to remember this is necessary if you want to, for example, set array sizes dynamically at run-time at the C++ end. Thus for simple access to the DLL using implib on MyDLL.dll to create MyDLL.lib for Borland works, but to use the more sophisticated memory management functions you need to delve into LabVIEW.lib (I was following examples I found in the KB).

If you know a way of dynamical
ly allocating/resizing arrays in Builder and then passing these back and forth from Builder to a LV dll then I'd be very pleased to learn of it; I just get memory.cpp and other errors - I don't get these from Visual C++. At present I define an array of the maximum expected size at compile time and check I don't exceed it at run-time; memory inefficient but it works!

My original point that the tutorial mentioned at the start of the discussion is not valid for Borland is correct - until implib is used as you discussed.
0 Kudos
Message 7 of 14
(4,939 Views)
My answer was based on the question ask.

My software is in Borland not Labview so I am not a Labview expert.

I assume that the caller is responsible for memory management, I don�t know how Labview would work with a pointer to an array.

NI tech support should answer this one.

I have done this the other way around (Labview creating array and passing to my DLL) which is OK as I had full control of the code in my Borland DLL.

Labview does have an array initialise vi that you could set the size to if that helps but then I thing you would have a problem with scope as it would be Labview allocating memory and not Borland so the pointer could be invalid after the call (dont know).

If you link
the VCL into the exe for a stand alone program, in Borland there are some circumstances that you have to ship the Borland memory manager DLL with your app. Check the Borland help.

Could it be the that you need to aline the array to 1 byte boundary as stated in the Labview header created for DLL?

Not must help.
Funny that Borland support is still in Labwindows so NI can do it if they whan't to.

As a side note the new FPGA modules do not seem to work with Borland when the host vi is compiled as a DLL.

None FPGA code works OK. Odd that as a dll is x86 code, the caller VS or Borland should not make any difference.

I would be interested if you get an answer to your problem as I might need to do the same one day.

Colin
0 Kudos
Message 8 of 14
(4,940 Views)
Try a new qestion as NI will not look at answered question like this one.
They only look at unanswered qestions.

Colin
0 Kudos
Message 9 of 14
(4,939 Views)
I did post a question a while ago with no response. I can deal with 1D numeric and string arrays, but arrays of clusters or arrays of more than 1 dimension only compile to a DLL with a special LV type definition - it is manipulating those arrays from the C end I was having problems with. For 2D arrays I've now stuck to 1D string arrays using [TAB] and [,] as delimiters for rows and columns; for clusters I've used name/value pairs.
0 Kudos
Message 10 of 14
(4,939 Views)