U12, Matlab 64 bit | LabJack
 

U12, Matlab 64 bit

3 posts / 0 new
Last post
jbiele
jbiele's picture
U12, Matlab 64 bit

Problem: call of U12 functions under a 64bit-version of Matlab does not work, though the dll’s are on Matlab’s search path.

From Labjack support:

If Matlab is 32-bits since it works with our old 1.18 CD installer and MATLAB dlls and cpps which are 32-bit only.

First, the dlls from Matlab_func.zip are 32-bit only and we don't update those anymore or have 64-bit versions. They are still available for download here (Old LJMATLAB):

https://labjack.com/support/software/examples/u12/matlab

To continue using this interface, you will need to build new MEX files (dlls) with your version of MATLAB and the cpp source files:

http://www.mathworks.com/help/matlab/matlab_external/creating-c-mex-files.html

Alternatively, you can update your MATLAB and LabJack code to use our .NET interface or use the U12 driver directly with MATLAB loadlibrary/calllib functions.

Second, with 64-bit MATLAB you will need to use our 64-bit U12 driver. Our latest installer, LabJack-U12-Installer-2015-03-27, will install both 32 and 64-bit versions of our dll. It is alright to uninstall the

"heritage" version as the installer will install newer versions of our software/drivers. Note that our software, not including the dlls, are installed in the "\Program Files (x86)\LabJackU12Legacy" folder now.

Do I still require the labjack/ folder (from Matlab_func.zip)?

That depends. If you are rebuilding the MEX dll files, then you still want that folder. Otherwise if you are rewriting the LabJack calls to not use the MEX files, then it is no longer necessary.

What are the high-level drivers or whatever that Matlab requires to access the functions?

Our U12 driver is ljackuw.dll. It seems like your MATLAB code was using our old MEX dlls from Matlab_func.zip, which uses ljackuw.dll.

Or a system search path issue?

On 64-bit Windows, 32-bit drivers are located in the Windows\SysWOW64 folder and 64-bit drivers are in Windows\System32 folder. It doesn't sound logical, that is the way Windows has it.These are the typical system search paths. Copying 32-bit drivers to System32 will not make them work in 64-bit applications.

Now uninstalled the heritage version (and deleted the dlls and libs in Windows\System32) and installed the 64bit U12 driver (and Labview RTI where I manually had to delete Cwds.hlp in Windows\SysWOW64). I now have 2 different ljackuw.dll: one in System32, 133120 bytes, one in SysWOW64, 128000 bytes, both of May 9, 2014.

Rebuild labjack mex-files for 64bit Matlab

In 64 bit Matlab:

>>mex –setup % make sure that the SDK 7.1 C++ compiler is there

Here is the Matlab script that does it all, in one go:

% rebuild labjack mex-files for 64bit Matlab
% 29.7.2016, see email Labjack support. SDK 7.1 and .NET 4 need to be
% installed properliy, see document on Labjack for 64 bit Windows
ljdir='D:\Documents\MYMATLAB\labjack'; % directory with the .cpp and ljackuw.lib
cd(ljdir)
list=ls('*.cpp'); % 36x22 1584 char
for i=1:length(list),
  fn=list(i,:);
  s=['mex ' fn ' ljackuw.lib'];
  eval(s);
end
% Building with 'Microsoft Windows SDK 7.1 (C++)'.
% MEX completed successfully.

Notes for proper installation of SDK 7.1:

If you want to try compiling the mex files for yourself, for MATLAB 2013a (and 2015a) you can install the Microsoft Windows SDK 7.1 (there are other options as well):

http://www.mathworks.com/support/sysreq/files/SystemRequirements-Release2013a_SupportedCompilers.pdf

[https://de.mathworks.com/matlabcentral/answers/101105-how-do-i-install-m...

PREREQUISITE INFORMATION

If you have any of the following cases true, see the troubleshooting section at the bottom before proceeding with the SDK 7.1 installation.

Microsoft Visual Studio C++ 2010 SP1 installed (version greater than 10.0.30319)

.NET Framework 4.5 installed (also bundled with Visual Studio 2012 or later)

INSTALLING THE WINDOWS SDK 7.1

1. Download Windows SDK for Windows 7 and .NET Framework 4 from Microsoft at:

http://www.microsoft.com/en-us/download/details.aspx?id=8279

2. When the download is complete, choose to run winsdk_web.exe. Depending on your security settings, you may be prompted by User Account Control (UAC) to confirm “making changes to this computer”.

3. After several seconds, the Setup Wizard will appear.

https://de.mathworks.com/matlabcentral/answers/uploaded_files/34907/a6c75f7f8224e9c096e09d0d7a273185.png

4. Click through the wizard, accepting the license agreement and not changing any of the installation folders.

https://de.mathworks.com/matlabcentral/answers/uploaded_files/34908/fa269a29f7bf9ca29611dfd1c9b319ea.png

During installation, under the "Installation Options" menu, UNCHECK the "Visual C++ Compilers" and "Microsoft Visual C++ 2010" components.

5. Continue through the wizard to download and install the SDK. Depending on the speed of your Internet connection, this step will take several minutes to an hour or more.

6. The setup wizard finishes.

https://de.mathworks.com/matlabcentral/answers/uploaded_files/34910/4c8a2a5432ac99fbe5baab4f23c94ed3.png

TROUBLESHOOTING

.NET Framework 4.5 already installed

If you have .NET Framework 4.5 installed, SDK 7.1 may fail to install. In this case:

Uninstall .NET Framework 4.5.

Install the SDK 7.1 using the instructions above.

Reinstall .NET Framework 4.5.

If SDK 7.1 was already installed, but with a message saying .NET 4 could not be installed due to the presence of .NET 4.5, you may need to uninstall .NET 4.5 first as well and retry.

Microsoft Visual Studio C++ 2010 SP1 already installed

If Microsoft Visual Studio C++ 2010 SP1 is already installed, SDK 7.1 may fail to install. In this case:

Remove the 2010 Redistributable packages (both x86 and x64). For that, navigate to the windows control panel -> click on "programs" -> click on "Programs and Features" -> select the required programs to be removed.

Install SDK 7.1 using the instructions above.

Apply the SDK 7.1 patch.

Reinstall 2010 Redistributable packages.

If you have both Microsoft Visual Studio C++ 2010 SP1 and SDK 7.1 already installed, but running into various errors during compilation, apply the SDK 7.1 patch to fix the issue.

"ammintrin.h missing" error

This occurs if only SDK 7.1 was installed (without Microsoft Visual C++ 2010 SP1 present on the machine), and then the SDK 7.1 patch is applied. In this case:

Install Visual Studio C++ 2010 (if not already installed). Either Professional or Express works.

Upgrade Visual Studio C++ 2010 to SP1

SUPPORTING LINKS AND INSTRUCTIONS

Installing the SDK 7.1 patch

The SDK 7.1 patch can be download and installed from:

<http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=4422 >

Upgrading Microsoft Visual Studio C++ 2010 to SP1.

Microsoft Visual Studio C++ 2010 SP1 upgrade can be obtained from:

http://www.microsoft.com/en-us/download/details.aspx?id=23691

N.B: Install The SDK 7.1 patchto restore the Visual C++ compilers and libraries that may have been removed when Visual Studio 2010 Service Pack 1 (SP1) was installed. The compilers and libraries are part of the Microsoft Windows Software Development Kit for Windows 7 and the .NET Framework 4 (later referred to as the Windows SDK 7.1).

[https://de.mathworks.com/matlabcentral/answers/95039-why-does-the-sdk-7-...

There is an issue with Microsoft Windows SDK 7.1. It may occur under two scenarios:

1. If you have Microsoft Visual C++ 2010 SP1 (Express or Professional) installed.

2. If you have Microsoft Visual C++ 2010 redistributable packages (x64 or x86) installed.

The details on the issue from Microsoft are below:

http://support.microsoft.com/kb/2717426

http://support.microsoft.com/kb/2519277

To avoid this issue:

1. Uninstall the Microsoft Visual C++ 2010 redistributable packages (both x86 as well as x64) from “Control Panel” > “Programs and Features”. If you have trouble uninstalling them, see related solution 1-NBI41W at the bottom.

2. Install the Windows SDK 7.1. During installation, under the "Installation Options" menu, UNCHECK the "Visual C++ Compilers" and "Microsoft Visual C++ 2010" components.

3. Apply the SDK 7.1 patch from below:

http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=4422

4. Reinstall the Microsoft Visual C++ 2010 redistributable packages.

x64:

http://www.microsoft.com/en-us/download/details.aspx?id=14632

x86:

http://www.microsoft.com/en-us/download/details.aspx?id=5555

LabJack Support
LabJack Support's picture
Thanks for posting this which

Thanks for posting this which is useful for people rebuilding our old U12 mex files (dlls), which we no longer update, for 64-bit MATLAB.

Note to users, you will need to install the correct compiler for your version of MATLAB:

http://www.mathworks.com/support/compilers/R2016a/

http://www.mathworks.com/support/sysreq/previous_releases.html

For new MATLAB users and in general users of MATLAB R2009a and newer, we recommend using the .NET method of using the U12 library instead of the mex method:

https://labjack.com/support/software/examples/u12/matlab

jbiele
jbiele's picture
Here are the mex files for

Here are the mex files for Matlab 64 bit in a folder labjack/

The files include the old dlls (should actually be renamed to .mexw32 for future versions of Matlab) for 32 bit-Matlab, the .cpp files (unchanged) and a simple Matlab script to do the compilation.

File Attachment: