top bar

Difference between revisions of "Building MM on Windows"

(Using Visual Studio 2010 (or 2012): Better install order for VS2010)
(Using Visual Studio 2010 (or 2012): Update VS2010 install instructions)
Line 102: Line 102:
 
To setup a 32/64-bit build environment with VS2010,  
 
To setup a 32/64-bit build environment with VS2010,  
  
* Install Microsoft Windows SDK 7.1 (http://www.microsoft.com/en-us/download/details.aspx?id=8279).
+
* Install Microsoft Windows SDK 7.1 (http://www.microsoft.com/en-us/download/details.aspx?id=8279). If the installer complains that .NET Framework 4 is required, cancel the SDK install and first install the .NET Framework (from http://www.microsoft.com/en-us/download/details.aspx?id=17851).
 
* Install Visual C++ 2010 Express from http://www.microsoft.com/visualstudio/eng/downloads#d-2010-express.
 
* Install Visual C++ 2010 Express from http://www.microsoft.com/visualstudio/eng/downloads#d-2010-express.
 
* Upgrade to Visual Studio 2010 (Express) SP1 (http://www.microsoft.com/en-us/download/details.aspx?id=23691).
 
* Upgrade to Visual Studio 2010 (Express) SP1 (http://www.microsoft.com/en-us/download/details.aspx?id=23691).
 
* Install this fix: http://www.microsoft.com/en-us/download/details.aspx?id=4422
 
* Install this fix: http://www.microsoft.com/en-us/download/details.aspx?id=4422
 +
 +
{{Note|The order if installation is important. In particular, the SDK 7.1 installer will fail if VS2010 SP1 is installed first. If you are in that situation, the only way out that I have found is to go to Control Panel > "Uninstall a program", uninstall everything with "Microsoft Visual ... 2010" in its name (Redistributable, Runtime, Express, Compilers, Service Pack, Tools for Office Runtime), and start over.}}
 +
 +
{{Note|It is also possible that installation of the Windows SDK can fail (even if you don't have VS2010 installed) if you have a newer version of "Microsoft Visual C++ 2010 Redistributable" (which is installed by various programs, including some versions of Micro-Manager) than the version that the SDK installer tries to install (which is 10.0.30319).}}
  
 
Even before the whole project migrates to VS2010, building individual device adapters using VS2010 is (usually) relatively easy. Open the .vcproj file for a device adapter in VS2010, and follow the instructions to auto-convert (a .vcxproj file is generated). Then, in Project Properties,
 
Even before the whole project migrates to VS2010, building individual device adapters using VS2010 is (usually) relatively easy. Open the .vcproj file for a device adapter in VS2010, and follow the instructions to auto-convert (a .vcxproj file is generated). Then, in Project Properties,
Line 114: Line 118:
 
Make sure to do both after selecting All Platforms and All Configurations.
 
Make sure to do both after selecting All Platforms and All Configurations.
  
I have not tried VS2012 yet, but the necessary steps are likely to be similar to VS2010.
+
I have not tried VS2012 yet, but the necessary steps are likely to be similar to VS2010. Microsoft says that project files can "round-trip" between VS2010 SP1 and VS2012 (http://blogs.msdn.com/b/visualstudio/archive/2012/03/28/round-tripping-with-visual-studio-11.aspx).
  
 
{{Programming_Sidebar}}
 
{{Programming_Sidebar}}

Revision as of 09:36, 4 October 2013

Preparation

First make sure you have enough hard disk space. 5 GB is probably enough.

Directory structure for the source code

Create a directory named projects. The projects directory may reside anywhere you like and will contain the subdirectories micro-manager1.4, 3rdpartypublic, and 3rdparty.

Downloading the source code

To check out the Micro-Manager Source Code, first obtain a Subversion client. From projects/, run:

svn co https://valelab.ucsf.edu/svn/micromanager2/trunk/ micro-manager1.4
svn co https://valelab.ucsf.edu/svn/3rdpartypublic/

Required tools and applications

To build the entire application from the source code, you will need to install the following tools:

To build device adapters:

  1. Microsoft Visual Studio 2008 (Express is fine, and doesn't cost anything.)

(Work is underway to migrate Micro-Manager to Visual Studio 2010.)

Additionally, to build the entire Micro-Manager package:

  1. JDK Standard Edition 6 or later
  2. Apache Ant 1.8.1 or later (tested with 1.9.2)

Tell the build tools where to find Java and Ant by opening the System control panel / Advanced system settings / Environment Variables / System variables and addding the following new entries:

ANT_HOME=C:\apache-ant-1.9.2 (or path to Ant)
JAVA_HOME=C:\Program Files\Java\jdk1.6.0_20 (or path to Java)
PATH=%PATH%;%ANT_HOME%\bin

Device libraries and SDKs

Some device adapter require the installation of manufacturer's SDKs in order to build. All SDKs should be installed in the <root>/projects/3rdparty directory. The actual names of SDK directories should match the paths in the corresponding header files in the Micro-manager source code for device adapters.

If you don't want to build one or more device adapters (because you don't have the SDK), you should remove corresponding projects from the master solution: MMCoreJ_wrap.sln.

To add a device adapter to the automated build, use Visual Studio 2008 to add the device adapter project (a .vcproj file) to the MMCoreJ_wrap.sln or MMCoreJ_wrap_x64.sln. Under the device adapter's project properties, make sure the device adapter has this command under Build Events > Post-build Event:

copy "$(TargetPath)" ..\..\bin_$(PlatformName)

and a Linker > General > Output File of

$(OutDir)/mmgr_dal_YourDeviceName.dll

Setting up library paths

The project files in the repository should have the correct path settings.

To deal with the flood of text in the Output window, in the Solution Explorer right-click and build one project at a time.

If in Visual Studio you get an error:

       Target(FOO) does not match the Linker's OutputFile property value (BAR) ...

You could right-click on the project > properties > Configuration Properties > General > Target Name and add the leading "mmgr_dal_" to the beginning of $(ProjectName) to satisfy it.

Setting up 64-bit support on Visual C++ Express

Visual Studio Express does not include 64-bit compiler support out of the box. To compile x64 libraries in addition to Win32, you need to install the Windows SDK: http://msdn.microsoft.com/en-us/windows/bb980924

After installation you should find the x64 specific libraries at a path similar to:

       C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\x64

To build your x64 project you would need to make sure this is in the 'Additional Library Directories' setting in your project, specifically in Project > Properties > Configuration Properties > Linker > Additional Library Directories. If you do not do this you will get linker errors similar to:

       LINK: fatal error LNK1181: cannot open input file FOO.lib

Building the C++ layer: MMCore and device adapters

You can build C++ part of the project by opening MMCoreJ_wrap.sln in Visual Studio 2008 and running the full build. This will build the MMCore, Java wrappers and all device adapters. You can remove any device adapter project from the solution if you don't have the corresponding SDK or if you don't need to build it.

The C++ components can also be built using the batch file buildscripts/buildCpp.bat.

Building the Java layer: Micro-Manager Studio

The Java layer of the Micro-Manager can be build using the Apache Ant utility with the build.xml project file, located in the directories for each Java component (mmstudio, acqEngine, plugins, autofocus).

Building these components currently requires that MMCoreJ.jar be manually placed in <root>/projects/micro-manager-1.4/build/Java.

In the mmstudio directory from the command line, run:

 ant jar

Which should produce MMJ_.jar in <root>/projects/micro-manager-1.4/build/Java.

The same command should work in acqEngine, plugins, the individual plugin subdirectories, and autofocus (acqEngine depends on mmstudio, and plugins depend on mmstudio and acqEngine, so they must be built in that order).

Building the full source in one step

You can build the C++, Java, and Clojure components in one step by typing, in <root>/projects/micro-manager-1.4, the following command:

 ant stage -Dmm.architecture=Win32 -Dmm.configuration=Release -Dmm.build.failonerror=false

The value for mm.architecture can also be x64. The mm.build.failonerror=false setting causes device adapters and plugins to be skipped if they do not compile. Built files are placed in the stage/Release/Win32 directory.

Using Visual Studio 2010 (or 2012)

Work is underway (by Mark) to migrate Micro-Manager to Visual Studio 2010 (in which the project file format has changed significantly from VS2008).

To setup a 32/64-bit build environment with VS2010,

Note
The order if installation is important. In particular, the SDK 7.1 installer will fail if VS2010 SP1 is installed first. If you are in that situation, the only way out that I have found is to go to Control Panel > "Uninstall a program", uninstall everything with "Microsoft Visual ... 2010" in its name (Redistributable, Runtime, Express, Compilers, Service Pack, Tools for Office Runtime), and start over.
Note
It is also possible that installation of the Windows SDK can fail (even if you don't have VS2010 installed) if you have a newer version of "Microsoft Visual C++ 2010 Redistributable" (which is installed by various programs, including some versions of Micro-Manager) than the version that the SDK installer tries to install (which is 10.0.30319).

Even before the whole project migrates to VS2010, building individual device adapters using VS2010 is (usually) relatively easy. Open the .vcproj file for a device adapter in VS2010, and follow the instructions to auto-convert (a .vcxproj file is generated). Then, in Project Properties,

  • Reset Linker Output File to "inherit from parent or project defaults", which gives you $(OutDir)$(TargetName)$(TargetExt), and set Target Name to mmgr_dal_$(ProjectName)
  • Set Platform Toolset to WindowsSDK7.1

Make sure to do both after selecting All Platforms and All Configurations.

I have not tried VS2012 yet, but the necessary steps are likely to be similar to VS2010. Microsoft says that project files can "round-trip" between VS2010 SP1 and VS2012 (http://blogs.msdn.com/b/visualstudio/archive/2012/03/28/round-tripping-with-visual-studio-11.aspx).

© Micro-Manager : Vale Lab, UCSF 2006-2011 | All Rights Reserved | Contact