LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Having problems making Call Library Function Work

I have tried reading other threads related to my problems, but can't figure out what to do. I am simply trying to use the call library function for a C++ program that receives 2 numbers and returns the sum (once I have this down, I intend to work with more complicated C++ programs for the project I am needed to work on). I have a function called 'add' in the C++ program that I finally figured out how to export (using previous forum threads) and so LabVIEW does see the function now. But when I run the VI, it gives me this error:

"LabVIEW: An exception occured within the external code called by a call library node.
This might have corrupted LabVIEW's memory.
Save any work to a new location and restart LabVIEW."


Do I really have to keep saving to a new location every time I try to run this and get this error? And what should I be looking at to stop this error from occuring? I have 2 controls for the input numbers on the front panel, and one indicator for the output. I put a break point after one of the controls and before the Call Library Function, it gives me the error after I step over the breakpoint.
I am thinking that maybe I am doing something wrong in my C++ program, but it is such a simple program I don't see what it could be.
I am running Microsoft Visual C++ 5.0 to create the .dll and LabVIEW 7.1.
Thanks for any input.

Lori
0 Kudos
Message 1 of 4
(2,275 Views)
It sounds like you are using different calling conventions. In LabVIEW's Call Library Function dialog, there is an option for Calling Convetions that can be set to either C (cdecl) or stdcall (WINAPI). This has to match the DLL you are calling, so try the other option of what it is set to now.

See the pdf document titled "Using External Code in LabVIEW" for more details.
Message 2 of 4
(2,275 Views)
Well that was much easier than expected. I had thought I tried that, but you got me to 'try' it again, and it worked.
Thanks Muchly,
Lori.
0 Kudos
Message 3 of 4
(2,275 Views)
You're welcome. You can also set LabVIEW as the target application in VC. This way, you'll run LabVIEW, and it will hit the breakpoints in your C code.
0 Kudos
Message 4 of 4
(2,275 Views)