转自:http://topic.csdn.net/u/20110625/22/fcba3ecb-83db-4147-9e7c-b398001a2543.html
一、安装
1. 安装Eclipse运行库:http://download.eclipse.org/eclipse/downloads,Build Type选Latest Release,打开Build Name为3.7的链接,下载Platform Runtime Binary中的Windows(51MB)和Windows (x86_64)(51MB)两个包,分别对应x86平台和x64平台。
2. 安装Java运行库:http://www.java.com
3. 安装CDT:http://www.eclipse.org/cdt/downloads.php
在线安装:http://download.eclipse.org/tools/cdt/releases/indigo
离线安装:http://download.eclipse.org/tools/cdt/builds
只选择C/C++ Development Platform即可!
4. 安装CMakeEd:http://sourceforge.net/projects/cmakeed
在线安装:http://cmakeed.sourceforge.net/eclipse
5. 安装CMake:http://www.cmake.org
二、配置
1. 字体设置:General > Appearance > Colors and Fonts
修改Basic的最后两项字体为Consolas,字体大小为11号
修改C/C++项字体为Consolas,字体大小为11号
2. 编辑器选项:General > Editors > Text Editors
选中Insert spaces for tabs
选中Show print margin,并设置Print margin column = 100
选中Show line numbers
修改Current line highlight为淡绿色
3. 快捷键:
Content Assist = Shift+Space
Word Completion = Alt+/
Line End = Ctrl+Enter
4. 工作空间设置:General > Workspace
选中Save automatically before build
选中Always close unrelated projects without prompt
5. 重构前自动保存:C/C++
选中Save all modified resources automatically prior to refactoring
6. 群组归类显示:C/C++ > Appearance
选中所有Group选项
7. 只构建有修改的项目:C/C++ > Build
选中Build configurations only when there are Eclipse resource changes within the project and its references
8. 构建变量:C/C++ > Build > Build Variables
WinDbg=${eclipse_home}/share/WinDbg/windbg.exe
9. 环境变量:C/C++ > Build > Environment
PATH = ${eclipse_home} / bin;${eclipse_home} / sdk / Irrlicht / Bin INCLUDE = ${eclipse_home} / sdk / DirectX9 / Include;${eclipse_home} / include;${eclipse_home} / sdk / Irrlicht / Include LIB = ${eclipse_home} / sdk / DirectX9 / Lib;${eclipse_home} / lib;${eclipse_home} / sdk / Irrlicht / Lib
Build = cmd / C " if not exist Build (mkdir Build && chdir Build && cmake -G " NMake Makefiles " .. && nmake verbose=1) else chdir Build && nmake " CMake_Debug = cmd / C " if not exist Build (mkdir Build && chdir Build && cmake -G " NMake Makefiles " -DCMAKE_BUILD_TYPE=Debug .. && nmake verbose=1) else chdir Build && cmake -G " NMake Makefiles " -DCMAKE_BUILD_TYPE=Debug .. && nmake " CMake_MinSizeRel = cmd / C " if not exist Build (mkdir Build && chdir Build && cmake -G " NMake Makefiles " -DCMAKE_BUILD_TYPE=MinSizeRel .. && nmake verbose=1) else chdir Build && cmake -G " NMake Makefiles " -DCMAKE_BUILD_TYPE=MinSizeRel .. && nmake " CMake_Release = cmd / C " if not exist Build (mkdir Build && chdir Build && cmake -G " NMake Makefiles " -DCMAKE_BUILD_TYPE=Release .. && nmake verbose=1) else chdir Build && cmake -G " NMake Makefiles " -DCMAKE_BUILD_TYPE=Release .. && nmake " CMake_RelWithDebInfo = cmd / C " if not exist Build (mkdir Build && chdir Build && cmake -G " NMake Makefiles " -DCMAKE_BUILD_TYPE=RelWithDebInfo .. && nmake verbose=1) else chdir Build && cmake -G " NMake Makefiles " -DCMAKE_BUILD_TYPE=RelWithDebInfo .. && nmake " Debug = ${WinDbg} ${ProjDirPath} / Build / ${ProjName} Open = explorer Build Run = cmd / C chdir Build && nmake && start runner ${ProjName} // 适用控制台程序 Run = cmd / C chdir Build && nmake && ${ProjName} // 适用GUI程序
CodeBlocks = ${eclipse_home} / share / CodeBlocks / CodeBlocks.exe Depends = ${eclipse_home} / share / Depends / Depends.exe ErrorShow = ${eclipse_home} / share / ErrorShow.exe Find2Replace = ${eclipse_home} / share / Find2Replace.exe QuickMSDN = ${eclipse_home} / share / QuickMSDN.exe ResEdit = ${eclipse_home} / share / ResEdit / ResEdit.exe Spy ++ = ${eclipse_home} / share / Spyxx / Spyxx.exe WinDbg = ${eclipse_home} / share / WinDbg / windbg.exe
foreach (flag_var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) if (${flag_var} MATCHES " /MD " ) string (REGEX REPLACE " /MD " " /MT " ${flag_var} " ${${flag_var}} " ) endif() if (${flag_var} MATCHES " /W3 " ) string (REGEX REPLACE " /W3 " " /W4 " ${flag_var} " ${${flag_var}} " ) endif() endforeach()
if (NOT ${CMAKE_BUILD_TYPE} MATCHES " Debug " ) set (WINDOWS WIN32) add_definitions( - D_IRR_STATIC_LIB_) set (LIBRARIES Irrlicht_S.lib) else () set (LIBRARIES Irrlicht.lib) endif() #... target_link_libraries(${PROJECT_NAME} ${LIBRARIES})
C ++ 风格注释: // .*$ C风格注释: / \ * (. | [\r\n]) *? \ */ 双字节字符(包括汉字在内):[ ^ \x00 - \xff] 汉字:[\u4e00 - \u9fa5] 空行1:\n[\s | ] * \r 或者 \n\s * \r (利用Ctrl + H中的File Search > Replace可以删除空行) 空行2: ^ \s * \n (利用Ctrl + F中的Replace All可以删除空行) 特定数字: ^ [ 1 - 9 ]\d * $ // 匹配正整数 ^- [ 1 - 9 ]\d * $ // 匹配负整数 ^-? [ 1 - 9 ]\d * $ // 匹配整数 ^ [ 1 - 9 ]\d *| 0 $ // 匹配非负整数(正整数 + 0) ^- [ 1 - 9 ]\d *| 0 $ // 匹配非正整数(负整数 + 0) ^ [ 1 - 9 ]\d * \.\d *| 0 \.\d * [ 1 - 9 ]\d * $ // 匹配正浮点数 ^- ([ 1 - 9 ]\d * \.\d *| 0 \.\d * [ 1 - 9 ]\d * )$ // 匹配负浮点数 ^-? ([ 1 - 9 ]\d * \.\d *| 0 \.\d * [ 1 - 9 ]\d *| 0 ? \. 0 +| 0 )$ // 匹配浮点数 ^ [ 1 - 9 ]\d * \.\d *| 0 \.\d * [ 1 - 9 ]\d *| 0 ? \. 0 +| 0 $ // 匹配非负浮点数(正浮点数 + 0) ^ ( - ([ 1 - 9 ]\d * \.\d *| 0 \.\d * [ 1 - 9 ]\d * )) | 0 ? \. 0 +| 0 $ // 匹配非正浮点数(负浮点数 + 0) 特定字符串: ^ [A - Za - z] + $ // 匹配由26个英文字母组成的字符串 ^ [A - Z] + $ // 匹配由26个英文字母的大写组成的字符串 ^ [a - z] + $ // 匹配由26个英文字母的小写组成的字符串 ^ [A - Za - z0 - 9 ] + $ // 匹配由数字和26个英文字母组成的字符串 ^ \w + $ // 匹配由数字、26个英文字母或者下划线组成的字符串
六、静态编译Jom多核编译
1. 下载源码:git://gitorious.org/qt-labs/jom.git
2. MSVC静态编译Qt:
修改QT编译及链接选项(mkspecs\win32-msvc2010\qmake.conf):
QMAKE_CFLAGS_RELEASE = -O2 -Os -MT
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -Os -MT -Zi
QMAKE_LFLAGS_RELEASE = /INCREMENTAL:NO /OPT:REF /OPT:ICF
QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO = /INCREMENTAL:NO /DEBUG /OPT:REF /OPT:ICF
配置QT:
configure -release -platform win32-msvc2010 -fast -static -opensource -no-qt3support -no-accessibility -no-rtti -no-stl -no-script -no-declarative -no-webkit -no-opengl -no-openssl -nomake demos -nomake examples -nomake tools -nomake translations
编译QT:
nmake
将QT的bin所在路径添加到环境变量PATH中,就可以在控制台下编译JOM了:
qmake ..
nmake release
即可编译出JOM的release静态版本。
这里下载我编译好的x86与x64版本:http://code.google.com/p/jom-nmake/
七、升级到每日构建版
先删除工作空间中的所有工程,再删除所有Eclipse相关文件、目录(workspace目录除外),再重复安装过程:之后重定位到相同workspace,即可自动恢复所有配置。
不要简单的覆盖:否则会多出许多过时的文件,不完美!