I know Android lets dev to use .so for native code. Is there a way to do the same in cocos creator? The native library has c and c++. I have access to them so building them to a different format that cocos creator use will not be an issue, but that's all I can do with those native code. I can't copy/share which means I can only build those native code to certain format that can be used in cocos creator, and the output lib has to be of course binary code.
Related
Is there a way to use a C# library in Windows Store app, so that is doesn't produce a separate DLL, but its modules are included in main assembly?
You can use ILMerge by Microsoft - download.
I have a library written by C language, which contains some complicated mathematical algorithm. I'm not going to porting it to C# language, can I use it in my WP8 project? and How?
You can use C library in C++ libraries, specifically, inside C++ Windows Phone Runtime Component. You can then use that proxy/wrapper library straight from C#.
C# cannot access native methods without such proxy. You will have to think about data types translation and what you want to do with it exactly.
Native code on Windows Phone 8
We're moving to Windows Phone 8. But since many good libraries out there are in pure C. So what is the best way for Windows Phone C# application to consume this C library?
Place C code in WP Static library. Then reference it from WP Runtime
component
Place C code in WP Runtime component
What is the best practice ?
There isn't any real difference between the two approaches. A static library is nothing but a collection of .obj files, the exact same kind of .obj files that you'll get from approach #2. After the linker is done, there won't be any difference in the result.
That's when everything is perfect, an ideal that can be very difficult to achieve when you use open source C code. An advantage of a static .lib is that it improves build time, not having to re-generate the .obj files. But that's also their disadvantage, you'll shoot your foot if you use a .lib that was created by somebody else and he didn't use the same compiler version or compile options. The simplest example of such a trap is building your Debug version and the .lib was built for Release. Or if it uses winapi functions that are verboten in a Phone app, pretty common. So #3 is the best way to avoid problems, build the .lib yourself so you can control all the compile and link settings. Do beware however that it can be very difficult to get open source C code to build, it often comes with a very extensive configuration script, designed to deal with the differences between the many architecture and Unix variants.
I need to wrap a C library with Adobe AIR native extension API (ANE).The extension should target IOS and Android.First,I realize that for Android , if not using NDK API , I have to port that library to Java.But my main concern is IO operations like read and write to file system which exist in that library.I read through the ANE development manual but found no note on restriction of native lib communication with the host file system.Does it mean my native library is allowed to read and write files inside AIR extension freely ?
You definitely can access the filesystem to read and write files.
The only thing of note here is that you'll only have access to the parts of the filesystem that the application has permission to access. So you basically just have to obey any restrictions that a normal native application developer has.
I've used the java.io.File to access files in ANE's no problem.
Based on what I see scanning through that too it reads to me like it's doable but I can't confirm 100%
When you create a native extension, you provide the following:
ActionScript extension classes that you define. These ActionScript classes use the built-in ActionScript APIs that allow access to and data exchange with native code.
A native code implementation. The native code uses native code APIs that allow access to and data exchange with your ActionScript extension classes.
sounds to me like you have whatever native API available for writing your native extension in and they're just providing a "bridge" or "data tunnel" to communicate between the actionscript code and the native extension. They have one import from the android library for log in their example as well so I imagine you can use whatever objects/methods are available for each platform, I suppose the only real question is then what access the native process has on the file system for each platform. If you don't get an answer please try and post back (if I have time I'll do the same).
Is there any way to use the library of other language in Action Script 3 ?
For C/C++
I learned that we can use Alchemy: http://labs.adobe.com/technologies/alchemy/
But for other languages (here I mean Ruby or Java), can I use their libs via AS3 ?
Alchemy is a cross-compiler from LLVM to ABC, if the language you are interested in can compile to LLVM, then, in theory, you can compile to ABC. So, Alchemy supports (with some tweaks) also C# or Java (but you will have to spend some time getting them to work together, there's no out of the box solution).
AIR (which is a desktop variant of Flash) can use something called "NativeProcess" which means that granted the operating system can execute the code in the library, then you can do so by creating a new process that calls the function from the library you need.
In AIR, again, there's a new feature called ANE (AIR Native Extensions) - this allows you to bind AIR more tightly to the native code. But, it doesn't need to be native as in object files only, it should be something the underlying system can execute. But I have to confess, I never tried creating any such extension, so my knowledge of it is theoretical.
No you can not use Ruby or Java code/libraries in Flash. Alchemy only allows you to use C and C++ libraries. The only way is to port those libraries to ActionScript, or maybe the library you want to use has already been ported to AS3.
It is also possible that there is something similar in AS3. You could ask another question here or on an Flash forum if anyone knows if the library you need has an equivalent in flash.