Compiling C files in non-ndk mode for Android

Source: Internet
Author: User

The day before yesterday, I completed the ndk development environment and made JNI
Development and testing. Because ndk development is not used in the actual project, I don't know what to do next. Think of the
The interaction program of command is compiled in the android source code using Android. mk. I always wanted to write the make file and compile it independently from the android source code.
C/C ++.

That's the beginning! The cross compiler uses the ndk.

Paste makefile first.

View plain
Copy to clipboard
Print
?
  1. Cc =/work/tool/android-ndk-r5/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin/ARM-Eabi-gcc
  2. Pre-Path =/work/tool/android-ndk-r5/platforms/Android-8/arch-arm/usr
  3. Lib = $ (pre-path)/lib
  4. Ic = $ (pre-path)/include
  5. Extra_objs: = $ (pre-path)/lib/crtend_android.o $ (pre-path)/lib/crtbegin_static.o
  6. Ldflags + =-nostdlib
  7. Ldflags + =-LC-LDL-bdynamic-wl,-dynamic-linker,/system/bin/linker
  8. Shard: shard. o
  9. $ (CC) $ (ldflags) $ (extra_objs)-g-O0-wall-STD = c99-I $ (IC)-L $ (LIB)-O shard. o
  10. Shard. O: shard. c
  11. $ (CC)-I $ (IC)-L $ (LIB)-C shard. c
  12. . Phony: clean
  13. Clean:
  14. Rm shard. o

Cc =/work/tool/android-ndk-r5/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin/ARM-Eabi-GCC <br/> pre-Path =/work/tool/android-ndk-r5/platforms /Android-8/arch-arm/usr <br/> lib =$ (pre-path) /lib <br/> Ic = $ (pre-path)/include <br/> extra_objs: = $ (pre-path)/lib/crtend_android.o $ (pre-path) /lib/crtbegin_static.o <br/> ldflags + =-nostdlib <br/> ldflags + =-LC-LDL-bdynamic-wl,-dynamic-linker, /system/bin/linker <br/> shard: shard. O <br/> $ (CC) $ (ldflags) $ (extra_objs)-g-O0-wall-STD = c99-I $ (IC)-L $ (LIB) -O shard. O <br/> shard. o: shard. c <br/> $ (CC)-I $ (IC)-L $ (LIB)-C shard. c <br/>. phony: Clean <br/> clean: <br/> RM shard. O

C file is very simple

View plain
Copy to clipboard
Print
?
  1. # Include <string. h>

  2. # Include <stdio. h>

  3. Static
     
    Char
    * S_string =
    "I'm Hui '/N' my mailbox lzh20044178@163.com"
    ;
  4. Int
    Main ()
  5. {
  6. Printf ("% S/N"
    , S_string );
  7. Return
    0;
  8. }

# Include <string. h> <br/> # include <stdio. h> <br/> static char * s_string = "I'm Hui '/N' my mailbox lzh20044178@163.com"; <br/> int main () <br/>{< br/> printf ("% s/n", s_string); <br/> return 0; <br/>}

For more information about makefile parameters, see

Http://blog.csdn.net/lzh20044178/archive/2011/02/16/6188515.aspx
Of
2.3 Study Hard



How to Write makefile e-books


Http://pipi.googlecode.com/files/How%20to%20Write%20makefile.pdf

Run:





Makefile files are very powerful. continue learning.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.