{"id":203,"date":"2014-11-12T07:35:00","date_gmt":"2014-11-12T07:35:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vcblog\/2014\/11\/12\/cross-platform-mobile-development-with-visual-c\/"},"modified":"2021-07-29T14:21:36","modified_gmt":"2021-07-29T14:21:36","slug":"cross-platform-mobile-development-with-visual-c","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/cross-platform-mobile-development-with-visual-c\/","title":{"rendered":"Cross-Platform Mobile Development with Visual C++"},"content":{"rendered":"<h2><span style=\"color: #000000\">Overview<\/span><\/h2>\n<p class=\"paragraph\" style=\"text-align: left\">Modern application customers are demanding applications be available for&nbsp;multiple device platforms (such as&nbsp;<span style=\"text-decoration: underline\">Windows<\/span>, &nbsp;<span style=\"text-decoration: underline\">Android<\/span>&nbsp;and&nbsp;<span style=\"text-decoration: underline\">iOS<\/span>).&nbsp;Today there exist multiple approaches in writing applications which target these&nbsp;device platforms. One approach is to simply create multiple versions of the application in different source trees-in other words a Windows specific version, an iOS specific version and an Android specific version of the application programmed to the native technologies available on the platform. While this is a simple straight forward approach it&nbsp;amounts&nbsp;to considerably more expensive development cost and time. C++ is unique as it provides the ability to write&nbsp;efficient, fast&nbsp;and feature rich cross-platform mobile code once which can then be shared across these different device platforms.&nbsp;<\/p>\n<p class=\"paragraph\" style=\"text-align: left\">Visual Studio 2015&nbsp;Preview (download <a href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkId=517033\">here<\/a>) introduces support for developers to be able to build&nbsp;<strong>cross-platform mobile<\/strong>&nbsp;native (C\/C++) binaries targeting Windows platforms (through the Visual C++ toolchain C1xx\/C2) and the Android&nbsp;platform (through Clang\/LLVM toolchain). Using this experience,&nbsp;developers will&nbsp;be able to share their cross-platform mobile code easily while making use of advanced&nbsp;development&nbsp;features like&nbsp;<em>cross-platform&nbsp;<\/em><em>I<\/em><em>ntellisense<\/em><em>, refactoring, cross-platform debugging&nbsp;<\/em>and&nbsp;more driving&nbsp;developer&nbsp;productivity.\u202f<\/p>\n<p>The Android Platform with API Level 3&nbsp;introduced the&nbsp;<a href=\"https:\/\/developer.android.com\/tools\/sdk\/ndk\/index.html\">Native Development Kit (NDK)<\/a> which enables creation&nbsp;and consumption&nbsp;of libraries written in C\/C++. Using Visual Studio 2015 preview, developers will be able to:&nbsp;<\/p>\n<ul>\n<li style=\"text-align: left\">Easily build&nbsp;<strong>dynamic shared libraries<\/strong>&nbsp;and&nbsp;<strong>static libraries<\/strong>&nbsp;which encapsulate all the native (C\/C++) code for the application. These libraries can then be used&nbsp;as part of&nbsp;other&nbsp;Android applications (.apk&#8217;s) using technologies like&nbsp;<a href=\"http:\/\/xamarin.com\/\"><strong><span style=\"text-decoration: underline\">Xamarin<\/span><\/strong>&nbsp;<\/a>and&nbsp;<strong><span style=\"text-decoration: underline\"><a href=\"https:\/\/www.java.com\/en\/\">Java<\/a><\/span><\/strong>. \u202fWe have been working with&nbsp;<strong><span style=\"text-decoration: underline\"><a href=\"http:\/\/xamarin.com\/\">Xamarin<\/a><\/span><\/strong>&nbsp;to enable a smooth experience in Visual Studio when building&nbsp;<span style=\"text-decoration: underline\">Xamarin<\/span>&nbsp;Android applications leveraging C\/C++ code.&nbsp;<br \/> &nbsp;<\/li>\n<li style=\"text-align: left\">Create&nbsp;Android&nbsp;<strong><span style=\"text-decoration: underline\"><a href=\"http:\/\/developer.android.com\/reference\/android\/app\/NativeActivity.html\">Native-Activity<\/a><\/span><\/strong>&nbsp;applications,&nbsp;<span style=\"text-decoration: underline\"><a href=\"http:\/\/developer.android.com\/reference\/android\/app\/NativeActivity.html\">Native-Activity<\/a><\/span>&nbsp;applications are implemented purely in native code (C\/C++) and used typically for games and applications requiring&nbsp;advanced graphic manipulation. Developers will be able to build, <a href=\"http:\/\/blogs.msdn.com\/b\/visualstudioalm\/archive\/2014\/11\/12\/debugging-c-code-on-android-with-visual-studio-2015.aspx\">debug<\/a> and deploy native-activity&nbsp;android&nbsp;applications to emulators and devices alike.&nbsp;<br \/> &nbsp;<\/li>\n<li style=\"text-align: left\">Quickly&nbsp;Iterate over the edit-build-debug cycle&nbsp;by&nbsp;making use of the&nbsp;&nbsp;fast x86 based&nbsp;<strong>Android emulators&nbsp;<\/strong>for&nbsp;deployment and targeted&nbsp;application testing utilizing the&nbsp;simulated&nbsp;sensors (like Zoom, Orientation, Accelerometer, Power and others).&nbsp;For more information please refer to this blog-post<a href=\"http:\/\/blogs.msdn.com\/b\/visualstudioalm\/archive\/2014\/11\/12\/introducing-visual-studio-s-emulator-for-android.aspx\"> here<\/a>.<br \/>&nbsp;<\/li>\n<\/ul>\n<h2 style=\"text-align: left\">Getting Started<\/h2>\n<p style=\"text-align: left\">In order to get started with doing <em>cross-platform mobile<\/em> development with Visual C++ download Visual Studio 2015 Preview (download here). On running the installer please choose the following installation option (&#8216;Visual C++ for cross-platform mobile development&#8217;) as shown in the figure 1. below.&nbsp;<\/p>\n<p>&nbsp; &nbsp;&nbsp;<a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/11\/6253.pic2_.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/11\/6253.pic2_.png\" alt=\"Image 6253 pic2\" width=\"308\" height=\"395\" class=\"alignnone size-full wp-image-28509\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/11\/6253.pic2_.png 308w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/11\/6253.pic2_-234x300.png 234w\" sizes=\"(max-width: 308px) 100vw, 308px\" \/><\/a>&nbsp; &nbsp;<a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/11\/1145.pic3_.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/11\/1145.pic3_.png\" alt=\"Image 1145 pic3\" width=\"312\" height=\"398\" class=\"alignnone size-full wp-image-28507\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/11\/1145.pic3_.png 312w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/11\/1145.pic3_-235x300.png 235w\" sizes=\"(max-width: 312px) 100vw, 312px\" \/><\/a>&nbsp; &nbsp;<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/11\/6648.pic4_.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/11\/6648.pic4_.png\" alt=\"Image 6648 pic4\" width=\"458\" height=\"643\" class=\"alignnone size-full wp-image-28510\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/11\/6648.pic4_.png 458w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/11\/6648.pic4_-214x300.png 214w\" sizes=\"(max-width: 458px) 100vw, 458px\" \/><\/a><br \/><span style=\"font-size: xx-small\">&nbsp; &nbsp; &nbsp;Fig1: Choose Visual C++ for Cross-Platform Mobile Option &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Fig 2: Choose &#8216;Restart and Install&#8217; option &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Fig 3: Choose required additional software<\/span><\/p>\n<p class=\"paragraph\" style=\"text-align: left\">Once this primary installation is complete,&nbsp;cross-platform mobile development users&nbsp;are provided with an&nbsp;additional&nbsp;install&nbsp;of third party&nbsp;software&nbsp;as&nbsp;part of the secondary installer shown in figure 2. (Choose&nbsp;&#8216;Restart and Install&#8217; option). Once the secondary installer comes up after a system restart,&nbsp;make sure the following entities&nbsp;are all&nbsp;(<a href=\"https:\/\/developer.android.com\/sdk\/index.html?hl=i\">Android SDK<\/a>, <a href=\"https:\/\/developer.android.com\/tools\/sdk\/ndk\/index.html\">Android NDK<\/a>, <a href=\"http:\/\/blogs.msdn.com\/controlpanel\/blogs\/posteditor.aspx\/=http:\/ant.apache.org\/\">Apache Ant<\/a>, <a href=\"https:\/\/www.java.com\/en\/\">Oracle Java SDK<\/a> and Microsoft Visual Studio Emulator for Android)&nbsp;selected as shown in&nbsp;Figure&nbsp;3&nbsp;and follow through the rest of the installation process.\u202f&nbsp;<br \/> \u202f&nbsp;<\/p>\n<h2>Cross-Platform Mobile Templates<\/h2>\n<p style=\"text-align: left\">Once a successful installation is complete. As a part of the File-&gt;New-&gt;Visual C++ -&gt;Cross Platform node you should see a collection of templates being introduced (as shown in figure 4 below).&nbsp;<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/11\/4571.pic6_.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/11\/4571.pic6_.png\" alt=\"Image 4571 pic6\" width=\"955\" height=\"525\" class=\"alignnone size-full wp-image-28508\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/11\/4571.pic6_.png 955w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/11\/4571.pic6_-300x165.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/11\/4571.pic6_-768x422.png 768w\" sizes=\"(max-width: 955px) 100vw, 955px\" \/><\/a>&nbsp;<br \/><span style=\"font-size: xx-small\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Fig 4: New templates introduced under Visual C++ -&gt; Cross Platform node<\/span><\/p>\n<p style=\"text-align: left\">The templates decorated with the (Android) specific keywords such as the &#8216;Dynamic Shared Library (Android)&#8217; template allows developers to create binaries specifically for the Android Platform where as templates decorated with (Cross Platform) keyword will allow developers to currently create binaries&nbsp;targeting&nbsp;both the Windows and Android platform respectively. The Cross Platform template will also highlight Visual C++&#8217;s ability to share and author code across these platforms easily. Please look forward to specific blogs talking about these templates in more detail which we will be posting soon.<\/p>\n<h2>Wrap up<\/h2>\n<p style=\"text-align: left\">This blog should give you an overview about the work we have done in VS2015 preview introducing Visual C++ Cross-Platform mobile development. We&nbsp;will&nbsp;follow up this blog post with&nbsp;additional&nbsp;posts&nbsp;diving deeper into&nbsp;key features.&nbsp;&nbsp;This is a preview release and as with any preview release, the goal for us is to collect feedback and learn from you. We are considering future support for other platforms too and your feedback is critical in shaping the direction of our product.&nbsp;&nbsp;<br \/> &nbsp;<br \/>Sharing feedback is easy! Make feature suggestions on <a href=\"http:\/\/visualstudio.uservoice.com\/forums\/121579-visual-studio\/category\/30937-languages-c\">UserVoice<\/a>, log bugs you find on our <a href=\"http:\/\/connect.microsoft.com\/visualstudio\">Connect<\/a> site and <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/zzszcehe.aspx\">send us a smile or frown<\/a> from inside the IDE. You can also leave comments below. In addition to this if you are\u202flooking&nbsp;to&nbsp;have&nbsp;a&nbsp;<span style=\"font-size: 12px\">directed conversation with our product team&nbsp;on this topic, please reach out to us through email (<\/span><span style=\"text-decoration: underline\"><a href=\"mailto:aasthan@microsoft.com\">aasthan@microsoft.com<\/a><\/span><span style=\"font-size: 12px\">).&nbsp;We would love to know more and connect with you.\u202f&nbsp;<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Overview Modern application customers are demanding applications be available for&nbsp;multiple device platforms (such as&nbsp;Windows, &nbsp;Android&nbsp;and&nbsp;iOS).&nbsp;Today there exist multiple approaches in writing applications which target these&nbsp;device platforms. One approach is to simply create multiple versions of the application in different source trees-in other words a Windows specific version, an iOS specific version and an Android specific [&hellip;]<\/p>\n","protected":false},"author":265,"featured_media":35994,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[8],"class_list":["post-203","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cplusplus","tag-announcement"],"acf":[],"blog_post_summary":"<p>Overview Modern application customers are demanding applications be available for&nbsp;multiple device platforms (such as&nbsp;Windows, &nbsp;Android&nbsp;and&nbsp;iOS).&nbsp;Today there exist multiple approaches in writing applications which target these&nbsp;device platforms. One approach is to simply create multiple versions of the application in different source trees-in other words a Windows specific version, an iOS specific version and an Android specific [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/203","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/users\/265"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=203"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/203\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media\/35994"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media?parent=203"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=203"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=203"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}