Linking to a C++ native library in MonoTouch - xamarin.ios

I am reading up about linking native libraries into MonoTouch, specifically this documentation:
http://monotouch.net/Documentation/Linking_Native_Libraries
Here it describes linking to C libraries. Is it also possible to link to C++ libraries from MonoTouch? I am very new to MonoTouch and particularly to importing libraries, so I would appreciate any advice about problems I may face trying to import a C++ library, if this is indeed possible. Would wrapping the C++ library in an Objective-C library and then using btouch to import this be a good route to take? Or is there an easier approach? Bearing in mind that my knowledge of C++ (and Objective-C for that matter) can best be described as "dangerous". ;)
The reason that I ask is that I am needing to make use of a C++ API from Sybase to access their Ultralite database. I have managed to get a sample application that accesses the Ultralite C++ API working in Xcode, with Objective-C. But now I am trying to port this sample to MonoTouch. The sample application can be found here:
https://github.com/BruceHill/Ultralite-Names-Sample-ObjC
The Sybase documentation for Xcode mentions the following, with reference to using the API in Xcode:
This tutorial uses the UltraLite C++ API. In order to eliminate the need to cast to C types, compile the source as C++. To compile the project as C++:
In the Search in Build Settings box, enter Compile Sources As.
Choose Objective-C++ from the options in the Value field
What are the implications of this for working with this API in MonoTouch?

You can certainly use a C++ api, but you will need to either wrap it in a C api, or a ObjC+btouch api to be able to talk to this. Invoking C api's uses PInvoke, and C++ libraries use symbol mangling. While theoretically you could pinvoke to the mangled symbol, this isn't a good idea as the mangling is compiler specific.

Related

Integrate C++ on webOS project

I'm developing a project for webOS 3.0 and I want to know if it's possible to integrate a C++ lib binary on a webOS aplication. I am tying to use nodejs addons and require the addon.node file into a JSservice like a module, but, according to this official LG developer it's not possible to integrate addons including C/C++ on webOS 3.0:
You cannot use modules including C/C++ addons. You must use modules implemented with JavaScript only.
I also tried using emscripten. This approach is not very convenient because it requires manually keeping track of all exported methods. As this project is maintained for several platforms and the code is already quite large, this becomes a hassle. The maintenance overhead would grow.
The question is whether there are any other ways of integrating C++ on webOS 3.0. Neither of the approaches I found seem ideal.
Sadly no.
WebOS on Palm supported C++ modules via their Plug-In Development Kit (PDK).
Unfortunately, to the best of my knowledge, it's not supported on LG TVs.

C++ Cross Platform Library (iOS and Android) using math.h

I am using VS2015 RC and the cross platform C++ Shared Library Template. Under the .Shared code I added a simple point class. When it created the class, in the .cpp it included pch.h or a pre-compiled header that is only available in .android and not .ios. That threw an error, so I just removed that so I didn't get errors and figured I could include my STL items as needed. Hopefully that is the correct route for that.
Anyway my main issue is
In the Point.cpp file I need to use sqrt so I need to include math.h:
#include <math.h>
I have tried including it several different ways (cmath...), but no matter what I get the error myprojectname.iOS: Error: cannot open source file "math.h".
According to the setting sin the project properties for .iOS Use STL is LLVM C== standard library with C++11 support (libc++).
I am not sure how to add the correct include directory for iOS this is the first time I've written a cross platform library and done any iOS development.
From what I've read all the STL classes are available on both platforms. Any help with any of it would be great. Too bad there isn't a full tutorial on making a simple math library that you then use in an Android and ios app.

How to access a C# library from C++ using Mono on embedded linux?

I am going to access a C# library from C++ in a embedded Linux system. The library is going to be made using Mono.
I have a large code base written in C++ running on a embedded Linux.
Because the C++ is unmanaged I can't just make calls to the library.
I was thinking about making a wrapper layer on top of the library and then using IPC calls.
I don't make the C# library myself, so maybe I need some kind of wrapper layer.
Any ideas will be appreciated.
You need to link to the mono runtime (embed it), and then call it. See http://www.mono-project.com/Embedding_Mono

Trying to use the ProtectedData Class in C++

I am trying to implement the ProtectedData Class in C++ but are having some issues with compilation. My first error comes from not being able to use #using <System.Security.dll>. The error is that IntelliSense: "#using" requires C++/CLI to be enabled, however when I go into my project settings and set the common language runtime support to /clr, In my project I do not see my sytax errors getting corrected anymore. I then thought ok this must have fixed all the issues but then i go to compile and then I receive and error that '/clr' and '/Gm' command-line options are incompatible. So i go to look at this and I am not sure what to put to correct my problem. Is there any way I can use the ProtectedData Class without having to go through the different config process?
I am using Microsoft Visual C++ 2010 Express.
The link to the ProtectedData Class is here: http://msdn.microsoft.com/en-us/library/system.security.cryptography.protecteddata.aspx?cs-save-lang=1&cs-lang=cpp#code-snippet-2
Thank you for your time.
You could use Microsoft Visual C# 2010 Express instead. C++/CLI is best used only as a .NET/native bridging framework, and only when other methods of interoperation aren't suitable (such P/Invoke).
If you decide to use C++, you do need to use the /CLR switch. Although you can tweak a C++ project into a C++/CLI project, it's best to start fresh with the one of the CLR project templates.
Two ways to indicate that you want to use an external .NET assembly:
specify it with #using, or
add it to the References section of the project properties
Since you mentioned Intellisense, you'll find that it's not supported in C++/CLI code.

In what programming language is GoogleTalk application developed?

Does any one know in which programming language were Google Talk application developed.
yes am asking about the windows client application. :)
http://www.google.ro/talk/
googletalk.exe -> Compiled with: Microsoft Visual C++ 7.0 [Debug]
gtalkwmp1.dll -> Complied with: Microsoft Visual C++ 7.1 DLL
So GTalk is written in C++
You'll find http://www.peid.info/ pretty useful for this kind of stuff.
According to Steve Yegge, Google is using C++, Java, Python, and JavaScript. So the answer would be C++ :)
Google released an open source library for Google Talk called libjingle, which is written in C++. So logically, the Windows client would probably be C++ too.
Do you mean the client side, or the server side ? The talk protocol is Jingle and libraries are available in C/C++/Java.
Ideally the protocol would be language independent, and consequently both sides (client and server) would not be constrained to a particular language.
According to this Google-talk Wiki, it uses libjingle which they've implemented in C++. However, a company as big as Google is big enough to develop their own in-house compilers with support for whatever dialect they prefer. This would be a sensible thing to do for Google, to have something which could be compiled for every operating system that they want to support.
I don't have Google-talk but I checked the binaties of Picasa, another Google application. It mentions the Visual C++ Runtime Library so I guess I'm wrong and Google is probably just using Visual Studio instead.
In general, C++ is a platform-independant language, making it the most appropriate language to use to write new projects. However, depending on the desired functionality, you do need the proper libraries for all the platforms you want to support and make sure they all expose the same methods.
Java generates platform-independant binaries. As such, it's more powerful than C++ but those binaries depend on the Java Virtual Machine, which reduces their performance. This makes them less qualified.
There are plenty of other languages that could have been used but Google is most likely using a language that supports as many platforms as possible. (Including the future Google Chrome Operating System.)

Resources