How to run a *.o file in Android

172 views
Skip to first unread message

perumal316

unread,
Apr 23, 2012, 6:08:17 AM4/23/12
to andro...@googlegroups.com
Hi All,

I currently compiled  a set of source code in C in Linux and the output is a *.o file which is a object file. This supposedly does image compression. Now I want to use/test this in Android.

Is this possible? I have only tried NDK examples from the Android NDK developer side. Have not came across any reference on how this can be done.

Thanks In Advance,
Perumal

Mārtiņš Možeiko

unread,
Apr 23, 2012, 1:31:46 PM4/23/12
to andro...@googlegroups.com
You can not do that. You must compile source file with Android NDK
toolchain. Only then you can use resulting .o file.

--
Mārtiņš Možeiko

> --
> You received this message because you are subscribed to the Google Groups
> "android-ndk" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/android-ndk/-/dXmFpYIhe_MJ.
> To post to this group, send email to andro...@googlegroups.com.
> To unsubscribe from this group, send email to
> android-ndk...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/android-ndk?hl=en.

chinlin@tw-roc

unread,
Apr 24, 2012, 1:56:52 PM4/24/12
to andro...@googlegroups.com
if you are compiling your code in linux with standard ARM toolchains with compatible machine code (ex: ARMv5 or ARMv7(a)), then you can do so.

perumal316於 2012年4月23日星期一UTC+8下午6時08分17秒寫道:

Chris Stratton

unread,
Apr 24, 2012, 2:57:50 PM4/24/12
to andro...@googlegroups.com
On Tuesday, April 24, 2012 1:56:52 PM UTC-4, chinlin@tw-roc wrote:
if you are compiling your code in linux with standard ARM toolchains with compatible machine code (ex: ARMv5 or ARMv7(a)), then you can do so.

Yes, in theory, provided that your code has no dependencies which are not included.  Note that it will be a little hard for such code to interact with the outside world, unless it was built against headers for an abi-compatible linux kernel, or unless you've take measured to be sure it will be compatible with the linkage of android's libraries. 

At any rate, before you can execute even compatible code with satisfied dependencies, it will have to be turned into a shared library (.so) to be called by means of jni from an android app, or (currently workable but unsupported), a linux executable.  A .o file is typically the output of a compiler - what you need is the output of the next step, the linker.

The most compatible way to generate this is to start the build process over from the beginning using the android ndk toolchain, ideally by grafting your code into the framework of an ndk library and using the ndk build system (see the ndk examples).  Second preference to using the scripts which generate a stand alone toolchain for the build system of existing projects being ported, third to reverse engineering the flags used by the ndk build system and putting those in your existing project build system - and dead, dead last, to trying to persuade the output of a non-android gcc to work on the device.
Reply all
Reply to author
Forward
0 new messages