Use eclipse CDT + cmake to build a cross-platform project (VC/GCC)

Source: Internet
Author: User
Tags regex replace

 

The title serves to tell the search engine that eclipse CDT can be used not only for GCC, mingw, but also for VC compilers.

ThisArticleThis is a brief summary after the cross-platform CDT environment has been configured in the past two days. If you have any questions, please leave a message after this article. If yes, I will reply.

1. You only need to install the most basic eclipse + CDT environment on both Windows and Linux platforms:

Eclipse classic 3.6.1

, 170 MB
Downloaded 520,504 times
Details

Other downloads platform runtime binary using the above other downloads, about 50 MB. After unzipping in Linux, if JRE is installed, it will be the green version!
2. Install new software to install CDT and remove components that you cannot use to increase the speed. 3. cross-platform project requires makefile project, it is strongly recommended to use cmake to generate makefile. Reference: http://www.cmake.org/Wiki/CMake:Eclipse_UNIX_Tutorial4. set different make masters for different platforms through a build variable $ {pmake} Program For example, set nmake in windows. 5. Enable the discovery option so that gcc/mingw can automatically find the path of the header file after compilation. 6. Create include, Lib, and path environment variables for the Windows platform (created in eclipse) and add them to the project. Not required in Linux. 7. make good use of make target, which has powerful functions. For example, the command for generating makefile: cmake-e chdir $ {projdirpath}/build cmake-dcmake_build_type = debug .. 8. run the make command: cmake-e chdir $ {projdirpath}/build $ {pmake} 9. command supporting windbg debugging: cmd $ {windbg }$ {projdirpath}/build/$ {projname}, where $ {windbg} must be set by yourself: /C "$ {eclipse_home}/build/share/windbg/windbg.exe" 10. you can configure multiple compilers in eclipse CDT. You only need to add the bin directory of mingw to the path environment variable, for example, my: $ {eclipse_home}/build/bin; $ {eclipse_home}/Bui LD/GCC/bin; 11. The shortcut key uses the vs style, which is the same as the windbg style, especially during debugging. 12. Code The ALT +/key must be changed to Shift + space! 13. Example of cmakelists.txt:<Textarea Cols = "50" rows = "15" name = "code" class = "Python"> Project (demo_01) <br/> cmake_minimum_required (version 2.8) <br/> If (Unix or mingw) <br/> set (cmake_verbose_makefile on) <br/> endif () <br/> If (msvc) <br/> set (cmake_c_flags_debug "$ {cmake_c_flags_debug}/MTD") <br/> foreach (flag_var <br/> cmake_c_flags cmake_c_flags_debug variable <br/> release variable) <br/> if ($ {flag_var} matches "/MD ") <br/> string (RegEx Replace "/MD" "/MT" $ {flag_var} "$ {$ {flag_var}") <br/> endif () <br/> endforeach () <br/> endif () <br/> aux_source_directory (. src_list) <br/> include_directories (..) <br/> add_executable (demo_01 $ {src_list}) <br/> </textarea>... Save it. Tired. Conclusion: Eclipse CDT 7.0 has more powerful functions than the previous CDT! In open-source IDE, CDT is the most powerful! Wash and sleep! Supplement: 1. to enable multi-core compilation, the VC compiler can use JOM: http://qt.gitorious.org/qt-labs/jom2. to better edit cmakelists.txt, you need to install a cmakeed plug-in: http://cmakeed.sourceforge.net/3. if mt.exe crashes frequently when using the vc10compiler I extracted, you need to install it. net Framework Version 2.0, here there is a green Version Download: http://download.csdn.net/source/17370714. CDT's powerful template parsing capabilities are amazing! 5. Add the speed-up feature: Modify the eclipse. ini file under the eclipse directory and add the following content to increase the speed by 2 ~ 5 seconds! <textarea cols="50" rows="15" name="code" class="css">-Xverify: None <br/>-xms512m <br/>-xmx512m <br/>-XX: permsize = 128 M <br/>-XX: + useparallelgc</textarea> Supplement: 11. Select the vs style as the shortcut key. This is the same as the windbg style, especially when debugging. 11th items are rejected by me today: If you select it, some useful Shortcut Keys enabled in the default state will be lost, such as: Ctrl + TAB to switch header files and source files, CTRL + Shift + F format the code. If you think about it, it is natural that eclipse can be set like this. Therefore, trust eclipse and change the habit of setting shortcuts to the eclipse style! In addition, 6.24 officially released 8.0 version is awesome Ah: http://wiki.eclipse.org/CDT/User/NewIn80Update Summary of latest configuration methods
: Http://topic.csdn.net/u/20110625/22/fcba3ecb-83db-4147-9e7c-b398001a2543.html

Related Article

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.