arm-linux-androideabi-gcc compiler doesn't work with -include /cygdrive... paths

504 views
Skip to first unread message

Lyle Zumbrun

unread,
May 18, 2011, 7:02:43 PM5/18/11
to android-ndk
I am trying to compile Linphone under Cygwin using the arm-linux-
androideabi-gcc compiler, but am having trouble with the -include
command line option with a /cygdrive... path. A simplified test case
follows showing that the the -include option can be used with the
native compiler to include test.h either from the current directory
without specifying a path, or by specifying the entire path starting
with /cygdrive/... With the cross-compiler, -include works with the
header file in the current directory or with a relative path, but not
with a path starting with /cygdrive/...

In other words, it seems that the cross-compiler's -include option
doesn't work in some cases where the native compiler does. What am I
doing wrong? Do I have the wrong compiler? Thanks for any
suggestions:


# Native compiler, just shows that gets an error if compiled without
test.h. The cross-complier does too.
$ /cygdrive/c/android-ndk-r5b/toolchains/arm-linux-androideabi-4.4.3/
prebuilt/windows/bin/arm-linux-androideabi-gcc test.c
test.c: In function 'main':
test.c:7: error: 'MY_STRING' undeclared (first use in this function)
test.c:7: error: (Each undeclared identifier is reported only once
test.c:7: error: for each function it appears in.)


# Native compiler works with test.h in the current directory
$ gcc -include test.h test.c


# Native compiler: works with path to test.h
$ gcc -include /cygdrive/c/android-ndk-r5b/test.h test.c


# Cross-compiler, gets to the link step if don't use a path to test.h
$ /cygdrive/c/android-ndk-r5b/toolchains/arm-linux-androideabi-4.4.3/
prebuilt/windows/bin/arm-linux-androideabi-gcc -include test.h test.c
C:/android-ndk-r5b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/
windows/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-
linux-androideabi/bin/ld.exe: crtbegin_dynamic.o: No such file: No
such file or directory
collect2: ld returned 1 exit status


# Cross-compiler, gets to the link step with a relative path to test.h
$ /cygdrive/c/android-ndk-r5b/toolchains/arm-linux-androideabi-4.4.3/
prebuilt/windows/bin/arm-linux-androideabi-gcc -include ../android-ndk-
r5b/test.h test.c
C:/android-ndk-r5b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/
windows/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-
linux-androideabi/bin/ld.exe: crtbegin_dynamic.o: No such file: No
such file or directory
collect2: ld returned 1 exit status


# Cross-compiler, can't find test.h using -include option with path
starting with /cygdrive/...
$ /cygdrive/c/android-ndk-r5b/toolchains/arm-linux-androideabi-4.4.3/
prebuilt/windows/bin/arm-linux-androideabi-gcc -include /cygdrive/c/
android-ndk-r5b/test.h test.c
cc1.exe: error: /cygdrive/c/android-ndk-r5b/test.h: No such file or
directory
test.c: In function 'main':
test.c:7: error: 'MY_STRING' undeclared (first use in this function)
test.c:7: error: (Each undeclared identifier is reported only once
test.c:7: error: for each function it appears in.)

Chris Stratton

unread,
May 18, 2011, 8:08:02 PM5/18/11
to andro...@googlegroups.com
I'm not familiar with -include as a gcc option, but one gotcha I remember from cygwin is that a double slash in a path has special meaning. On linux (and probably a lot else) its the same as s single slash, so its not uncommon to have scripts which accidentally create a double slash when constructing a path from multiple variables, and so work everywhere but cygwin.

mingw android

unread,
May 19, 2011, 3:54:02 AM5/19/11
to andro...@googlegroups.com

What you refer to as native (cygwin) is far from it.

The windows ndk toolchain is (thankfully) native to windows, so it doesnt go through the cygwin translation layer which would translate /cygdrive paths.

Just make sure it uses windows paths and it should work (either use single / for dir seps or double \). How are you building this code? Are you using ndk-build? If so then that is responsible for doing these path translations for the cygwin based make system and it should work fine.


--
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.

Reply all
Reply to author
Forward
0 new messages