Can I use C on Android with Corona Native?

Hi,

I’m just learning about Corona Native …

https://docs.coronalabs.com/native/android/index.html#native-apis

says: “Android development is done using the Java programming language”

but, the similar page for Corona Native on iOS talks about using C.

Can I use C on Android?  That’s the *whole purpose* I wanted to use Corona SDK + Native …

so I could develop with a mixture of C and Lua for both iOS and Android :slight_smile:

On neither platform do I want to use C to access platform specific OS stuff / APIs …

it’s just code that does POSIX file system things (e.g, “open”, “write”), and then generic C things

(e.g., compression, encryption, image manipulation given a .jpg file).

(I can do such generic / POSIX C things on iOS using XCode … successfully mixing C with

Objective C … so I know how useful this can be … to have native-speed C code for the bulk of

my code, and Objective C or Lua or whatever for my GUI / platform-specific code.)

thanks,

Stan

Yes.

I’m attaching my OLD math2d plugin code (just the c) file so you can see basically what coding in native with C will look like.

Note: This code is a bit dated, but still pretty close to current methodology.

@roaminggamer … thanks for the info!  Sorry for the delay, it came in while I was undergoing sedation dentistry, and I missed a

number of emails for a couple of days.

The math2d.c compiles just fine (I compiled in 64 bit mode)

(I.e., yes, I know simply compiling from my Mac command line will generate a .o that probably isn’t usable by Corona, but it is a usable

technique to ensure the file compiles correctly … and in this case, there appears to be little or no problem in either 32 or 64 bit mode)

(Said differently, I presume Corona Native somehow compiles it for the correct architecture, and I presume it’s a 64 bit mode)

Anyway, I was hoping to see the Corona glue/setup/config/build/whatever that I need to integrate the C code.

thanks again,

Stan 

sieler@allegro.com

You would include the C file in your Xcode project like any other .m or .mm file.  If you can make a .a file then you can include it as a library.

Rob

Thanks…surprising, since I haven’t had to use XCode for any other Corona app :frowning:

I.e., I was hoping for an answer like:

  In build.settings, use:    c_library {file = mycstuff.a)

Looks like it’s going to be a long learning curve :slight_smile:

thanks again, Stan

Corona Simulator builds cannot use native C code or object libraries. It can use Plugins but those plugins have to be made using  Corona Native (i.e. Xcode builds). Plugins can either be submitted to the Marketplace for the community, or you can pay for self-hosted plugins that let you use private plugins with simulator builds.

To help you understand Corona Native, you might find this tutorial helpful:

https://docs.coronalabs.com/tutorial/native/iosIntro/index.html

Rob

Yes.

I’m attaching my OLD math2d plugin code (just the c) file so you can see basically what coding in native with C will look like.

Note: This code is a bit dated, but still pretty close to current methodology.

@roaminggamer … thanks for the info!  Sorry for the delay, it came in while I was undergoing sedation dentistry, and I missed a

number of emails for a couple of days.

The math2d.c compiles just fine (I compiled in 64 bit mode)

(I.e., yes, I know simply compiling from my Mac command line will generate a .o that probably isn’t usable by Corona, but it is a usable

technique to ensure the file compiles correctly … and in this case, there appears to be little or no problem in either 32 or 64 bit mode)

(Said differently, I presume Corona Native somehow compiles it for the correct architecture, and I presume it’s a 64 bit mode)

Anyway, I was hoping to see the Corona glue/setup/config/build/whatever that I need to integrate the C code.

thanks again,

Stan 

sieler@allegro.com

You would include the C file in your Xcode project like any other .m or .mm file.  If you can make a .a file then you can include it as a library.

Rob

Thanks…surprising, since I haven’t had to use XCode for any other Corona app :frowning:

I.e., I was hoping for an answer like:

  In build.settings, use:    c_library {file = mycstuff.a)

Looks like it’s going to be a long learning curve :slight_smile:

thanks again, Stan

Corona Simulator builds cannot use native C code or object libraries. It can use Plugins but those plugins have to be made using  Corona Native (i.e. Xcode builds). Plugins can either be submitted to the Marketplace for the community, or you can pay for self-hosted plugins that let you use private plugins with simulator builds.

To help you understand Corona Native, you might find this tutorial helpful:

https://docs.coronalabs.com/tutorial/native/iosIntro/index.html

Rob