Configure the C/C ++ compiling environment for eclipse CDT

Source: Internet
Author: User
Tags wxwidgets

Reprinted on http://blog.csdn.net/goodfunman/archive/2005/08/31/468319.aspx

When Visual C ++ has a long tail, Borland C ++ builder is bloated, and the wallet is empty, isn't there any good C ++ ide that we can afford in windows?
Of course not. Another thing in the world is open source.
The purpose of this article is to show you how to use open-source software to build C ++ ide under Windows XP (although it is a better choice to use Linux OS, there is no doubt that, windows OS is at least easier to use than Linux OS, and in China, Windows users are far more than Linux users ).
When Visual C ++ has a long tail, Borland C ++ builder is bloated, and the wallet is empty, isn't there any good C ++ ide that we can afford in windows?
Of course not. Another thing in the world is open source.
The purpose of this article is to show you how to use open-source software to build C ++ ide under Windows XP (although it is a better choice to use Linux OS, there is no doubt that, windows OS is at least easier to use than Linux OS, and in China, Windows users are far more than Linux users ).

1. install Java JDK
Why should I install Java JDK on the C ++ development platform? This seems to be the pity of C ++. The reason is very simple, because eclipse is not only used for Java Development, but also developed based on Java virtual machine. Because of this, eclipse has good portability. What you need is not a specific operating system, but just a Java JDK. Therefore, this article is intended for Windows OS, but a lot of content can be applied to other operating systems.
Installing Java SDK is simple. Find the appropriate Java JDK installer for your operating system on the http://java.sun.com, download and run, the Java SDK will be installed in your system. I downloaded the latest Java JDK 1.5. Note: a later version of eclipse requires a later version of Java JDK. Currently, eclipse can use Java JDK 1.4.2 or later.
For more help on installing Java JDK, refer to the online documentation on the Java website.
(Note: Eclipse requires Java JDK to run, not just JRE, because eclipse itself integrates Java development functions and requires the support of Java JDK .)

2. Install eclipse and CDT
Download eclipse from the http://www.eclipse.org on the official website of Eclipse. Multiple versions of eclipse can be downloaded at the same time, including the latest 3.1, 3.0.1, and 2.1.2. 3.1 is a relatively new version, but unfortunately there is no Chinese patch pack. However, this is not an important obstacle for the brothers. If you really want to use a Chinese development environment, download 3.0.1. Currently, the latest language patch package supports 3.0.1. As for 2.1.2, if you have used eclipse and prefer the previous interface style, 2.1.2 will be more suitable for you.
In fact, different versions of eclipse can coexist. You just need to install them in different directories (I am using both 3.0.1 and 3.1 ).
Now, let's download eclipse 3.0.1. Select an appropriate image website, download the eclipse 3.0.1 software package and the 3.0.1 _ translations language patch package, and decompress them to the same directory. Don't rush to run it now. There are still many things to be done.
Now you need to install CDT. CDT is short for C/C ++ development tools. It is a plug-in that enables eclipse to support C/C ++ development. Go to the official website of CDT, http: // www/eclipse.org/cdt. then select a website to download the CDT 2.0.2 and the CDT language patch package (if you select eclipse of version 2.x, download the CDT of version 1.x ). After the download is complete, extract the two packages to the eclipse directory.
Now that the installation is complete, click the eclipse beautiful icon to see the effect.
(You can also install CDT through the eclipse software update function after installing eclipse. For detailed steps, refer to the eclipse online documentation .)

3. Install mingw
Currently, this C/C ++ ide cannot be started because it lacks important components. This part is the C/C ++ compiler. In Windows OS, we can select two compilers, cygwin and mingw. The former is supported by RedHat, but it is not completely open-source now. You need to pay for the license. For details, refer to http://www.redhat.com/software/cygwin /. This obviously cannot satisfy us. A Windows XP is expensive enough. So we chose mingw.
Now to mingw website http://mingw.sourceforge.net, download mingw-3.1.0-1.exe, then run the EXE file installation. To facilitate future use, create a batch file:

Mingw32setvar. bat
Set Path = D:/mingw/bin; % PATH %
Set LIBRARY_PATH = D:/mingw/lib
Set c_include_path = D:/mingw/include
Set cplus_include_path = D:/mingw/include/C ++/3.2.3; D:/mingw/include/C ++/3.2.3/mingw32; D: /mingw/include/C ++/3.2.3/backward; D:/mingw/include

Similarly, to run CDT conveniently, create another batch file:

CDT. bat
Set Path = % PATH %; D:/mingw/bin
Set LIBRARY_PATH = D:/mingw/lib
Set c_include_path = D:/mingw/include
Set cplus_include_path = D:/mingw/include/C ++/3.2.3; D:/mingw/include/C ++/3.2.3/mingw32; D: /mingw/include/C ++/3.2.3/backward; D:/mingw/include

D:/Eclipse/eclipse.exe

Now let's test it. Click CDT. BAT to open eclipse and choose create> Project> managed make C ++ project. Create a new main. cpp in the project, enter a simple program, and then create and run it. See the result. If you have any questions, you can search for eclipse CDT on Google to find many articles related to the content. I believe it will be helpful to you.

4. Install wxWidgets
What is wxWidgets? I think you must have heard of wxwindows. This year, under the pressure of MS, The wxwindows development team had to rename it as wxWidgets, but it was as good as it was before.
Development in Windows inevitably involves GUI Design. If you only use the WIN32API of mingw, it is too outdated. WxWidgets is undoubtedly a good choice.
Download the wxWidgets 2.4.2 or 2.5.3 version of wxWidgets on the wxWidgets website http://wxWindows.sourceforge.net and decompress it. Note that the decompressed path cannot contain space characters. Compile the required library by referring to docs/MSW/install.txt.
(Note: you may need to install more mingw tools to compile wxWidgets. These tools are also downloaded on the wxWidgets website .)
Now, open eclipse, create a standard make C ++ project, and add an example in wxWidgets. In the project options, set the builder command to make-F makefile. g95 and save the settings. Build and run the project. The expected form appears.

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.