Jump to content
MrGrj

Build cross platform apps using c++ and save your time, money and code

Recommended Posts

  • Active Members

Building cross platform apps can be a huge savings for your company you are a startup especially because you can hire only one developers for entire mobile suite of applications.

You can build native C++ apps for Android and Windows devices, and share code in libraries built for iOS, Android, and Windows, by using Visual C++ for Cross-Platform Mobile Development. This is an option available in Visual Studio 2015 that installs the SDKs and tools you need for cross-platform development of shared libraries and native apps. When it’s installed, you can use Visual C++ to create code that runs on iOS and Android devices and platforms, in addition to Windows, Windows Phone, and Xbox.

Writing code for multiple platforms can be frustrating. The primary development languages and tools for iOS, Android, and Windows are different on each platform. However, all platforms support writing code in C++. This is the common denominator that you can use to enable reuse of core code across platforms. Native code written in C++ can be both more performant and resistant to reverse engineering. Code reuse can save both time and effort when creating apps for multiple platforms.

You can use Visual Studio to build shared libraries of standard C++ code for Classic Windows applications, Universal Windows apps, iOS, and Android platforms. You can build native apps for Windows and Android platforms using only Visual C++ and third-party tools integrated into Visual Studio. If you have a Mac computer, you can use Visual Studio to create and debug C++ code for iOS apps that are built and deployed on your Mac.

 

Quote

Out of the box, Visual C++ for Cross-Platform Mobile Development supports Android API Level 19 and 21, targeting Android 4.4 and 5.0. Other API levels can be installed with the SDK Manager. The Visual Studio C++ Android debugger requires target emulators or devices run at least Android API level 17 (version 4.2) or newer.

 

Requirements

For installation requirements, see Visual Studio 2015 System Requirements.

Quote

If you are using Windows 7 or Windows Server 2008 R2, you can develop code for Classic Windows applications, Android Native Activity apps and code libraries, and apps and code libraries for iOS, but not Windows Store or Universal Windows apps.

 

To build apps for specific device platforms, there are a few additional requirements:

  • The Visual Studio Emulator for Android and Windows Phone emulators require a computer that can run Hyper-V. For more information, see the emulator’s system requirements.

  • The x86 Android emulators that come with the Android SDK work best on computers that can run the Intel HAXM driver. This driver requires an Intel x64 processor with VT-x and Execute Disable Bit support. For more information, see Installation Instructions for Intel® Hardware Accelerated Execution Manager – Microsoft Windows.

  • Building apps for iOS requires an iOS Developer Program account and a Mac computer that can run Xcode 6.

Get the Tools

Visual C++ for Cross-Platform Mobile Development is an optional component included in Visual Studio 2015. To get Visual Studio, go to the Visual Studio 2015 Downloads page and download Visual Studio 2015.

The installer for Visual Studio 2015 includes an option to support cross-platform mobile development. This includes the option to install Visual C++ Mobile Development and the following common tools and software development kits. Most of these options are open-source software required for cross-platform support.

  • Android Native Development Kit (R10E, 32bits) is required for the Android build process.
  • Android SDK, Apache Ant, and Java SE Development Kit are required for the Android build process.
  • Microsoft Visual Studio Emulator for Android is a fast, capable emulator for Android development.

For detailed installation instructions, see Install Visual C++ for Cross-Platform Mobile Development.

To build code for iOS, you need to set up and configure a remote build agent on your Mac and connect to it in Visual Studio. For detailed installation and configuration instructions, see Install And Configure Tools to Build using iOS.

Create a new Android Native Activity project

You can use Visual C++ for Cross-Platform Mobile Development to create, build, run and debug a complete Android app using C++. Visual Studio includes a template for an Android Native Activity project that can help you get started.

 

In this tutorial, you’ll first create a new project and then build and run the default app.

Before you can create a new project, make sure that you’ve met all system requirements and installed the Visual C++ for Cross-Platform Mobile Development for Visual Studio. For more information, see Install Visual C++ for Cross-Platform Mobile Development.

Take a look at the video to build cross platform apps

 

To create a new project

Open Visual Studio. On the menu bar, choose File, New, Project.

In the New Project dialog box, under Templates, choose Visual C++, Cross Platform, and then choose the Native-Activity Application (Android) template.

Give the app a name like MyAndroidApp, and then choose OK.

 

codingsec-cross.png

 

The new Android Native Activity app solution includes two projects:

  • MyAndroidApp.NativeActivity contains the references and glue code for your app to run as a Native Activity on Android. The implementation of the entry points from the glue code are in main.cpp. Precompiled headers are in pch.h. Your app project is compiled into a shared library (.so) file which is picked up by the Packaging project.
  • MyAndroidApp.Packaging creates the packaging (.apk) file for deployment on an Android device or emulator. This contains the resources and AndroidManifest.xml file where you set manifest properties. It also contains the build.xml file that controls the Ant build process. It’s set as the startup project by default, so that it can be deployed and run directly from Visual Studio.

Build and run the app generated by the template to verify your installation and setup. By default, the template sets the solution configuration to Debug and the solution platform to x86 to run the app on the Microsoft Visual Studio Emulator for Android. If you prefer to test your app on another target, load the target emulator or connect the device to your computer.

To build and run the default Native Activity app

  1. On the menu bar, choose BuildBuild Solution.

    The Output window displays the output of the build process for the two projects in the solution.

  2. Choose one of the VS Emulator profiles as your deployment target.

    If you have installed other emulators or connected an Android device, you can choose them in the deployment target dropdown list.

  3. Press F5 to start debugging, or Shift+F5 to start without debugging.

    Here’s what the default app looks like in the Visual Studio Emulator for Android.

cross2.png

 

Visual Studio starts the emulator, which takes a few seconds to load and deploy your code. Once your app has started, you can set breakpoints and use the debugger to step through code, examine locals, and watch values.

Please take your time to comment on our articles and suggest us some topic you like.

Source

Edited by MrGrj
  • Upvote 2
Link to comment
Share on other sites

Unity e C#/js din cate stiu si e destinat in principal jocurilor, chiar daca ai posibilitatea sa faci mai multe chestii.

Tot in C# pentru aplicatii android/iOS mai exista Xamarin , dar din cate stiu are doar un trial "moca".

 

In  C++ pentru aplicatii "all-around" Qt  inca e solid (la fel si IDE-ul), iar specific pentru gamedev aveti Unreal (de mentinut ca recent au adaugat suport specific pentru Android din moment ce Unity are o vechime  pentru jocuri 2D/lightweight, etc).

  • Upvote 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...