sieler2
December 29, 2017, 7:59pm
1
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
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
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.
sieler2
February 2, 2018, 11:05pm
4
@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
rob
February 4, 2018, 1:46am
5
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
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
thanks again, Stan
rob
February 4, 2018, 4:09pm
7
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
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.
sieler2
February 2, 2018, 11:05pm
10
@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
rob
February 4, 2018, 1:46am
11
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
sieler2
February 4, 2018, 6:15am
12
Thanks…surprising, since I haven’t had to use XCode for any other Corona app
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
thanks again, Stan
rob
February 4, 2018, 4:09pm
13
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