Difference between revisions of "ApCoCoA-1:HowTo:Compile MatlabToolbox on Windows"

From ApCoCoAWiki
(Initial description)
 
Line 54: Line 54:
 
Prior to compilation you have to adjust the makefile. Open the file makefile.vc in the ApCoCoALibToolbox subfolder.
 
Prior to compilation you have to adjust the makefile. Open the file makefile.vc in the ApCoCoALibToolbox subfolder.
  
Set the include and lib pathes in the following lines according to your local pathes
+
Set the include and lib pathes to your local pathes. The relevant section is indicated by
 
<c>
 
<c>
_INCLUDES= /I ..\..\CoCoALib-0.9914\include /I ..\..\ApCoCoALib-devel\include /I ..\..\gmp_p4_dll /I C:\Programme\MATLAB\R2006b\extern\include
+
#-------------------------------------------------------------------------------
_LIBS=..\..\CoCoALib-0.9914\src\cocoa-0.99.14-msvc2005.lib ..\..\ApCoCoALib-devel\src\apcocoa-1.09.05-msvc2005.lib  ..\..\gmp_p4_dll\gmp.lib  ..\..\IntelMKL\libs\MKLBlas.lib \
+
# Adjust the following names and pathes
      ..\..\IntelMKL\libs\MKLLapack.lib ..\..\IntelMKL\libs\MKLBlas.lib ..\..\IntelMKL\libs\mkl_c_dll.lib C:\Programme\MATLAB\R2006b\extern\lib\win32\microsoft\libmx.lib C:\Programme\MATLAB\R2006b\extern\lib\win32\microsoft\libmex.lib
+
#-------------------------------------------------------------------------------
 +
 
 +
...
 +
 
 +
#-------------------------------------------------------------------------------
 
</c>
 
</c>
 
Note:
 
* All pathes shown here are relative pathes to the ApCoCoALib folder.
 
* The CoCoALib.lib and ApCoCoALib.lib are generated during compilation of the Ap/CoCoALib. The files are stored in the src subfolder of the Ap/CoCoALib folders. Copy the generated file name to the MatlabToolbox makefile.vc as this filename depends on the downloaded version
 
  
 
==Compilation==
 
==Compilation==

Revision as of 14:29, 2 July 2008

Introduction

  • This site is set up to collect all necessary bits and pieces to compile the MatlabToolbox on Windows.
  • This description is made for compiling the MatlabToolbox with MSVC 2003/2005 and Matlab 2003b.

Preparation

Before compiling the MatlabToolbox you need to install the following files/libraries:

  • CoCoALib: Find a description on how to install the CoCoALib on Windows here.
  • ApCoCoALib: Find a description on how to install the ApCoCoALib on Windows here.
  • HG mercurial: You will need this software to download the latest MatlabToolbox from a repository. The MatlabToolbox is managed with the source control system mercurial. We will refer to TortoiseHG. TortoiseHG will install mercurial on your system and adds a context menu in the MS Explorer providing many of the needed functionalities.
    • Download TortoiseHG here.
    • A more detailed documentation on you how to use mercurial can be found here.

Download Instructions

Get the latest MatlabToolbox version from the repo site. A brief instruction using TortoiseHG is:

  • Add a folder on your local harddisk for the local repo copy.
  • Open the context menu entry TortoiseHG->Clone a repository.
    • As the source path copy the selected link from the repo site.
    • As the destination path select your created folder.
    • Start the download of the ApCoCoALib with the clone button.

Compilation Instructions

Before compiling you have to set up the right compiler in Matlab and adjust the makefile configuration.

Mex Compiler

The MatlabToolbox will use the mex.bat to generate mex files. MSVC has to be defined as the default mex compiler.

To do so open the Matlab command prompt and type in: <c>mex -setup</c> The following information and dialogs will display. Choose the right options as shown. <c>mex -setup Please choose your compiler for building external interface (MEX) files:

Would you like mex to locate installed compilers [y]/n? y

Select a compiler: [1] Lcc C version 2.4.1 in C:\PROGRA~1\MATLAB\R2006b\sys\lcc [2] Microsoft Visual C/C++ version 8.0 in C:\Programme\Microsoft Visual Studio 8

[0] None

Compiler: 2

Please verify your choices:

Compiler: Microsoft Visual C/C++ 8.0 Location: C:\Programme\Microsoft Visual Studio 8

Are these correct?([y]/n): y</c>

Config File

Prior to compilation you have to adjust the makefile. Open the file makefile.vc in the ApCoCoALibToolbox subfolder.

Set the include and lib pathes to your local pathes. The relevant section is indicated by <c>

  1. -------------------------------------------------------------------------------
  2. Adjust the following names and pathes
  3. -------------------------------------------------------------------------------

...

  1. -------------------------------------------------------------------------------

</c>

Compilation

Open a Visual Studio command prompt and change to your local ApCoCoALib folder. Use the nmake command to compile the MatlabToolbox : <c>nmake -f Makefile.vc</c> Will display all available targets. <c>nmake -f Makefile.vc toolbox</c> Will build the MatlabToolbox DLL. <c>nmake -f Makefile.vc mex</c> Will build the MatlabToolbox mex files.

Note: The mex files can be called in Matlab as usual Matlab functions.

Setting Path Variables

Windows Path Settings

In order to use the generated ApCoCoALibToolBox.dll this file has to be made known to the system. Add the following path to the System Variable Path: %ToolboxPath\ApCoCoALibToolBox (%ToolboxPath stands for your local MatlabToolbox repository folder). You can set the path e.g. using the windows gui provided at:

  • right-click My Computer icon, select Properties,
  • click Start > Control Panel > System icon
  • Click the Advanced tab

Matlab Path Settings

To use the mex files and the classes provided by the MatlabToolbox three pathes have to be added to the Matlab Path-Variable. Open File->Set Path and add the following three folders (%ToolboxPath stands for your local MatlabToolbox repository folder):

  • %ToolboxPath
  • %ToolboxPath\MatlabFiles
  • %ToolboxPath\MexFiles

Problems

If you encounter problems check out the forum: ApCoCoA Forum