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

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.

Related

Is it possible to create a C# DLL of C++/CLI code using .Net Core 3.1 on Linux

This might be a very specific question. But it might be interesting for some other people, too.
The setting might be quite common: we develop an embedded device using C++ and Linux and have a build system for this. With our device we ship a C# desktop app using a DLL based plugin mechanism. The plugin contains the shared logic used both on the embedded device and the app. To keep processes easy it would be best to create the DLL on our Linux build system (hence I would like to use .Net Core and not "normal" .Net).
As far as my trial and error showed it's not possible - even with .Net Core 3.1. Can you confirm this? The software is for windows only (although it's compiled on Linux) - so theoretically it could possible since .Net Core supports CLI/C++ in Version 3.1 (https://devblogs.microsoft.com/dotnet/announcing-net-core-3-1/).
What I tried:
I compiled pure C# code on Linux to an exe running successfully on windows using the console app dotnet
I successfully created a simple C++/CLI test app on Windows using sample code following this guide: https://devblogs.microsoft.com/cppblog/an-update-on-cpp-cli-and-dotnet-core/
Finally I took the (probably for too naive) approach to replace the test app's .vcxproj with the .csproj of step 1 (.csproj seems to detect files automatically). I got the following error message:
quote CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point [/home/vagrant/Projects/cpp_dotnet_on_linux/cs_on_linux.csproj]
Is there something I can improve or is the task just impossible (adding the cpp-files manually to .csproj, ...)? I'm afraid it's just technically impossible because I guess .Net Core is missing a C++ compiler on Linux but I'm not sure.
C++/CLI is not support on Linux.
Some sources:
https://devblogs.microsoft.com/cppblog/the-future-of-cpp-cli-and-dotnet-core-3/ :
We don’t currently have plans for C++/CLI for targeting macOS or Linux. Additionally, compiling with “/clr:pure” and “/clr:safe” won’t be supported for .NET Core.
https://github.com/dotnet/coreclr/issues/659#issuecomment-539742740
C++/CLI on Linux will not be supported and would be very challenging. It would require Microsoft VC++ to support Linux or require Clang or GCC to support C++/CLI. Those are both huge projects with uncertain payoff. It is also unclear if Clang or GCC would ever allow us to upstream our changes. Maintaining an up-to-date fork of a fast moving compiler project forever is very expensive. We have no plans to take on either of those projects.

Is there a way to build cpputest with pthreads disabled?

I'm planning to use cpputest as a testing framework in my project which I need to cross compile as it will be used on ARM platform. The compiler I'm using for ARM development is arm-gcc which is built with pthreads disabled. Due to this, I need to build cpputest without pthreads. Currently l am following the autotool approach for building cpputest. Any help would be really appreciated.
Are you trying to compile, download, and run CppUTest on a target device?
Typically, CppUTest isn't compiled and downloaded to your target device but instead it's built as a Windows (or Linux) console application. This means that CppUTest gets compiled using a native compiler (Visual Studio or GCC) but your firmware will also need to compile using that same native compiler (Visual Studio or GCC).
Unit testing is meant to verify that your code's logic is correct, which means it doesn't matter if the code is executing on an ARM processor or in an Intel processor. For the record, when I first started getting into unit testing this blew my mind.
But what about hardware registers and stuff like that? Well, there's ways around testing embedded devices hardware in a Windows environment. At the end of the day, you'll still need to download your firmware onto the embedded device and verify that your port mappings are correct (i.e. That you're properly settings up a GPIO port to turn on an LED for instance).
There's several advantages to running your unit testing on your development PC instead of on target. Your development PC is much faster, has more resources (i.e. storage and RAM) and it also easily allows for running in a continuous integration environment (like Jenkins or TeamCity) whenever you check-in code to your version control system.
I highly recommend the book Test-Driven Development for Embedded C by James W. Grenning for more information. It will answer all your questions on unit testing on an embedded device. CppUTest can be used for C as well as C++ projects.

How to run C++ executable in Windows PE?

I have an executable I made using a CLI console application with Visual Basic 2010. I can run the program completely fine from my developer machine.
However, when I copy the executable over to another machine, re-boot to a pre-installation environment and run the executable again, nothing happens at all. There are no errors shown or anything.
My guess is the executable can't run without certain dependencies that aren't loaded at this environment, but I need it to work in a PE.
Any ideas on whats going on?
First of all, since the question is tagged "c++" and you mention C++/CLI several times, I assume that "Visual Basic 2010" is a typo for "Visual Studio 2010". But either way, whether you've written the application in Visual Basic (VB.NET) or C++/CLI, the problem is exactly the same.
My guess is the executable can't run without certain dependencies that aren't loaded at this environment, but I need it to work in a PE.
That's exactly correct. You've written an application that targets the .NET Framework. Somewhat like Java applications requiring a JVM, .NET applications require that the .NET Framework be installed in order to run (or a compatible alternative implementation, like Mono). Unfortunately, Windows PE does not support the .NET Framework.
Note that it is irrelevant whether you've written a WinForms, WPF, or Console application. Although they present their UI in very different ways, they all depend on the .NET Framework being installed.
You will need to (re-)write the application in a different programming language, one that generates native code without any dependencies on the .NET Framework. C and C++ are popular choices. If you choose to use C++, make sure that you create what Visual Studio calls a "Win32" project. This is one that targets the underlying operating system APIs directly (i.e. a native application) and does not have a dependency on the .NET Framework. Stay away from anything that has ".NET" or "CLR" in its description.
I don't really have a full comprehension of when an application is using .NET or not... I am just used to Linux C/C++ development. I hate Microsoft shit
It uses .NET whenever you use the .NET Framework libraries/classes in your code. I'm not really sure why this is so difficult to understand. The same problem could easily exist on Linux if you were using a third-party library that was not available in certain environments for whatever reason. This is not Microsoft's problem, it's an issue of using the wrong tools for the job. The .NET Framework is an object-oriented wrapper around the native APIs that makes it much easier for people to get up and running writing programs for Windows. But if you're "used to Linux C/C++ development", you should have little trouble writing a simple console application that targets the native APIs directly without using .NET.
If your hatred for "Microsoft shit" has turned into an allergy, you can avoid Visual Studio entirely and download MinGW, which is a Windows port of the GCC compiler you're probably used to. Combined with your favorite Windows port of Vi, you're working in an environment very similar to the one you're used to. And since GCC doesn't support C++/CLI or the .NET Framework, you won't have to worry about getting stuck picking the wrong option.
The .Net framework has been supported as an optional package install during your PE build process for the past couple versions of WinPE. I write code in C# that I run in WinPE everyday. I have yet to find a good way to debug in a manner where I can walk through break points, etc... though. My best option has just been a lot of logging and a global Exception catch around my main entry point that will write out a full stack dump. You can attach to your app as a remote process in a VM running WinPE, but if you need to catch something early in the execution you'll have a difficult time.

C++ in mobile apps. How does it works

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.

Porting .NET C++ standalone to Mac

I need to give an estimate for porting a standalone program to a Mac from a .NET platform. I have all the source code which is in C++ and is both code I wrote and a modified version of GLUT/GLUI because the program uses OpenGL and GLUT/GLUI as a UI.
I don't think the C++ code will be a problem or the OpenGL environment, please tell me if you think it will be. In .NET, I use OpenGL32.DLL and deploy it with my app. I need to find out how this is done for a Mac?
I really need to know what the current deployment method is for Mac's these days and how hard it will be for me to write for it. For .NET, I use Visual Studio for the application development and deployment, I make a new VS project to build the deployable MS installer.
The deployment process also allows things like placing a desktop shortcut, associate a unique icon with the program ... What deployment options can one select on a Mac? What do you think the biggest obstacles will be?
There's no .NET framework calls within the code. The deployment phase produces a .NET assembly with all the security features. I think that is the main relationship with .NET since it is straight C++ not C#.
Development should be rather straight-forward. You'll be able to do OpenGL/GLUT/etc... through the Cocoa framework. Look at this example from Apple to see how it is done in code.
As for development tools, you will be able to use Xcode (which is free with the Mac). You can develop in C++ and compile with GCC.