文章归档

64位matlab mex64位编译器解决方案

今天打算在64位的matlab上使用libsvm训练个数据,发现libsvm的matlab版不能成功make,mex需要使用64位编译器,于是就去寻找各种解决方案,下面是mathworks给的一个technical solution。

http://www.mathworks.com/support/solutions/en/data/1-6IJJ3L/index.html?solution=1-6IJJ3L

Subject:

How can I set up Microsoft Visual Studio 2008 Express Edition for use with MATLAB 7.7 (R2008b) on 64-bit Windows?

Problem Description:

I would like to set up Microsoft Visual Studio 2008 Express Edition for use with MATLAB 7.7 (R2008b) on 64-bit Windows.

Solution:

The support for Microsoft Visual Studio 2008 Express Edition to create MEX files has been added in MATLAB 7.7 (R2008b). On 64-bit Windows, Visual Studio 2008 Express Edition support requires you to install some optional components as detailed below. Note that in some cases, the configuration steps described below are known to work with MATLAB 7.8 (R2009a), MATLAB 7.9 (R2009b) and MATLAB 7.10 (R2010a) as well.

When using 64-bit MATLAB on 64-bit Windows, you must use a 64-bit compiler to build MEX-files, MATLAB Compiler & Builder components, Simulink S-functions, RTW models, etc. The full list of supported products is available at:

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

The default installation of Visual Studio 2008 Express is only capable of building 32-bit binaries, and will not work with MATLAB.

In order to build 64-bit binaries, the “x64 Compilers and Tools” and Microsoft Windows Software Development Kit (SDK) must both be installed. The x64 Compilers and Tools are not installed by default.

Without these packages, Visual Studio can build simple C/C++ applications as 32-bit binaries — “Hello World” type programs compile and execute as expected. However, Visual Studio cannot build the 64-bit binaries MATLAB requires.

To install Visual Studio 2008 Express Edition with all required components:
1. Install Microsoft Visual Studio 2008 Express Edition. The main Visual Studio 2008 Express installer is available from (the C++ installer name is vcsetup.exe):

http://www.microsoft.com/downloads/details.aspx?
displaylang=en&FamilyID=a22341ee-21db-43aa-8431-40be78461ee0

This package can be installed using the default options.

2. Install the Microsoft Windows SDK. The Microsoft Windows SDK is available by searching Microsoft’s download site, or by going directly to:
http://msdn.microsoft.com/en-us/windowsserver/bb980924.aspx
or
http://www.microsoft.com/downloads/details.aspx?FamilyId=F26B1AA4-741A-433A-9BE5-FA919850BDBF&displaylang=en

Download the Windows Server 2008 & .NET 3.5 SDK. Do not install beta or ‘Release Candidate’ (RC) versions. Also do NOT install “Microsoft Windows SDK for Windows 7 and .NET Framework 4″ (version 7.1); if you want to use a 7.x version choose the “Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1″.

2.1. While installing the SDK, you must select “x64 Compilers and Tools”. For example, in the SDK installer above:
On screen “Installation Options”
Select “Developer Tools”->”Visual C++ Compilers”.
This item has the Feature Description “Install the Visual C++ 9.0 Compilers. These compilers allow you to target x86, x64, IA64 processor architectures.”

3. To verify that you have all installed components, check that the Microsoft SDK contains the “amd64″ version of the C/C++ compiler “cl.exe”. This is usually installed into

C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\amd64\cl.exe
4. At this point you should be able to proceed and compile code as usual.

For example, to select the compiler and build the YPRIME.C example MEX-file,
mex -setup % Select Visual Studio 2008 Express Edition
copyfile(fullfile(matlabroot,’extern’,'examples’,'mex’,'yprime.c’))
mex -v yprime.c
yprime(1,1:4)
The final line should execute the MEX-file, and calculate the following output:

ans =

2.0000 8.9685 4.0000 -1.0947If you are unable to select your compiler, compile the MEX-file, or execute the MEX-file, consult the Troubleshooting section below.

5. Troubleshooting
If the “x64 Compilers and Tools” are not installed properly, MATLAB might display one of the following messages:

*****************************************************************************
Error: Could not find the 64-bit compiler. This may indicate that the
“X64 Compilers and Tools” or the Microsoft Windows Software
Development Kit (SDK) is not installed. To build 64-bit MEX-files
Microsoft Visual C++ 2008 Express Edition requires that these two
packages are installed properly.
*****************************************************************************
*****************************************************************************
Error: Could not find the Microsoft Windows Software Development Kit (SDK).
This may indicate that the Microsoft Windows SDK or the
“X64 Compilers and Tools” is not installed. To build 64-bit
MEX-files Microsoft Visual C++ 2008 Express Edition requires that
these two packages are installed properly.
*****************************************************************************If you see these messages, you may not have the SDK or x64 Compilers and Tools installed properly, or MATLAB may not be able to locate them on your system. Verify that you have installed these packages as described above. For additional assistance, contact MathWorks Technical Support.

For information on which MathWorks products support Visual Studio 2008 Express Edition in your release, see the Supported Compiler List:
http://www.mathworks.com/support/compilers/current_release/

Related Solutions:

菊子曰 我用菊子曰写博客,你呢?

无觅相关文章插件,快速提升流量