# The Windows CE shared knowledge base

by Werner Willemsens

## Building Windows CE 6 or 7 Smart Device Application with Visual Studio 2012 (Part 1)

With every new release of Windows CE (Windows Embedded CE, Windows Embedded Compact Edition) version 4.x, 5.0, 6.0, 7.0, 2013 (aka 8.0), people ask what version of Visual Studio they should use for Smart Device development. And how much it is different from the Visual Studio you use for developing the OS image, or how much it is different from the latest Visual Studio version? For those people that don’t understand what I am talking, a summary:

• OS image : the image (NK.BIN) that will include kernel, device drivers, servers (File, Ftp, Smb, Http, …), CRT and so. The thing required to run “Windows CE” (subset of desktop Windows API) on your hardware. With Windows CE you can choose what components you want to add in your image. To build the OS you need “Platform Builder”, nowadays a plug-in in Visual Studio.
• Smart Device : many people are not interested in building their own drivers, neither a full OS. They just buy the hardware and want to get started with a prebuilt OS. For those developers the OS image builder supplies also a SDK that you need to compile & link your Smart Device application against. The SDK contains all headers and library files of all components you added in your OS image, so you cannot accidentally compile & link a program to an API that is not present in your (customized) OS.

For these 2 situations, you need 2 different tools.

Historical overview

 Version Platform (OS) Builder -> NK.BIN Smart Device application Windows CE 4.x Windows CE Platform Builder 4.x Embedded Visual Studio 4 Windows CE 5.0 Windows CE Platform Builder 5.0 Visual Studio 2005 + SDK Windows CE 6.0 Plugin for Visual Studio 2005 Visual Studio 2008 + SDK Windows CE 7.0 Plugin for Visual Studio 2005 Visual Studio 2008 + SDK Windows CE 8.0 Plugin for Visual Studio 2012 Visual Studio 2012 + SDK

As you notice, Platform Builder and Smart Device application development required in the past a different version of Visual Studio. This bothered always people because they had to invest in and maintain different (older) versions of Visual Studio projects. Only with Windows CE 8.0 Microsoft finally succeeded in at least using the same (and latest!) version of Visual Studio. For older versions of Windows CE you still need to use the older versions of Visual Studio.

Not entirely true!

With Visual Studio 2010 and now Visual Studio 2012 you have a lot of control of the internal build system. I will show you how you can also use Visual Studio 2012 to build Windows CE 6.0 and 7.0 Smart Device applications, which gives us the following table:

 Version Platform (OS) Builder ->NK.BIN Smart Device application Windows CE 6.0 Plugin for Visual Studio 2005 Visual Studio 2008 + SDK or Visual Studio 2012 + SDK Windows CE 7.0 Plugin for Visual Studio 2005 Visual Studio 2008 + SDK or Visual Studio 2012 + SDK Windows CE 8.0 Plugin for Visual Studio 2012 Visual Studio 2012 + SDK

Today we have already implemented this setup in my company’s build system, relieving all developers (except me as the Windows CE OS builder J/L) to maintain many project versions in different Visual Studio versions. It was only recent that we could upgrade to Visual Studio 2012, the last 5 years we were forced to stick with Visual Studio 2008 for all our C++ projects because we have some 30+ C++ libraries, few COM DLLs and executables that compile both for desktop Windows and Windows CE (both share the same subset of the Windows API). For convenience both configurations were present in 1 Visual Studio 2008 C++ vcproj file.

Now, let me explain how to achieve this. Many thanks also go to my colleague Marcus (The Build Guru) who did most of the initial research.

First of all we learned by studying how a Windows CE 8.0 SDK is installed. Basically the SDK (“MyDevice8.msi”) installs itself in folder C:\Program Files\Windows CE Tools\SDKs\MyDevice8. Roughly said, it contains subfolders for the OS APIs in Inc, Atl and Mfc headers in atlmfc and CRT in Crt. The Bin folder contains the tools (compiler, linker, midl, rc, …)

How does this look like in a Windows CE 6/7 SDK? There you also have a C:\Program Files\Windows CE Tools\wce600\MyDevice6 (x86) folder. But here you will find only the OS headers and libraries. The Atl, Mfc and Crt headers and libraries are located in C:\Program Files\Microsoft Visual Studio 9.0\VC\ce. In Visual Studio 2012 much of the build system internals is regulated through Property Sheets in C:\Program Files\MSBuild. After installing the Windows CE 8.0 SDK, a subfolder is added in C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\V110\Platforms\MyDevice8.

Notice “MyDevice6 (x86)”; the “(x86)” is typically added in a Windows CE 6/7 SDK name, in Windows CE 8 it is omitted. When I created the Visual Studio 2012 SDK for Windows CE 6/7 projects hereafter, I also omitted the “(x86)”, although it doesn’t really matter (it is just part of a SDK name)

What follows are the detailed steps you have to follow to transform your Windows CE 6 SDK (hereafter named “MyDevice6 (x86)”) for Visual Studio 2008 to a new SDK (hereafter named “MyDevice6”) for Visual Studio 2012. Although it might look like there are many steps to follow, we are just going to copy a few folders to a new location and edit a few files to create this new Visual Studio 2012 compatible SDK for Windows CE 6 (the same applies to a Windows CE 7 SDK):

Step 1: Property Sheets

• Create a new C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\V110\Platforms\MyDevice6 folder by copying (and renaming) it from C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\V110\Platforms\MyDevice8.
• Rename the files to (“MyDevice8” -> “MyDevice6”)
• C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\V110\Platforms\MyDevice6\ Microsoft.Cpp.MyDevice6.Common.props
• C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\V110\Platforms\MyDevice6\ Microsoft.Cpp.MyDevice6.default.props
• C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\V110\Platforms\MyDevice6\ Microsoft.Cpp.MyDevice6.props
• C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\V110\Platforms\MyDevice6\ Microsoft.Cpp.MyDevice6.targets
• C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\V110\Platforms\MyDevice6\PlatformToolsets\wce600\ Microsoft.Cpp.MyDevice6.wce600.props
• C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\V110\Platforms\MyDevice6\PlatformToolsets\wce600\ Microsoft.Cpp.MyDevice6.wce600.targets
• Open a Text Editor with Admin Rights (write access) to these folders (Run as Administrator)
• Go through all 6 files and rename everything in those files that refers to MyDevice8 to MyDevice6, CE800 to wce600

Step 2: Registry

• Open with a Text Editor C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\V110\Platforms\MyDevice6\PlatformToolsets\wce600\Microsoft.Cpp.MyDevice6.wce600.props
• Look up <SdkRootPath>\$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Tools\SDKs\MyDevice6)sdk\</SdkRootPath>

This is a reference to a registry key that needs to exist on the system you wish to use for compiling the Windows CE 6/7 Smart Device projects. This key is used by Visual Studio 2012 to recognize your SDK (Windows CE platform configuration). Create this key manually with Regedit.exe. You will also find the “MyDevice8” SDK key there, use it as an example.

• You need to create the key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Tools\SDKs\MyDevice6 with (default) REG_SZ data “C:\Program Files\Windows CE Tools\SDKs\MyDevice6\”

Step 3: Folder structure

• Copy the Visual Studio 2008 “CE” folders from C:\Program Files\Microsoft Visual Studio 9.0\VC\ce  to  C:\Program Files\Windows CE Tools\SDKs\MyDevice6\Sdk
• Copy the “Windows CE Tools” folders from C:\Program Files\Windows CE Tools\wce600\MyDevice6 (x86)  to  C:\Program Files\Windows CE Tools\SDKs\MyDevice6

Your folder structure should look like:

 “Old” Visual Studio 2008 structure “New” Visual Studio 2012 structure C:\Program Files\Windows CE Tools\wce600\MyDevice6 (x86) C:\Program Files\Windows CE Tools\SDKs\MyDevice6\wce600 C:\Program Files\Windows CE Tools\wce600\MyDevice6 (x86)\Include C:\Program Files\Windows CE Tools\SDKs\MyDevice6\wce600\Include C:\Program Files\Windows CE Tools\wce600\MyDevice6 (x86)\Lib C:\Program Files\Windows CE Tools\SDKs\MyDevice6\wce600\Lib C:\Program Files\Microsoft Visual Studio 9.0\VC\ce C:\Program Files\Windows CE Tools\SDKs\MyDevice6\Sdk C:\Program Files\Microsoft Visual Studio 9.0\VC\ce\atlmfc C:\Program Files\Windows CE Tools\SDKs\MyDevice6\Sdk\atlmfc C:\Program Files\Microsoft Visual Studio 9.0\VC\ce\bin C:\Program Files\Windows CE Tools\SDKs\MyDevice6\Sdk\bin C:\Program Files\Microsoft Visual Studio 9.0\VC\ce\crt C:\Program Files\Windows CE Tools\SDKs\MyDevice6\Sdk\crt C:\Program Files\Microsoft Visual Studio 9.0\VC\ce\dll C:\Program Files\Windows CE Tools\SDKs\MyDevice6\Sdk\dll C:\Program Files\Microsoft Visual Studio 9.0\VC\ce\include C:\Program Files\Windows CE Tools\SDKs\MyDevice6\Sdk\include C:\Program Files\Microsoft Visual Studio 9.0\VC\ce\lib C:\Program Files\Windows CE Tools\SDKs\MyDevice6\Sdk\lib

Step 4: Binary tools folders

• Open with a Text Editor C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\V110\Platforms\MyDevice6\PlatformToolsets\wce600\Microsoft.Cpp.MyDevice6.wce600.props
• Adapt the <ExecutablePath> </ExecutablePath> tag as follows (mind the order)
• From <ExecutablePath Condition="'\$(ExecutablePath)' == ''">\$(SdkRootPath)bin\i386;\$(SdkRootPath)bin\i386\x86;\$(VSInstallDir)Common7\Tools\bin;\$(VSInstallDir)Common7\tools;\$(VSInstallDir)Common7\ide;\$(ProgramFiles)\HTML Help Workshop;\$(MSBuildToolsPath32);\$(FxCopDir);\$(PATH);\$(VCINSTALLDIR)\bin;</ExecutablePath>
• To <ExecutablePath Condition="'\$(ExecutablePath)' == ''">\$(SdkRootPath)bin\x86_cex86;\$(VSInstallDir)Common7\Tools\bin;\$(VSInstallDir)Common7\tools;\$(VSInstallDir)Common7\ide;\$(ProgramFiles)\HTML Help Workshop;\$(MSBuildToolsPath32);\$(FxCopDir);\$(PATH);\$(VCINSTALLDIR)\bin;</ExecutablePath>

Step 5: C++ Include headers folders

• Open with a Text Editor C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\V110\Platforms\MyDevice6\PlatformToolsets\wce600\Microsoft.Cpp.MyDevice6.wce600.props
• Adapt the <IncludePath> </IncludePath> tag as follows (mind the order)
• From <IncludePath Condition="'\$(IncludePath)' == ''">\$(SdkRootPath)crt\Include;\$(SdkRootPath)crt\Include\sys;\$(SdkRootPath)crt\Include\stl;\$(SdkRootPath)atlmfc\Include;\$(SdkRootPath)Inc;</IncludePath>
• To <IncludePath Condition="'\$(IncludePath)' == ''">\$(SdkRootPath)Include;\$(SdkRootPath)wce600\Include\x86;\$(SdkRootPath)atlmfc\Include;</IncludePath>

Step 6: C++ Libraries folders

• Open with a Text Editor C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\V110\Platforms\MyDevice6\PlatformToolsets\wce600\Microsoft.Cpp.MyDevice6.wce600.props
• Adapt the <LibraryPath> </LibraryPath> tag as follows (mind the order)
• From <LibraryPath Condition="'\$(LibraryPath)' == ''">\$(SdkRootPath)crt\Lib\x86;\$(SdkRootPath)atlmfc\lib\x86;\$(SdkRootPath)Lib\x86\debug;\$(SdkRootPath)Lib\x86\retail;</LibraryPath>
• To <LibraryPath Condition="'\$(LibraryPath)' == ''">\$(SdkRootPath)wce600\Lib\x86; \$(SdkRootPath)atlmfc\lib\x86; \$(SdkRootPath)Lib\x86; </LibraryPath>

• Open with a Text Editor C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\V110\Platforms\MyDevice6\PlatformToolsets\wce600\Microsoft.Cpp.MyDevice6.wce600.props
• Rename all “*110*” files to “*90*” files in the <CEAdditionalFiles>  </CEAdditionalFiles> tags

• Open with a Text Editor C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\V110\Platforms\MyDevice6\PlatformToolsets\wce600\Microsoft.Cpp.MyDevice6.wce600.props

Step 9: Compiler Preprocessor Definitions

• Open with a Text Editor C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\V110\Platforms\MyDevice6\PlatformToolsets\wce600\Microsoft.Cpp.MyDevice6.wce600.props
• Adapt < PreprocessorDefinitions></ PreprocessorDefinitions> tag in <ItemDefinitionGroup><ClCompile></ ClCompile ></ItemDefinitionGroup> section
• From <PreprocessorDefinitions>UNDER_CE;WINCE;_WIN32_WCE=0x800;%(PreprocessorDefinitions)</PreprocessorDefinitions>
• To <PreprocessorDefinitions>UNDER_CE;WINCE;_WIN32_WCE=0x600;%(PreprocessorDefinitions)</PreprocessorDefinitions>

Step 10: Avoid linker error ” LINK : fatal error LNK1104: cannot open file 'OLDNAMES.lib' “

This will tell the linker to ignore the default library named “oldnames.lib” which has no use in Windows CE

Voila, if you have implemented all the previous steps, your Windows CE 6 SDK for Visual Studio 2008 is converted to a Windows CE 6 SDK for Visual Studio 2012. Once again, this also applies to a Windows CE7 SDK.

Geek note:

You might ask yourself; “how the hell did those geeks find what directories were searched (and in what order) by Visual Studio 2008?”

We needed this information to understand how to manipulate and set the C++ include and library directories in the Visual Studio 2012 Property Sheet files. The order is important as some header files exist more than once (in a slightly different variation).

We used Sysinternals Process Monitor (Procmon.exe) for that. We installed a filter for Process Name cl.exe, created a Smart Device project in Visual Studio 2008 with 1 C++ source file “test.cpp” with 1 statement

#include "search_it.h"

As this header file does not exist, cl.exe had to search all its include directories. In Process Monitor, you find these traces (among many others):

When you do the same for a non existing search_it.lib and a filter on Process Name link.exe, you will find the library directories

Note the 3 root directories that are being searched:

• The current project directory
• C:\Program Files\Microsoft Visual Studio 9.0\VC\ce
• C:\Program Files\Windows CE Tools\wce600\MyDevice6 (x86)

This order was preserved in the compiler (step 5) and linker (step 6) steps.

Print | posted on Friday, September 13, 2013 10:00 PM | Filed Under [ Windows CE Windows Embedded Compact Microsoft Visual Studio 2012 Smart Device application ]

## #re: Building Windows CE 6 or 7 Smart Device Application with Visual Studio 2012 (Part 1)

Dear Werner,
thank you very much for you rich, detailed and useful post!

Do you have any experience with ARM?
I'am guessing if the modification you described are straight forward also for this architecture.
In particular I'd like to use VS2012 to build apps for EC7 on BeagleBoard-xM.

Michele.
10/11/2013 3:42 PM | Michele

## #re: Building Windows CE 6 or 7 Smart Device Application with Visual Studio 2012 (Part 1)

I'm sorry but, with a little poor hope - is there any possibility that i can use vs2012 to build a wince 5.0 app?

Thank you
11/7/2013 10:22 AM | Nark

## #re: Building Windows CE 6 or 7 Smart Device Application with Visual Studio 2012 (Part 1)

11/23/2013 3:40 PM | nitishkumar

## #re: Building Windows CE 6 or 7 Smart Device Application with Visual Studio 2012 (Part 1)

I don't know for sure (I haven't tried) if it is possible to build for Windows CE 5, but as VS2012 is merely an IDE and the underlying Windows CE 5/6/7 build is actually performed by their respectively toolset (compiler, linker, ...), I expect it is also possible to build for any other Windows CE x.x SDK (even non Windows related compilations could be done)
The steps I explain in the blog, tell you how to configure VS2012 to use the respectively Windows CE 5/6/7 compiler and linker. So as long as you have installed the compiler and linker tools for Windows CE 5 (being VS2008/VS2005 and/or PlatfromBuilder 5), I think it will work.
12/16/2013 8:13 PM | Werner Willemsens

## #re: Building Windows CE 6 or 7 Smart Device Application with Visual Studio 2012 (Part 1)

Amazing post. Thanks!
2/28/2014 12:39 AM | JohnDr

## #re: Building Windows CE 6 or 7 Smart Device Application with Visual Studio 2012 (Part 1)

Hi Werner,

this is a very amazing post. Many thanks!
My opintion was that we all stuck on VS2008 forever with Win CE 5/6.
It's a pity that Microsoft doesnt Support officially any option for older CE development. The lifetime of smart devices with Windows CE 5/6 is much longer than they should have been thinking about... I guess...
3/5/2014 3:19 PM | Sven

## #re: Building Windows CE 6 or 7 Smart Device Application with Visual Studio 2012 (Part 1)

can i do this for C#? sorry if the question is very simple
3/9/2014 4:34 PM | eko

## #re: Building Windows CE 6 or 7 Smart Device Application with Visual Studio 2012 (Part 1)

Yes, you can. As VS2012 is merely an IDE and the underlying Windows CE 6/7 build is actually performed by their respectively toolset (compiler, linker, ...), this should be possible for C# as well. But mind you, only compiling, not debugging. You need VS2008 for a CE6/7 application.
3/9/2014 8:25 PM | Werner

## #re: Building Windows CE 6 or 7 Smart Device Application with Visual Studio 2012 (Part 1)

Like others have mentioned this post was enlightening. I am going to try to do this with VS2013. I was wondering though, why we would only be able to compile and not debug. If we debug on the actual device isn't the application execute on the device?
3/26/2014 7:38 AM | NamPhan

## #re: Building Windows CE 6 or 7 Smart Device Application with Visual Studio 2012 (Part 1)

Visual Studio needs a debug host program running on the Windows CE side
Visual Studio 2008 needs ConmanClient2.exe on the Windows CE 6/7 side
Visual Studio 2012 needs ConmanClient3.exe on the Windows CE 8 side
You cannot mix both ConmanClient2 and ConmanClient3. I tried to connect from Visual Studio 2012 to ConmanClient2.exe (even by messing with the registry and C:\Program Files\Microsoft Visual Studio 11.0\WindowsEmbeddedCompact folder) but It didn't work. If it would be, than we could also debug from VS2012 to a CE6/7 target, but unfortunately no luck.
3/26/2014 4:09 PM | Werner

## #re: Building Windows CE 6 or 7 Smart Device Application with Visual Studio 2012 (Part 1)

is it working in vs2010 ?
7/1/2014 9:54 AM | ERick

## #re: Building Windows CE 6 or 7 Smart Device Application with Visual Studio 2012 (Part 1)

I've installed the Compact Framework 2013 Update 5 and the folders and files for MyDevice8 are not present on my system. What have I missed?

What are the steps to get to the point before step 1?

10/8/2014 1:15 AM | RCDMK

## #re: Building Windows CE 6 or 7 Smart Device Application with Visual Studio 2012 (Part 1)

Thank you much for detailed and useful post!
Do you have somthing like this for visual studio 2013
Thanks Shay
3/10/2015 6:34 PM | Shay

## #re: Building Windows CE 6 or 7 Smart Device Application with Visual Studio 2012 (Part 1)

Will this work for VS2010? do i have to do anything different for vb.net?
9/15/2015 7:02 PM | Marvin Cavender

## #re: Building Windows CE 6 or 7 Smart Device Application with Visual Studio 2012 (Part 1)

I have no experience with VS2010. I do know that you can do the same with VS2015.
9/15/2015 11:08 PM | werner

## #re: Building Windows CE 6 or 7 Smart Device Application with Visual Studio 2012 (Part 1)

Werner,
Thank you for your quick response. I developed a program using VB.net (using 2008 Visual Studio) it worked fine until we changed SQL servers from Microsoft SQL 2000 to Microsoft SQL 2012. Visual Studio 2008 does not support SQL greater than 2005. I used a SDK for Windows Mobile 6. Do you know what the difference between Windows CE 6 and Windows Mobile SDK?
Regards,
Marvin
9/16/2015 12:59 PM | Marvin Cavender

## #re: Building Windows CE 6 or 7 Smart Device Application with Visual Studio 2012 (Part 1)

is Windows CE 8.0 the same as Windows Embedded 8 Handheld SDK i have not found a download for Windows 7 is it only available for Windows 8
Thanks
1/13/2016 12:54 PM | RicK

## #re: Building Windows CE 6 or 7 Smart Device Application with Visual Studio 2012 (Part 1)

Cool tip, thanks.

But I think it's worth while to make a bold statement "compile only, no debugging support" in the article. As developers, I think we'll need the debugging capability sooner or later, so we can't really ditch VS2008 entirely/
2/12/2016 6:57 AM | Kurt

## #re: Building Windows CE 6 or 7 Smart Device Application with Visual Studio 2005

how to install win CE 6.0 on visual studio 2005 pleaaaaaaaase
2/19/2016 8:46 AM | lema

## #re: Building Windows CE 6 or 7 Smart Device Application with Visual Studio 2012 (Part 1)

Hi, Guys

I'm working for a company that is developing applications for bar-code scanners. I had never worked with this environment before, so I've been struggled with it the last 3 days without any idea where I have to start.

Thank you very much for sharing your knowledge. You're great!

4/27/2016 11:39 PM | Enrique

## #re: Building Windows CE 6 or 7 Smart Device Application with Visual Studio 2012 (Part 1)

Hi Enrique,
You need to build the SDKs yourself for your own hardware. Or ask your hardware vendor for a wince BSP + SDK.
Then refer to your own SDK (simple rename in vcxproj/csproj files)
Success Werner
5/2/2016 10:02 PM | Werner