Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

How to dynamically allocate memory?

I am using a custom built PCI DAQ card hardwired for a particular address.
For acquiring the data, I used the inport.vi and outport.vi but it is slow.
So, I wrote a C pgm and made a dll file and thought of using in LV. But I am
facing the following problems in the Win98 system.

1. In the Visul C++ IDE, in the project->settings->c/c++->code generation
field, if I select Debug Multithreaded DLL, I am getting a message "unable to
load secondry DLL" when I open the VI. But when I open the VI in Win2000
system, the DLL is getting loaded and there is no error. If the option is
selected as Debug Multithreaded , then the DLL gets loaded in Win98 systems.
I dont understand the difference between these two options. Can anyone please
explain me the significance of these choices?

2. In my C pgm, I wanted to use dynamic memory allocation using "malloc"
function. When I use this function, the following error message comes when
the VI is executed: "An exception has occured within the external code called
by LabVIEW call Library node". I have attached my C pgm with this mail. Can
anyone help me on how to use dynamic memory allocation ? Should I look for
CINs?

Thanks & Regards,
Srini
0 Kudos
Message 1 of 2
(3,095 Views)
This MSDN document describes those various options. Im not sure why you would be getting these kinds of failues, I would recommend posting on the LV forum to see if someone has seen this before.

That error is an indication that something generated an error in your DLL. One thing you can do to track such issues is to debug into the DLL using Visual Studio. Under the debugging options in the project settings, set LabVIEW.exe to be the external process. when you run the Visual Studio project, it will launch LV for you. You can set breakpoints in your DLL code and when you run the VI, the debugger will let you step thru the DLL code.

One thing to mention is that if you are allocating memory for data that you want to pass back into LabView, you need to use the LabVIEW memory manager functions. Using malloc and calloc will not work, since these are not labview aware. This also depends on how you have configured the "Call Library Node". You can find more information about using DLLs with LV in the Using External Code in LabVIEW manual.

Hope this helps
Bilal Durrani
NI
0 Kudos
Message 2 of 2
(3,085 Views)