undefined reference to `__errno_location'

3,363 views
Skip to first unread message

Android2011

unread,
May 2, 2011, 1:32:35 AM5/2/11
to android-ndk
Hello sir,

I am compileing application for ndk, i am getting error "undefined
reference to `__errno_location'".

Any any one please let me know that is missing?



thanks in advance...

mic _

unread,
May 3, 2011, 1:10:15 PM5/3/11
to andro...@googlegroups.com
Try replacing  __errno_location  with  &errno

You can find errno.h in platforms/android-#/arch-arm/usr/include

/Michael


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
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.


Android2011

unread,
May 5, 2011, 7:57:03 AM5/5/11
to android-ndk
thanks mic,

actually it is errno its not __errno_location in code or c file. but
compilation gives error of "undefined reference to
`__errno_location'", i have searched it in errno.h too but no
succcess.
I am tracing down how it gives error of undefined reference to
`__errno_location' even though its errno. do you know this?


do you know which lib should contain the defination of the
"__errno_location", i have found it in libc.so on some platform. is it
correct?
> >http://groups.google.com/group/android-ndk?hl=en.- Hide quoted text -
>
> - Show quoted text -

mic _

unread,
May 5, 2011, 11:09:58 AM5/5/11
to andro...@googlegroups.com
This works for me:

volatile int * errnoLoc = &errno;

Are you sure you're not linking against some library or object file(s) that were compiled with some other toolchain and are referencing __errno_location?

/Michael

Tim Mensch

unread,
May 9, 2011, 12:23:15 PM5/9/11
to andro...@googlegroups.com
On 5/5/2011 5:57 AM, Android2011 wrote:
> actually it is errno its not __errno_location in code or c file. but
> compilation gives error of "undefined reference to
> `__errno_location'", i have searched it in errno.h too but no
> succcess.

You probably have an include file somewhere that #defines errno to
__errno_location. Search your include tree for such a define. Check
every folder you're asking it to include.

Or as Michael suggested, maybe you're linking with something built
against a different tool chain; that just won't work.

Tim

Chris Stratton

unread,
May 9, 2011, 1:42:39 PM5/9/11
to andro...@googlegroups.com
> actually it is errno its not __errno_location in code or c file. but
> compilation gives error of "undefined reference to
> `__errno_location'", i have searched it in errno.h too but no
> succcess.

Use ndk-build V=1 to see the commands being issued by the build system

Or just use grep -r on directories potentially containing the .o files to figure out which one has a dependency on that symbol.

It does sound like the wrong toolchain / wrong libc class of problem - grepping /usr/lib on my ubuntu box finds lots of occurrences, while grepping /system/lib on my android device finds none, so I suspect you may have something linked against glibc rather than bionic.


BTR Naidu

unread,
May 2, 2012, 8:54:40 AM5/2/12
to andro...@googlegroups.com
I guess its more of linker issue than pre-processor...


On Tuesday, 3 May 2011 19:10:15 UTC+2, mic wrote:
Try replacing  __errno_location  with  &errno

You can find errno.h in platforms/android-#/arch-arm/usr/include

/Michael

On Mon, May 2, 2011 at 7:32 AM, Android2011 <snjag...@gmail.com> wrote:
Hello sir,

I am compileing application for ndk, i am getting error "undefined
reference to `__errno_location'".

Any any one please let me know that is missing?



thanks in advance...

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk+unsubscribe@googlegroups.com.

David Turner

unread,
May 3, 2012, 8:26:32 AM5/3/12
to andro...@googlegroups.com
On Mon, May 2, 2011 at 7:32 AM, Android2011 <snjag...@gmail.com> wrote:
Hello sir,

I am compileing application for ndk, i am getting error "undefined
reference to `__errno_location'".


__errno_location is a GLibc-specific symbol, not supported by Android. This means your binary has been generated with the wrong toolchain.
You should really give more details about what you're doing, and how if you want any useful answer on this forum.
 
Any any one please let me know that is missing?



thanks in advance...
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages