Building Device Adapters on Windows 10 with Visual Studio 2015 Community

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Building Device Adapters on Windows 10 with Visual Studio 2015 Community

Daniel Kovari
Micro-manager Community,

I've had some success compiling device adapters under Windows 10 using Visual Studio 2015 Community Edition and thought if might be useful to share my experiences.

Under Windows 10 you cannot install the Windows7.1 SDK which means that you cannot easily compile the devices following the instructions posted on the micro-manager webpage.

To get around this problem you need to do a few things.

1) After downloading the micro-manager source SVN, you need to get an updated copy of the boost libraries.  (The version included in on the 3rdpartypublic SVN is pretty old.)  On my system I downloaded the pre-compiled boost_1_61_0 binary for MSVC-14, which you can find here: https://sourceforge.net/projects/boost/files/boost-binaries/1.61.0/

2) Install the boost binaries. When prompted, I chose to put them in ...projects\3rdpartypublic\boost-versions\

3) You need to edit the MMcomon.props file to point to the new library
Navigate to ...\projects\micro-manager1.4\buildscripts\VisualStudio
open MMcomon.props with a text editor and change lines 8 and 9 to point to the location of the new copy of boost (and the appropriate binary lib files).
On my system I have:

<MM_BOOST_INCLUDEDIR>$(MM_3RDPARTYPUBLIC)\boost-versions\boost_1_61_0</MM_BOOST_INCLUDEDIR>
<MM_BOOST_LIBDIR>$(MM_3RDPARTYPUBLIC)\boost-versions\boost_1_61_0\lib64-msvc-14.0</MM_BOOST_LIBDIR>

4) Open ...\projects\micro-manager1.4\micromanager.sln with Visual Studio 2015

5) You need to change the Platform toolset for each project you intend to build
To change the toolset, right click on the project in the Solution Explore window (e.g. MMcore) and select Properties.
Using the drop-down menus. Select "All Configurations" and "All Platforms"
Navigate to Configuration Properties->General
Set the "Project Toolset" to "Visual Studio 2012 (v140)"

Be sure to change the toolset for all the dependent projects too:
MMcore
MMCoreTest
MMDevice-SharedRuntime
MMDevice-StaticRuntime
LibraryTest
DeviceTest

6) Build your project

I haven't done a lot of testing yet, but so far the test programs and DemoCamera build without issue.  The generated DemoCamera dll also appears to work with the current nightly build of Micro-Manager1.4 (MMSetup_64bit_1.4.23_20160523), even though that build was probably compiled using the old (Win7sdk) toolset and boost 1.5.

I know that the development team is busy working on Micro-Manager2.0 but while that is in development I think it would be nice if we could update Micro-manager 1.4 to include a more recent version of boost by default.  Assuming people will always be able to write new device adapters using VS 2010 isn't really an option as it appears that Microsoft is actively phasing it out. (Even under windows 7 it's really hard to get a copy of VS 2010 express with Win7.1 sdk to install properly.)


I hope people find this helpful.

Regards,
Dan





------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: Building Device Adapters on Windows 10 with Visual Studio 2015 Community

Mark Tsuchida-3
Hi Dan,

Thank you for sharing this.

On Thu, May 26, 2016 at 12:17 PM, Daniel Kovari <[hidden email]> wrote:

> I've had some success compiling device adapters under Windows 10 using
> Visual Studio 2015 Community Edition and thought if might be useful to share
> my experiences.
>
> Under Windows 10 you cannot install the Windows7.1 SDK which means that you
> cannot easily compile the devices following the instructions posted on the
> micro-manager webpage.
>
> To get around this problem you need to do a few things.
>
> 1) After downloading the micro-manager source SVN, you need to get an
> updated copy of the boost libraries.

This is probably only necessary if the device adapter you're building
uses non-header-only parts of Boost. This is relatively uncommon but
definitely the case with a few.

[...]
> Be sure to change the toolset for all the dependent projects too:
> MMcore
> MMCoreTest
> MMDevice-SharedRuntime
> MMDevice-StaticRuntime
> LibraryTest
> DeviceTest

The only dependency of a device adapter is MMDevice-SharedRuntime
(except for some device adapters that use MMDevice-StaticRuntime
instead, for compatibility reasons).

[...]
> I haven't done a lot of testing yet, but so far the test programs and
> DemoCamera build without issue.  The generated DemoCamera dll also appears
> to work with the current nightly build of Micro-Manager1.4
> (MMSetup_64bit_1.4.23_20160523), even though that build was probably
> compiled using the old (Win7sdk) toolset and boost 1.5.

The device interface is intensionally designed so that the compiler
version need not be equal. The official build statically links any
non-header-only parts of Boost, so there should be no clash there
either.

> I know that the development team is busy working on Micro-Manager2.0 but
> while that is in development I think it would be nice if we could update
> Micro-manager 1.4 to include a more recent version of boost by default.
> Assuming people will always be able to write new device adapters using VS
> 2010 isn't really an option as it appears that Microsoft is actively phasing
> it out. (Even under windows 7 it's really hard to get a copy of VS 2010
> express with Win7.1 sdk to install properly.)

We'll definitely update to VS2015 as soon we've released 2.0, and
probably update Boost at the same time (to make it one job instead of
two). Is there a particular reason why a newer Boost is needed for
VS2015? (I can see that you would need a Boost built with VS2015 if
using non-header-only parts, but that's different from the Boost
version.)

We'll probably also stop providing a Boost build of our own, instead
providing complete instructions or a script for building Boost on
Windows for use with Micro-Manager. (For terse notes on how the
current version was built, see
3rdpartypublic/boost-versions/build-1_55_0-VS2010.bat.)

Best,
Mark

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: Building Device Adapters on Windows 10 with Visual Studio 2015 Community

Stuurman, Nico
In reply to this post by Daniel Kovari

Hi Daniel and others,

I've had some success compiling device adapters under Windows 10 using Visual Studio 2015 Community Edition and thought if might be useful to share my experiences.

Under Windows 10 you cannot install the Windows7.1 SDK which means that you cannot easily compile the devices following the instructions posted on the micro-manager webpage.

Although I agree that it would be nice to be able to use VS2015 with MM (especially since registration is no longer needed, and b.t.w. thanks for sharing your experiences and instructions!), I had little trouble getting VS2010 Express to compile MM code under Windows 10.  Just for the record, here are my notes while using a very fresh Windows 10 64 bit machine (very similar to the notes on the MM website):

  1. Download the VS2010 iso fromhttp://download.microsoft.com/download/1/E/5/1E5F1C0A-0D5B-426A-A603-1798B951DDAE/VS2010Express1.iso.  Double  click the iso file and run "Setup" within the folder.  Install Visual C++ 2010 Express.  In the installer deselect SQL server and Silverlight
  2. Install Microsoft Windows SDK 7.1 and .NET Framework 4 (http://www.microsoft.com/en-us/download/details.aspx?id=8279).  Run the installer, ignore warning about .net and accept all defaults (although most will be invisible on high dpi screens).
  3. Upgrade to Visual Studio 2010 SP1 (http://www.microsoft.com/en-us/download/details.aspx?id=23691).
  4. Download and install the compiler fixer: https://www.microsoft.com/en-us/download/details.aspx?id=4422 (I had to restart the PC before this ran successfully)


Best,

Nico

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: Building Device Adapters on Windows 10 with Visual Studio 2015 Community

JonD
Administrator
In reply to this post by Daniel Kovari
Thank you Dan for your helpful hints!  I spent some time today getting "Visual Studio 2015 Express for Windows Desktop" to build device adapters on my new Windows 10 machine.

I was able to compile the device adapters I'm interested in using only your steps 4-6.  Makes sense since those adapters don't use Boost.

Here are some further findings that may be useful to others migrating to Visual Studio 2015.

First, my device adapters had boilerplate code which had a Windows-specific "#define snprintf _snprintf".  This define was commonplace previously to cover up a quirk in older versions of VS, but as of VS2015 the quirk is fixed and the define results in an error.  Fortunately because my device adapters don't use snprintf so the define could be safely eliminated (the original presence of this define was simply an "inheritance problem" of copying existing code and not changing something I didn't understand).

Second, I encountered some warnings in the common device code, specifically C4456 about shadowed variables.  These warnings will hopefully go away in the long run (I will submit a patch to the main developers) but it's safe to ignore the warnings.

Third,  DLLs I generated with Win10/VS2015 wouldn't work on the other computer's Win7 Micro-Manager installation and the DLLs from Win7/VS2010 wouldn't work on the Win10 computer's installation.  But the DLLs would work fine on the same computer.  I just chalk this up to compatibility issues and/or incorrect settings.  It's a minor point for me because I'm generally only build device adapters to test code changes before submitting to the main repository.  So it seems I just have to test on the same OS that I build with.

Jon

------------------------------------------
Jon Daniels
Applied Scientific Instrumentation
29391 West Enid Rd, Eugene, OR 97402
Phone: (541) 461-8181 x118
------------------------------------------

Reply | Threaded
Open this post in threaded view
|

Re: Building Device Adapters on Windows 10 with Visual Studio 2015 Community

Mark Tsuchida-3
Hi Jon,

On Fri, Jun 24, 2016 at 5:07 PM, JonD <[hidden email]> wrote:
Third,  DLLs I generated with Win10/VS2015 wouldn't work on the other
computer's Win7 Micro-Manager installation and the DLLs from Win7/VS2010
wouldn't work on the Win10 computer's installation.  But the DLLs would work
fine on the same computer.  I just chalk this up to compatibility issues
and/or incorrect settings.  It's a minor point for me because I'm generally
only build device adapters to test code changes before submitting to the
main repository.  So it seems I just have to test on the same OS that I
build with.

They are expected to be compatible with each other, provided that they are Release builds (not Debug builds -- all Debug builds need the same version of Visual Studio to be installed) and that their device interface versions match. You might also need to install the VC++ runtime (https://www.microsoft.com/en-us/download/details.aspx?id=48145) to run Release builds on computers without VS2015.

Best,
Mark

------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general