LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling a Vi in C++

Hello,

 

I want to call a Vi(compiled to a .dll) in C++. Sadly there are very litte Examples.The Vi should just take 2 numbers and return the sum. I added the cintools folder correctly to my project and Visual Studio 2010 gives mit the following Error:

 

Spoiler
1>plus.obj : error LNK2028: unresolved token (0A000050) "extern "C" int __stdcall Viincpp(int,int)" (?Viincpp@@$$J18YGHHH@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)
1>plus.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall Viincpp(int,int)" (?Viincpp@@$$J18YGHHH@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)
1>c:\users\matthias\documents\visual studio 2010\Projects\plus\Debug\plus.exe : fatal error LNK1120: 2 unresolved externals

 

What is my mistake?

 

 

Thanks

 

Matthias

 

 

 


I

0 Kudos
Message 1 of 10
(4,424 Views)

I haven't looked at your attachment, but does the target computer have the correct version of the LabVIEW run time engine installed?

(details)

 

What LabVIEW version was used to make the dll?

0 Kudos
Message 2 of 10
(4,412 Views)

I used Labview 2011 to compile the .dll . I tried to execute it on the same computer I compiled it. Do I have to install Labview 2011 und Labview Runtime Environment?

 

0 Kudos
Message 3 of 10
(4,389 Views)

When you create a DLL in LabVIEW you get the DLL file, a .h file and a .lib file. The DLL file is obvious where to put, the .h file needs to be #included in your C(++) source code somewhere, and the .lib file needs to be linked with whatever executable file you are producing. Now there is a potential gotcha with this since the created /lib file is in COFF library format, the binary format used by the Microsoft C compiler. If you are using a different C compiler than from Microsoft, it may not like the COFF library format at all, or at least have some trouble to process the specific format created for Microsoft C.

 

If that is a problem in your case you can work around it by caling LoadLibrary() and GetProcAddress() explicitedly for every function you want to call from the LabVIEW DLL, and avoid the need for the created link library entirely.

 

But since you seem to be using Microsoft Viaul C, simply make sure to open the project settings and there the linker settings for your target file, and then under additional link libraries, add your addition.lib file.

Rolf Kalbermatter
My Blog
Message 4 of 10
(4,361 Views)

Hi,

 

The Runtime Engine is normally automatically installed while installing LV.

But to be shure you can check in MAX->Software if it is also installed on the computer on which you compiled your .dll file.

 

Regards

Daniel

0 Kudos
Message 5 of 10
(4,340 Views)

Sorry Danial, but the compile errors in Visual Studio have nothing to do with the LabVIEW runtime system. They come from the fact that the link library for the DLL has not been included in the link settings for the VS project. Once the OP gets past this and receives some error messages when trying to start the executable that calls the LabVIEW DLL we can go and look if the runtime system is an issue.

Rolf Kalbermatter
My Blog
0 Kudos
Message 6 of 10
(4,306 Views)

Hello Rolf,

 

I think you are right about the problem with the not included library.

I just wantet to tell Matthias how he can check his installed software and the versions of this software.

 

I think your advice should help to prevent the error Matthias is getting right now.

 

Regards

Daniel

0 Kudos
Message 7 of 10
(4,301 Views)

Hi Matthias,

 

any new information?

 

Regards

Daniel

0 Kudos
Message 8 of 10
(4,249 Views)

hi, i am new in this field and i have no idea how i cant post a new thread.
but i have problem with my labview program which in associate with cRio-9025

which also doing the data acquisition of temperature.
below is my programing, pls help me to check on it.
Apprecite it, thanks

0 Kudos
Message 9 of 10
(4,160 Views)

In order to post a new topic you first should make a search in the forum for your topic and not simply attach it to some completely unrelated post. On the result page you should find the option to create a new topic.

Rolf Kalbermatter
My Blog
0 Kudos
Message 10 of 10
(4,156 Views)