On 06/06/13 19:29, Anil wrote:
>
> I am not using Android.mk and Application.mk files. I am running the
> standalone toolchain from linux shell like the below.
>
> arm-linux-androideabi-gcc -g -Wall -Wpointer-arith -Wreturn-type
> -Wstrict-prototypes -I../include -I/usr/include -D_REENTRANT -fPIC -c
> text_file.c
>
> The above command is able to compile and create object file.
>
> But when it is linking, i am getting the below errors.
>
> /home/user/android-ndk-r8e/standalone-toolchain-api14/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld:
> test_file.o: in function finally:hashtbtest.c:45: error: undefined
> reference to 'stderr'
> /home/user/android-ndk-r8e/standalone-toolchain-api14/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld:
> test_file.o: in function main:hashtbtest.c:94: error: undefined
> reference to 'stdin'
Perhaps you should try
arm-linux-androideabi-g++ for c++ code?
You need to decide which std library implementation you want to use, in
the NDK directory is sources/cxx-stl/ which contains various std
libraries. I recommend gnu-libstdc++.
You'll want to add the appropriate include path with -I (I don't know
which one it is picking up by default), the library search path with -L
and the library with -l.
Something like:
arm-linux-androideabi-g++
-I/path/to/ndk/sources/cxx-stl/gnu-libstdc++/4.6/include
-I/path/to/ndk/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include
-L/path/to/ndk/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi
-lgnustl_shared
Ben