• Eclipse IDE for C/C++ Developers+Cygwin
  • Eclipse Classic + Cygwin + CDT
  • Eclipse Classic + Cygwin + CDT + NDK ->Android so Lib
  • Show Chinese in Cygwin
  • A Project For Test


Software Version:

  Cygwin 1.7.15-1

  Eclipse IDE for C/C++ Developers(Juno)

  Eclipse Classic 4.2(Juno)

  CDT 8.1.0 for Eclipse Juno

   Android ADT 14.0.0

  Android SDK 4.0.3 (API 15)

  Android NDK r8

A.Eclipse IDE for C/C++ Developers + Cygwin

InstallEclipse IDE for C/C++ Developers.

Install Cygwin.Important step!You had better download the full package and install from local.Installing from Internet always failed and may lost file!

 The first time I install it from the Internet ,but it occured a file failure and I ignore it.Then ,holy shit!!! I spend 2 days to debug the errors result from the file failure!!So remember thatyou had better install the full package and from the local.

click the "Install" after "All".

  Install/Download from Internet.If the warning “Download Incomplete,Try again? ”comes out or it hangs on a certain progress,you can cancel it and repeat the download steps.Remember two points:

  Ⅰ.Select the same download website with the last time.

  Ⅱ.Installing type,select”Reinstall“ not”install“.(may needn't)

  Then you can continue the download progress oryou have to install from 0.

  

  I download it first for a night and then install it for a day.A whole day!

  Probably you have to set theenvionment variablePATH。PATH should include x:\cygwin\bin,x:\cygwin is your cygwin install folder。

  My is f:\cygwin.Then PATH=f:\cygwin\bin.

Restart Eclipse,File->New->C++ Project

click Finish,Build it first and then run it.


B.Eclipse Classic +Cygwin +CDT

Install Eclipse Classic 4.2.

Install CDT for Eclipse.

  Open the CDT download page,you will see the following content:

                     <pic B-1>

  The p2 software repository is the address you should access in Eclipse.Help->Install New Software,click Add button and input the address:

  click OK,then you will see the next:

    

  click next to install them.

  However,it hanged at this progress for a long time:

  Then I canceled it ,and clicked thecdt-master-8.1.0.zipof pictrue<pic B-1>,wanting to download it first and install it from local directory.

    

  click Archive to select the local zip file.

  Finally,I installed the CDT successfully.

InstallCygwin.The same with Part A.

Restart Eclipse,File ->New -> Others,and you'll see C/C++ project.


C.Eclipse Classic+Cygwin+ CDT+ NDK -> so Lib

①②③ The same with part B①②③.

Install NDK.Download the zip file and unzip itto thedestination folder.my isD:\Android\android-ndk-r8

  Edit file \cygwin\home\user_name\.bash_profile,if you can't find the file in this location,copy the cygwin\etc\skel\.bash_profile to here,add the following to the end: 

# Android NDK

  NDK=/cygdrive/<你的盘符>

  export NDK

My:

  ndk=/cygdrive/D/Android/android-ndk-r8

  export ndk

  ndk is a custom name ,you can change it.  

  Save and restart cygwin.Go to D:\Android\android-ndk-r8\samples\hello-jni\jni :

cd $ndk/samples/hello-jni/jni

  

  execute command$ndk/ndk-build

  

 Pay attention to these content of google document:

 Required development tools

  • For all development platforms, GNU Make 3.81 or later is required. Earlier versions of GNU Make might work but have not been tested.
  • A recent version of awk (either GNU Awk or Nawk) is also required.
  • For Windows,Cygwin1.7 or higher is required.The NDK willnotwork with Cygwin 1.5 installations.

 If you installed the wrong version,you may get the error of the following pictrue:

  

Create NDK Builder for Eclipse.

  Right click your project->Properties->Builders->New->Program:

  Main location:the path of file bash.exe incygwin/bin.

     working directory:the path ofcygwin/bin.

     arguments:--login -c "cd /cygdrive/d/Workspace2/hello&&$ndk/ndk-build"

      /cygdrive/d/Workspace2/hello is the absolute path of yourandroid project.

  if you can't input the argument or it can't berecognized,make sure that you have added the path of ndk (D:\Android\android-ndk-r8) to the environment PATH.

  

  In label Refresh,specific the folder needed to refresh whencompilation end.Choose libs,create it if none.

  

  About the label Build Options,use to set the folder needed tomonitor.Run the builder when the content of the folder changed.

  Specify working set... choose the folder of the c/c++ code.

  

  Completed! you can use the builder in your android project.


D.Show Chinese in Cygwin

  Right Click->Options:

  

  Set the character set to GBK,not UTF-8

E.A Project For Test

  ①Create a empty android project.

  ②Create jni folder to contain c/c++ code.

  ③Create libs folder to contain generated libs.

  ④Write your c/c++ code in jni.

   My:hello.cpp

int test() {    return 5;}

  ⑤Write your Android.mk file.you can copy it from the ndk sample project.

  ⑥Press "Ctrl+S" to save it and the lib will be generated automatically.

   

  ⑦Generate the lib which can be used in android.

    In order to use the lib in Android, you have to modify the C/C++ code tocoordinate with android.

    

  If the package name or activity name notcoordinate with c/c++ method name,UnsatisfiedLinkError may occurs.

   To use the lib:

    

更多相关文章

  1. 【Android实战开发】3G技术和Android发展简介
  2. Android(安卓)Studio安卓学习笔记(二)Android项目结构
  3. 软件工程之四则运算开发感悟与收获
  4. Android(安卓)studio中TextView改变字体的两种方式(如仿宋、隶书)
  5. Android计算器尝试
  6. Android布局颜色对应值
  7. 不是我不写博客,是我不敢写
  8. Android是怎样调用硬件加速的
  9. android studio中常用快捷键

随机推荐

  1. mac M1安装vmware虚拟机及centos8详细教
  2. 自动飞舞的气泡——JavaScript之DOM练习
  3. 不玩游戏有必要买独立显卡吗 电脑独立显
  4. 微信电脑版怎么删除备份文件?微信删除备
  5. 剪映怎么做文字围绕头像转动的动画? 剪映
  6. win10应用商店提示错误代码0x87e00017解
  7. Android与Vue的交互的方法示例
  8. Android(安卓)Too many classes in --mai
  9. 手把手--Android(安卓)Studio V3.5.2开发
  10. Only the original thread that created