ããA. 为ä»ä¹è¦å¨Linux使ç¨Eclipseå¼åC/C++ç¨åº?
ããLinuxæ¯ä¸ä¸ªä»¥C/C++å¼å为主çå¹³å°ï¼æ 论æ¯Kernelææ¯Applicationï¼ä¸»è¦é½ä½¿ç¨C/C++å¼åãä¼ ç»å¨Linuxä¸å¼åç¨åºï¼æ¯å¨æå模å¼ä¸ï¼å©ç¨viçæåç¼è¾å¨æ°åC/C++ç¨åºåçåï¼å¨Command lineä¸ä½¿ç¨gccç¼è¯ï¼è¥è¦debugï¼å使ç¨gdbã
ããè¿ç§å¼åæ¹å¼ç产å并ä¸é«ï¼è¥åªæ¯å¼åå¦ä¹ ç¨çå°ç¨åºåå½±åä¸å¤§ï¼ä½è¥è¦å¼å大å项ç®æ¶ï¼ç¨åºæ¡£æ¡ä¸ªæ°ä¼å¤ï¼éè¦ç¨projectæsolutionçæ¹å¼ç®¡çï¼ä¸debugæ¶breakpointçå å
¥ï¼åæ¥æ§è¡ï¼è§å¯åéååçï¼é½éè¦æ´å¯è§åçæ¹å¼æè½å¤å¢å ç产åï¼æéè¦çï¼ç±äºç°å¨çç¨åºè¯è¨çé常çåºå¤§ï¼åæå¤æçå½å¼åºï¼è¦ç¨åºåçè®°ææçç¨åºè¯æ³åfunctionå称ï¼å®å¨å¾å°é¾ï¼æ以è¯æ³æ示(Intellisense)çåè½å°±é常éè¦ï¼è¿äºå°±å¿
é¡»é IDEæ¥è¾¾æã
ããå¨Windowså¹³å°ä¸ï¼è¥è¦å¼åC/C++ç¨åºï¼æ们æMicrosoft Visual StudioãBorland C++ Builderå¯ç¨ï¼è¿äºé½æ¯å¾å¥½ç¨çIDEï¼ä½å¯æä»
è½å¨Windowsä¸ä½¿ç¨ï¼ä½æ¯å¨Linuxå¹³å°å¢?åºäºä»¥ä¸çç±ï¼ææ¨è使ç¨Eclipseå¼åC/C++ç¨åºï¼
ãã1. Eclipseæ¯ä¸ä¸ªç¨Javaææ°åIDEï¼å æ¤å¯è·¨å¹³å°ï¼æ以å¨LinuxåWindowså¹³å°ä¸çå¯ä½¿ç¨Eclipseï¼å¯éä½ç¨åºåçæIDEçå¦ä¹ æ²çº¿ã
ãã2. Eclipseè½ç¶ä¸»è¦æ¿æ¥å¼åJavaç¨åºï¼ä½äºå®ä¸Eclipse为ä¸ä¸ªãä¸ç¨è¯è¨ãçIDEï¼åªè¦æä¸pluginåï¼å°±å¯ä»¥å¨Eclipseå¼ååç§è¯è¨ç¨åºï¼æ以æ们åªè¦æä¸CDT(C/C++ Development Toolkit)åï¼å°±å¯ä»¥å¨Eclipseå¼åC/C++ç¨åºï¼é¤æ¤ä¹å¤ï¼ç®åç主æµç¨åºè¯è¨ï¼å¦C/C++ãC#ãJavaãPHPãPerlãPythonãRubyãRebolãJavaScriptãSQLãXMLãUMLçï¼çå¯å¨Eclipseä¸æ°åï¼æ以åªè¦çæEclipseçIDEç¯å¢ï¼å°æ¥è¥å¼åå
¶å®è¯è¨ç¨åºï¼å°±ä¸ç¨åéæ°å¦ä¹ IDEç¯å¢äºã
ãã3. æéè¦çï¼EclipseåCDTæ¯Open Sourceä¸å®å
¨å
è´¹ï¼åå¾ç¸å½å®¹æï¼äºå®ä¸Fedora 5å·²ç»å
å«EclipseåCDTäºï¼è½ç¶é¢è®¾Fedara 5å®è£
æ¶å¹¶æ²¡æå«Eclipseï¼åªè¦æå¨å¦å¤å éå³å¯ã
ããB. å¦ä½å¨Linuxä¸å®è£
EclipseåCDT?
ããi. ç±Linux Distributionå®è£
Eclipseï¼Fedora 5å°±å
å«EclipseåCDTã
ããii. æå¨å®è£
ãã1. ä¸è½½æ¡£æ¡
ããAã ä¸è½½JRE(Java Runtime Environment) ã(
http://java.sun.com/javase/downloads/index.jsp)
ããBã ä¸è½½Eclipse SDKã(
http://www.eclipse.org/downloads/)
ããCã ä¸è½½CDTã(
http://www.eclipse.org/cdt/downloads.php)
ãã2. å®è£
ããAã å®è£
JRE
ããi. [root@localhost ~]#mkdir /usr/local/java
ããii. (å°æ¡£æ¡jre-1_5_0_09-linux-i586-rpm.binä¸è½½å°/usr/local/javaç®å½ä¸)
ããiii. (è¶
级ç¨æ·æ¨¡å¼)
ãã[root@localhost ~]#su
ããiv. [root@localhost ~]#cd /usr/java
ããv. (å°æ¨æä¸è½½çæ¡£çæéæ´æ¹ä¸ºå¯æ§è¡)
ãã[root@localhost java]#chmod a+x jre-1_5_0_09-linux-i586-rpm.bin
ããvi. (å¯å¨å®è£
è¿ç¨)
ãã[root@localhost java]#./jre-1_5_0_09-linux-i586-rpm.bin
ãã(æ¤æ¶å°æ¾ç¤ºäºè¿å¶è®¸å¯åè®®ï¼ææ§æ ¼æ¾ç¤ºä¸ä¸é¡µï¼è¯»å®è®¸å¯åè®®åï¼è¾å
¥ ãyesã继ç»å®è£
ãæ¤æ¶ä¼å°è§£å缩ï¼äº§çjre-1_5_0_9-linux-i586.rpm)
ããvii. (å®è£
jre-1_5_0_9-linux-i586.rpm)
ãã[root@localhost java]#rpm âivh jre-1_5_0_9-linux-i586.rpm
ãã(æ¤æ¶ä¼å°JREè£
å¨/usr/java/jre1.5.0_09ç®å½ä¸)
ããviii. (设å®ç¯å¢åéï¼è®©Linuxè½æ¾å°JRE)
ãã[root@localhost java]#vi /etc/profile
ãã(å°ä»¥ä¸å
容å å
¥å¨æ¡£æ¡åé¢)
ãã1PATH=$PATH:/usr/java/jre1.5.0_09/bin
ãã2export JAVA_HOME=/usr/java/jre1.5.0_09
ãã3export CLASSPATH=$JAVA_HOME/lib:.
ãã(åçåï¼éæ°å¯å¨Linux)
ããix. (æµè¯Javaæ¯å¦å®è£
æå)
ãã[root@localhost ~]#java âversion
ããBã å®è£
Eclipse SDK
ããi. (å°æ¡£æ¡eclipse-SDK-3.2.1-linux-gtk.tar.gzä¸è½½å°æ¡é¢)
ããii. [root@localhost ~]#cd /usr/local
ããiii. [root@localhost local]#cp ~Desktop/eclipse-SDK-3.2.1-linux-gtk.tar.gz .
ããiv. (å°eclipse-SDK-3.2.1-linux-gtk.tar.gz解å缩)
ãã[root@localhost local]#tar âzxvf eclipse-SDK-3.2.1-linux-gtk.tar.gz
ããv. [root@localhost local]#cd eclipse
ããvi. (æ§è¡Eclipse)
ãã[root@localhost eclipse]#./eclipse
ããvii. (Select a workspace)
ãã(å°Use this as the default and do not ask againæå¾ï¼ä»¥åå°±ä¸ä¼åºç°è¿ä¸ªçªå£)
ãã(第ä¸æ¬¡æ§è¡Eclipseä¼åºç°æ¤errorï¼å 为没æä»»ä½Eclipse设å®æ¡£ï¼æ以æ æ³è¯»åï¼ç¬¬äºæ¬¡æ§è¡Eclipseå°±æ æ¤é误讯æ¯ï¼æOK继ç»ã)
ãã(Eclipse主ç»é¢)
ããCã å®è£
CDT
ããi. (å°æ¡£æ¡org.eclipse.cdt-3.1.1-linux.x86.tar.gzä¸è½½å°æ¡é¢)
ããii. [root@localhost ~]#cp ~/Desktop/org.eclipse.cdt-3.1.1-linux.x86.tar.gz .
ããiii. (å°org.eclipse.cdt-3.1.1-linux.x86.tar.gz解å缩)
ãã[root@localhost ~]#tar âzxvf org.eclipse.cdt-3.1.1-linux.x86.tar.gz
ãã(æ¡£æ¡å°è§£å°~/eclipseç®å½ä¸)
ããiv. (å®è£
CDT plugin)
ãã[root@localhost ~]cp âr eclipse/plugins/. /usr/local/eclipse/plugins/
ããv. (å¯å¨Eclipseï¼å¤äºCåC++ Projectæ¯æ)
ãã
ããC. å¦ä½å¨Eclipseä¸å¼åC/C++ç¨åº?
ããi. 建ç«Hello Word project
ãã1. 建ç«C/C++ project
ãã2. éæ©Managed Make C++ Project(è¥éæ©Managed Make C++ Projectï¼Eclipseä¼èªå¨ä¸ºæ们建ç«make fileï¼è¥éæ©Standard Make C++ Projectï¼åå¿
é¡»èªå·±åmake fileã)
ãã3. è¾å
¥Project name
ãã4. éæ©Projectç±»å(å¦æ§è¡æ¡£æLibraryï¼è¿ééæ©æ§è¡æ¡£å³å¯)
ãã5. é¢å¤ç设å®
ãã6. Open Associated Perspective?(éYes继ç»)
ãã7. 建ç«C++ Source File
ãã8. è¾å
¥C++ Source Fileæ¡£å
ãã9. è¾å
¥C++ç¨åºä»£ç
ãã10. æ§è¡ç¨åº(æ¾ç¤ºå¨ä¸æ¹çConsoleåº)
ããii. å¦ä½å¨Eclipse CDTä¸Debug C/C++ç¨åº?
ãã1. å¨Eclipseä¸Debugï¼å°±å¦åå¨ä¸è¬IDEä¸Debugä¸æ ·ï¼åªè¦å¨ç¨åºä»£ç çå·¦æ¹æ两ä¸ï¼å°±å¯å å
¥breakpointã
ãã2. å¯å¨Debug
ãã3. Debug设å®ï¼æDebugå¼å§Debug
ãã4. åæ¥æ§è¡ï¼æ¾ç¤ºåéåå
ããE. ç»è®º
ããEclipse为Linuxå¨C/C++å¼åæä¾ä¸ä¸ªå®åçIDEç¯å¢ï¼äºå®ä¸ï¼ä»¥æç¨è¿ä¼å¤IDEçç»éªï¼é¤äºVisual Studioææ¹ä¾¿å¤ï¼Eclipseç好ç¨ä¹ç´è¿½Visual Studioï¼å¹¶ä¸è¶
è¶Borland C++ BuilderåDev C++ï¼è½ç¶å®è£
ä¸æ¯è¾éº»ç¦ï¼ä½åªè¦ä¾ç
§æ¬æä»ç»ä¸æ¥ä¸æ¥ç设å®ï¼å°±ä¸å®å¯å®æEclipse设å®ï¼è¥æ³è¦å¨Windowså¹³å°ä½¿ç¨gcc compilerï¼ä¹å»ºè®®ä½¿ç¨Eclipse + CDT + MinGWçç»åã