Loading 64-bit National Instruments library in 64-bit Matlab

Hi everyone,
I am trying to directly call functions in the National Instruments DAQmx driver in a 64-bit setup via loadlibrary. We have everything working under 32-bit, but when switching to 64-bit things break (the setup is 64-bit Matlab 2011b on 64-bit Win7 with the 64-bit driver installed).
When I try to load the 64 bit DAQ dll ('C:\Windows\SysWOW64\nicaiu.dll') using loadlibrary, I receive the error below (both nicaiu.dll and NIDAQmx.h are copied to a local directory.):
>> [A,W] = loadlibrary(['nicaiu.dll'],'NIDAQmx.h','alias','nidaqmx');
Error using loadlibrary (line 421)
There was an error loading the library "C:\Users\NSL_User\nicaiu.dll"
C:\Users\NSL_User\nicaiu.dll is not a valid Win32 application.
Caused by:
Error using loaddefinedlibrary
C:\Users\NSL_User\nicaiu.dll is not a valid Win32 application.
I have read everything I could find on the web, but am not clear why this doesn't work. I can load the 32-bit library from Matlab, but that leaves me with some type incompatiilities (the libpointer for the task is not recognized when passing it back to the driver).
Insights would be highly appreciated,
Thanks & Best wishes,
Bernhard

 Accepted Answer

The "is not a valid Win32 application" error usually means that you are attempting to load a 32-bit DLL using 64-bit MATLAB. Perhaps there are no 64-bit versions of the NI DLLs available? You can try installing 32-bit MATLAB on your 64-bit machine and see if you are able to load the libraries from that installation.

3 Comments

Dear Kaustubha,
thanks for your answer. I have tried this and another avenue in the meantime:
1) Using 32-bit MATLAB on 64-bit Windows : allows me to access the driver in the same way I could on a 32-bit machine. Hence, the problem would be solved, although the goal of switching to a 64-bit machine was to make use of the additional memory.
2) Using 64-bit MATLAB on 64-bit Windows: I used a loadlibrary call of the NIDAQmx.h file provided by the DAQmx driver together with the niciau.dll in C:\Windows\System32 (which is where the 64-bit library are apparently stored). The driver loaded find (with some warnings), and I could make calls into the driver (DAQmx... functions), as long as no Task handle was required. Task handles are usually libpointer('uint32Ptr',false) on 32-bit systems, which identify a task in the NI driver. In this setup, however, the returned task handle was always the same and was not recognised by the driver when using a function which uses the task handle (Error Code: DAQmxInvalidTask). It seemed like a type-error, but I doubt this, since a) I have tried all available types and b) the returned value of the Taskhandle is always the same, even if multiple tasks are created.
While the question is quite specific at this point, I would still be interested whether you have some ideas.
Thanks,
B
Bernhard: What type would you use for the task handles if you were writing a 64-bit C application (outside of MATLAB) to call into the 64-bit DLLs?
The key here is that the 64bit .dll is inside system32. I verified this myself.

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!