Android NDK and Makefile for Objective-C

113 views
Skip to first unread message

Maxime Biais

unread,
Mar 5, 2010, 11:06:34 AM3/5/10
to android-objc
Hi,

First, thanks for the work you have done on porting objective-c to
android.

I just patched and compiled gcc with objc support. I wrote a
HelloWorld.m and compiled it for Android (hooray !). I just had to add
"-x objective-c" to LOCAL_CFLAGS in my Android.mk and rename
HelloWorld.m in HelloWorld.c

Now, I'm trying to compile a real life project (GNUStep base lib, that
includes Foundation). I was wondering if you already dug into the
android-ndk makefiles to recognize .m extensions and compile them
using "-x objective-c" ?

Philippe Hausler

unread,
Mar 5, 2010, 11:13:05 AM3/5/10
to android-...@googlegroups.com, Maxime Biais

I have actually been working on a slightly more Apple-esque version of foundation than GNUStep (and more impressively UIKit with a JNI based encapsulation). But to your question no I have not been altering the android .mk files, as a matter of fact I have been avoiding them in lieu of working entirely in Xcode. The GCC target should detect .m versus .c by default, however that does not eliminate the need for -lobjc (since that is a requirement for binding to the runtime as a library and not part of the actual language).

Im very glad that the patch works as expected. Right now I am working on some other projects for a bit, but I will be returning to my internal builds of the Foundation/UIKit shortly which will most likely spur some more commits into the compiler code-base.

Have you had a chance to test any further other than just HelloWorld type stuff?

Maxime Biais

unread,
Mar 5, 2010, 11:26:21 AM3/5/10
to Philippe Hausler, android-...@googlegroups.com
On Fri, Mar 5, 2010 at 5:13 PM, Philippe Hausler <phau...@gmail.com> wrote:
>
> On Mar 5, 2010, at 10:06 AM, Maxime Biais wrote:
>
>> Hi,
>>
>> First, thanks for the work you have done on porting objective-c to
>> android.
>>
>> I just patched and compiled gcc with objc support. I wrote a
>> HelloWorld.m and compiled it for Android (hooray !). I just had to add
>> "-x objective-c" to LOCAL_CFLAGS in my Android.mk and rename
>> HelloWorld.m in HelloWorld.c
>>
>> Now, I'm trying to compile a real life project (GNUStep base lib, that
>> includes Foundation). I was wondering if you already dug into the
>> android-ndk makefiles to recognize .m extensions and compile them
>> using "-x objective-c" ?
>
> I have actually been working on a slightly more Apple-esque version of foundation than GNUStep (and more impressively UIKit with a JNI based encapsulation). But to your question no I have not been altering the android .mk files, as a matter of fact I have been avoiding them in lieu of working entirely in Xcode. The GCC target should detect .m versus .c by default, however that does not eliminate the need for -lobjc (since that is a requirement for binding to the runtime as a library and not part of the actual language).
>

OK, I'm a XCode beginner and I really don't know how to start to
create an empty project and "change" the compiler using XCode. I will
ask Google.

> Im very glad that the patch works as expected. Right now I am working on some other projects for a bit, but I will be returning to my internal builds of the Foundation/UIKit shortly which will most likely spur some more commits into the compiler code-base.
>

Great news !

> Have you had a chance to test any further other than just HelloWorld type stuff?
>

Not yet. My first goal is to port some iPhone applications (95%
OpenGL) to Android with the minimum of code modification (I think of
activity creation, touch events, etc...).

--
Maxime Biais

Maxime Biais

unread,
Mar 5, 2010, 1:07:08 PM3/5/10
to Philippe Hausler, android-...@googlegroups.com
On Fri, Mar 5, 2010 at 5:13 PM, Philippe Hausler <phau...@gmail.com> wrote:
>
> I have actually been working on a slightly more Apple-esque version of foundation than GNUStep (and more impressively UIKit with a JNI based encapsulation). But to your question no I have not been altering the android .mk files, as a matter of fact I have been avoiding them in lieu of working entirely in Xcode. The GCC target should detect .m versus .c by default, however that does not eliminate the need for -lobjc (since that is a requirement for binding to the runtime as a library and not part of the actual language).
>

Ok, I just patched android-ndk/build/core/definitions.mk and
android-ndk/build/core/build-binary.mk to make it works with .m files.

--
Maxime Biais

Vladimir Boichentsov

unread,
Jan 3, 2013, 12:53:34 PM1/3/13
to android-...@googlegroups.com, Philippe Hausler
Hi

I'm trying build objc simple HelloWorld .m files with latest NDK r8d.
Now my re-builded NDK has supporting for objC but still can't compile .m files.

May be you know, what I should patch in definitions.mk?

Many Thanks!
Reply all
Reply to author
Forward
0 new messages