First CPP used eclipse CDT

来源:互联网 发布:sql2000数据同步 编辑:程序博客网 时间:2024/05/22 15:41

不是第一次用eclipse写CPP程序,不过每一次都不是很顺利。现总结一下:

这里是操作的具体方式,不过在新版本里还有些不一样。
http://www.codeproject.com/useritems/CPP_Dev_eclipse_CDT.asp

1. 下载Eclipse+CDT(我是直接从eclipse.org上下带CDT4.0的eclipse3.3)

2. 安装完了新建第一个cpp project,一般用managed C++,我是用wizard直接建了一个hello word的可执行project,这样可以避免写make文件
但这时候程序还不能运行,需要下mingw或者Cygwin。关于mingw和Cygwin的区别如下:

MinGW was a fork of version 1.3.3 of Cygwin. Although both Cygwin and MinGW are used to port Unix software to Windows, they have different approaches: Cygwin aims to provide a complete POSIX layer (similar to that found in a Linux or other Unix systems) on top of Windows, sacrificing performance where necessary for compatibility, while MinGW aims to provide only a free compiler and toolchain, prioritizing performance.

Unlike Cygwin, MinGW does not require a compatibility layer DLL and its runtime is licensed under a permissive license.

Since MinGW does not provide a POSIX API, it is unable to compile some Unix applications that can be compiled with Cygwin. Specifically, this applies to applications that require specific POSIX functionality and those that expect to be run in a POSIX environment. Applications written using platform-independent libraries, such as SDL, wxWidgets, Qt, or [[GTK+]] will usually compile as easily in MinGW as they would in Cygwin.

3. 配置eclipse
点击进入project->properties
选择c/c++ Build->settings
选择Binary parsers
选定Elf parser 和PE Windows parser

再选择c/c++ Build->Tool chain editor
将debug和release的current toolchain选定为MinGW

此时build all就能生成二进制文件,然后运行。不需要再建立make文件或者make target。

原创粉丝点击