C++ in mobile apps. How does it works - c++

Tell me.
How is executed binaries (written in c++ ForExample) in mobiles??
Is it only possible as mixed with J2ME or is it possible to execute "RAW" (like exe file) binary.
(In old and new mobiles)

Running a program on a mobile phone is like running it on a normal computer.
You have to take two things into consideration the processor that is running the phone and the OS that is running on top of the processor.
Certain phone OS's are very restrictive on what they let run on the phone so you need to read up on the restrictions imposed by the OS.
Secondly the processors are usually very limited and completely different to a normal PC so you need a compiler that will generate code for that processor.
But RAW object files are not enough C++ is dependent on a whole set of standard libraries functions and framework to start up the application. For this you will need to have the appropriate SDK for the your phone so that you can link your program with the appropriate framework that your phone OS will understand.
The last problem is getting the binaries onto the phone. Detailed instructions will usually come with the SDK.

How is executed binaries (written in
c++ ForExample) in mobiles??
There are two ways.
First, the application can consist of natively executable instructions. In a Windows CE based mobile phone, like Windows Mobile/phone, this means the PE format, which native C and C++ code is compiled and linked to.
Second, the application can be managed by a runtime environment, like J2ME for Java and the CLR for .Net CF on Windows CE/Mobile/Phone. Then the runtime environment executes PE and the application layer above, e.g., .Net CF is compiled to an intermediate language that is compiled to PE during runtime ("jitted").

Common Windows .exe are unlikely to run on mobiles out-of-the box.
The target mobile has to have a specific SDK, which will help compiling C code into native platform code.
Or, if the mobile has a common operating system, like Symbian or Windows mobile, then you need SDK and compilers for these target platforms.

I think it depends on the operating system of the mobile device. For example, if its Windows Mobile 5/6 they can use .exe files compiled with the Windows CE SDK.

Related

Convert a Windows Phone 8.1 project into a Portable Library

I haven't been able to find any information on this issue:
I have a C++ Windows Phone 8.1 library project, I would like to convert it into a portable library without having to recreate the project and set all parameters.
I guess it should be possible to do it by editing the vcxproj file, but I don't know how to modify it to make it work.
I meet several issues:
What is the equivalent of Portable Library (C#) for C++?
How to change an existing Windows Phone 8.1 C++ project into this equivalent?
Thanks :)
In general, Windows Phone 8.x doesn't support sharing of binaries with Windows desktop because the import libraries are different between the two (eg, desktop apps link against kernel32.dll but that DLL doesn't exist on Windows Phone). You could share between Windows Phone 8.0 and 8.1 though (provided you only used features available in 8.0).
In theory you might be able to make a static lib that was shared if it didn't depend on any Windows APIs, but it's not really supported. You could try creating a new Static Library project and diffing it against your current project to see what settings have changed.
This changes in Windows 10, where shared binaries are fully supported (obviously you still need ARM vs x86 vs x64 builds depending on CPU architecture).
According to Maximize code reuse between Windows Phone 8 and Windows 8 C++ is not supported as PCL language as this is a .net framework technology.
Note that Portable Class Libraries are a .NET Framework concept and don’t support C++
I also looked into Visual Studio to confirm that and couldn't find a template.

Is it possible to use Native C++ code in ARC?

We want to try to launch our software on Chrome OS using ARC. Many parts of our software application are written in C++ and compiled using the Android NDK.
Is it possible to launch this kind of application under ARC?
Is it possible to launch Native applications(or Java + JNI) under ARC?
Yes, ARM compiled NDK libraries will run on all Chromebooks currently. For ARM machines they run more or less natively.
For non-ARM machines there is a binary translation layer that dynamically converts the code to run on the target machine. This layer may not be 100% machine compatible and if you see errors or crashes indicating instructions cannot be translated, or fundamental differences between your app on ARM and x86, you should file a bug: http://goo.gl/megdlG
I am currently using a library in my project called PDFtron. It contains ".so" files that I have to assume are either c or c++, and they work fine with Java + JNI. There doesn't seems to be a lot of information out there about how this all works(and what works or doesn't), so please post your findings.
From google spokesperson(taken from arstechnica):
"""The app code is all running on top of the Chrome platform, specifically inside of Native Client. In this way the ARC (App Runtime for Chrome) apps run in the same environment as other apps you can download from the Chrome Web Store, even though they are written on top of standard Android APIs. The developers do not need to port or modify their code, though they often choose to improve it to work well with the Chromebook form factor (keyboard, touchpad, optional touchscreen, etc)."""
In this quote I think the important part is the integration with native client, which is a technology for executing Native code like C and C++ in the browser.

MFC app to Linux dll

Currently we have a legacy client/server system written in MFC(server) and Java(client). This system cant not run on Internet because of various reason. So, we are developing a small system (very few functionalities of this legacy system) in cake php etc to fullfill customer requirement.
Now, one functionality in legacy system needs in this new system. We are thinking of making a DLL of that code and then integrate it with cake php (to save time) but this DLL will not work on Linux where this new system will sit.
So, is there any way to generate a dll so that it works with php in Linux system using QT etc?
OR
we have to rewrite the whole thing? In this case, what would be the most appropriate framework to develop cross platform dll. I would prefer to use Windows to write it.
Also, can we run dll with cake php?
Thanks
So, is there any way to generate a dll so that it works with php in Linux system using QT etc?
No, Linux doesn't support the DLL file format. You may want to compile a shared object file in the ELF format from your source code.
I think, the two most prominent cross platform GUI libraries are wxWidgets and Qt.
You cannot use a Windows DLL as a part of a Linux application. That is simply not possible, because of the different object formats.
So, the only option is to rewrite or port it in some form.
A guide for porting your application might be Porting MFC applications to Linux, which uses wxWidgets.
Another one using Qt, could be MFC to Qt Migration - Walkthrough.

Is it possible to program for Windows Phone 7 in standard C++ only?

I know that the recommended language for Windows Phone 7 development is C#.
However, for various reasons, I very much prefer continuing to program in standard C++, if possible.
Is it possible to program for Windows Phone 7 in standard C++ only?
If the answer is yes, what tools and resources do I need to accomplish that?
EDIT, finally: for WP7 it won't ever be, but for Windows Phone 8 - yes you can. Native apps, C/C++, iOS/Android portability and code sharing, DirectX. You'll need Visual Studio 2012 and Windows 8 for WP8 development, though. VS2010 is not getting the requisite SDK. To run the emulator, you'll need a 64-bit physical Windows 8 box with a SLAT-enabled CPU. You can still develop on a virtual machine, but you'd need a device to run apps, the emulator won't start.
The nongame UI, however, will still be XAML-based and managed. The entirety of Win32 API will not be supported. They're pushing a model with managed UI layer and a native middleware beneath it. Purely native development is still not an option; although one might try with WinMD classes as code-behind for XAML. The visual XAML designer will probably choke, and you'll need a dummy managed DLL anyway.
EDIT: even assembly, as long as it's targeting Thumb-2 and the mnemonics are UAL-style. For running on the simulator, you'd have to produce an alternative set of assembly files (or other sources) targeting Intel.
For the sake of posterity, here's the pre-06/20/2012 answer:
If you work for Microsoft or an OEM, then yes. Otherwise, no (for now).
There's hope though. Google did relent and issued their NDK after a while; Microsoft might, too. The native code capability is already there. Once they come up with a sensible sandboxing solution, why not.
Also, there's already some pressure from big-name software vendors to open up native development. Mozilla people stated outright that there will be no Firefox on WP7 unless it's native. Similar rumors about Flash.
EDIT: if you want a native SDK on WP7, like I do, please go sign the petition here and/or the one over there. Thank you!
EDIT2: see this. It's a leak and therefore not official, but still, I say there's some hope.
EDIT3: also this. Still not official, but this rumor moves the timeframe for native app support even closer - to the upcoming Tango release.
EDIT4: Microsoft seems to be pretty keen to promote WinRT, their new tablet-oriented XAML-based app platform, which allows for (among other things) unmanaged C++. Now, on every other major mobile OS the tablet and the phone app stacks are one and the same. Just sayin'.
EDIT5: there's been some proof-of-concept work along the lines of C++ => LLVM => MSIL and C++ => LLVM => C#, but nothing production-quality so far.
Phone manufacturers such as Samsung can deploy applications written in unmanaged code, but all other developers can not.
No that is not possible. Microsoft has made a decision to only allow application developers to use managed code on the Windows Phone 7 devices.
According to Wikipedia Windows Phone 7.0 runs Windows CE 6.0 R3/7.0 hybrid as operating system.
In theory one could use C++ to build standard* C++ programs targeting Windows CE 6.0 R3 and 7.0 (supposed to come out on Q1 2011). I mean all the standard* dlls should be there (gdi32.dll, user32.dll) Internet Explorer and other C++ programs are still running on Windows Phone 7.
The how to get the application on the phone? and how to run the application on the phone? are the next questions which at the moment I don't know how to answer.
This interview tells something about it: Writing the WP7 App Platform in C# and C++ I haven't watched it yet, so you might add respective comments :)
Windows Phone 7 supports Silverlight and XNA.
All programs for Windows Phone 7 are written in .NET managed code. It is also possible to write Windows Phone 7 applications in Visual Basic .NET.
Visual Studio 2010 Express for Windows Phone includes XNA Game Studio 4.0 and an on-screen phone emulator, and also integrates with Visual Studio 2010. You can develop visuals and animations for Silverlight applications using Microsoft Expression Blend.
The Silverlight and XNA platforms for Windows Phone 7 share some libraries, and you can use some XNA libraries in a Silverlight program and vice versa.
But you can’t create a program that mixes visuals from both platforms. Maybe that will be possible in the future, but not now.
EDIT:
to be more clear..there is no native C++ support you'll have to use either Silverlight or XNA,both are based on .net framework.

Using windows DLLs in a portable app

I have built a windows C++ application that I'd like to port to linux. The main reasons to do this is ease of system maintenance for our IT staff. Apart from the one windows machine that runs this application we're a linux only operation.
The reason this application was built in-, and runs on- windows is that it uses a windows API (dll and header) to connect to a server belonging to an external party. This connection uses some proprietary protocol that I don't really want to mess with, (and I think I'm contractually not allowed to) so I'm stuck with the .dll.
This dll is windows only because of (I suspect) windows sockets specific code in the dll. Apart from that it doesn't do a whole lot of advanced stuff. Is there a way somewhere between just running the app on linux in WINE and sniffing out the protocol and reimplementing the DLL myself that will allow me to get this application to run on a linux machine?
This idea got inspired by this item about QT creator so any solution that allows me to play with that would be extra cool.
The most obvious middle ground would be to use Winelib. I do not know if it can link directly to a native DLL, but if not you probably could load it with LoadLibrary().
You could then split your application in two parts: a wrapper which only calls the DLL, and the rest of the code talking to your wrapper. You could have both in separate processes, and thus only the wrapper would have to be compiled with Winelib. The rest of the application could then use whatever framework you want.