H
htcdesiree
Neues Mitglied
- 0
Hallo,
Wie kann ich ein C Programm von meiner Linux Kiste auf das Android Handy bringen???
Ich habe jetzt schon zig Anleitungen durch angefanngen von agcc bis hin zum ndk... Nichts funktioniert.
Im Moment probier ich es mit folgendem Makefile:
EDIT:
Die Fehler bezüglich den fehlenden Libs etc. bekomme ich bei agcc auch.
Kann mir wer weiterhelfen? Ich find den Fehler nicht...
Wie kann ich ein C Programm von meiner Linux Kiste auf das Android Handy bringen???
Ich habe jetzt schon zig Anleitungen durch angefanngen von agcc bis hin zum ndk... Nichts funktioniert.
Im Moment probier ich es mit folgendem Makefile:
Das Ergebnis ist dann:# Dynamic hello example for Android NDK
# motz diary: Dynamically linked "Hello, world!" for Android
NDK = /usr/src/android-ndk-1.5_r1
NDK_ARCH = $(NDK)/build/platforms/android-1.5/arch-arm
NDK_COMP = $(NDK)/build/prebuilt/linux-x86/arm-eabi-4.2.1
ifneq ($(shell uname -m),armv6l)
# When not compiling on the phone use cross compiler
CROSS_COMPILE = /opt/android/ndk/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin/arm-eabi-gcc
endif
CC = $(CROSS_COMPILE)gcc
LD = $(CROSS_COMPILE)ld
# bionic setbuf() segfaults, do not use
CFLAGS += -D'setbuf(a,b)='
CFLAGS += -DUSE_FPM
CFLAGS += -I$(NDK_ARCH)/usr/include
%o: %c Makefile
$(CC) $(CFLAGS) -c $<
all: hello-gcc hello-ld
hello-gcc: hello.o fpm.o
strace -o bla.txt -s 512 -f $(CC) -o $@ \
-nostartfiles -nodefaultlibs -nostdlib \
-lc -lm -lgcc -L$(NDK_ARCH)/usr/lib \
-Wl,-rpath-link -Wl,$(NDK_ARCH)/usr/lib \
-Wl,--dynamic-linker -Wl,/system/bin/linker \
$(NDK_ARCH)/usr/lib/crtbegin_dynamic.o \
$^ \
$(NDK_ARCH)/usr/lib/crtend_android.o
hello-ld: hello.o fpm.o
$(LD) -o $@ \
-lc -lm -lgcc -L$(NDK_ARCH)/usr/lib \
-L$(NDK_COMP)/lib/gcc/arm-eabi/4.2.1 \
-rpath-link $(NDK_ARCH)/usr/lib \
--dynamic-linker /system/bin/linker \
$(NDK_ARCH)/usr/lib/crtbegin_dynamic.o \
$^ \
$(NDK_ARCH)/usr/lib/crtend_android.o
clean:
rm -f hello-ld hello-gcc
rm -f *.o
rm -f *~
/opt/android/ndk/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin/arm-eabi-gcc gcc -D'setbuf(a,b)=' -DUSE_FPM -I/usr/src/android-ndk-1.5_r1/build/platforms/android-1.5/arch-arm/usr/include -c hello.c
arm-eabi-gcc: gcc: No such file or directory
In file included from hello.c:1:
/opt/android/ndk/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin/../lib/gcc/arm-eabi/4.4.0/include-fixed/stdio.h:50:23: error: sys/cdefs.h: No such file or directory
/opt/android/ndk/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin/../lib/gcc/arm-eabi/4.4.0/include-fixed/stdio.h:51:24: error: sys/_types.h: No such file or directory
In file included from hello.c:1:
/opt/android/ndk/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin/../lib/gcc/arm-eabi/4.4.0/include-fixed/stdio.h:163: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'extern'
/opt/android/ndk/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin/../lib/gcc/arm-eabi/4.4.0/include-fixed/stdio.h:232: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__BEGIN_DECLS'
/opt/android/ndk/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin/../lib/gcc/arm-eabi/4.4.0/include-fixed/stdio.h:382: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__BEGIN_DECLS'
/opt/android/ndk/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin/../lib/gcc/arm-eabi/4.4.0/include-fixed/stdio.h:393: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'static'
hello.c:2:18: error: time.h: No such file or directory
hello.c: In function 'main':
hello.c:10: error: 'time_t' undeclared (first use in this function)
hello.c:10: error: (Each undeclared identifier is reported only once
hello.c:10: error: for each function it appears in.)
hello.c:10: error: expected ';' before 't'
hello.c:14: error: 't' undeclared (first use in this function)
make: *** [hello.o] Fehler 1
EDIT:
root@raw:/opt/android/shellfiles# ./agcc -o main main.c
arm-eabi-gcc: /opt/android/ndk/toolchains/arm-eabi-4.4.0/out/target/product/generic/obj/lib/crtend_android.o: No such file or directory
arm-eabi-gcc: /opt/android/ndk/toolchains/arm-eabi-4.4.0/out/target/product/generic/obj/lib/crtbegin_dynamic.o: No such file or directory
arm-eabi-gcc: /opt/android/ndk/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/lib/gcc/arm-eabi/4.2.1/interwork/libgcc.a: No such file or directory
cc1: error: /opt/android/ndk/toolchains/arm-eabi-4.4.0/system/core/include/arch/linux-arm/AndroidConfig.h: No such file or directory
main.c: In function 'main':
main.c:4: warning: incompatible implicit declaration of built-in function 'printf'
Die Fehler bezüglich den fehlenden Libs etc. bekomme ich bei agcc auch.
Kann mir wer weiterhelfen? Ich find den Fehler nicht...
Zuletzt bearbeitet: