Eclipse builds c\c++ development environment guide __c++

Source: Internet
Author: User

At present, major Internet companies in the mainstream C language development environment for linux+c\c++, for beginners, Linux under the C language development environment needs to master such as Vim, Makefile, GCC and other related knowledge, which is enough to let many new people retreat, at the same time, after work, study, brush problems, Or when you're inspired to write code, there's a lot of inconvenience in using Linux+c.

So, when the Java IDE's God Eclipse first appeared in the author's life, there is a kind of surprise, untimely, not false me, don't stop me to turn to Java impulse. Calm, asking degrees Niang, looking for, Huang Tian not negative, finally found based on eclpise build c\c++ language development environment development ideas. After a while, a shout from GNU haunted the Ear, and became the text.

Gossip Hugh, this article is introduced based on Eclipse to build c\c++ language development environment of the tutorial article, in the Niang on the various tutorials to comb, summed up, but also the author of the installation process encountered problems and some experience to share. This article is suitable for beginners, at the same time for veteran also has a certain reference value, if there is insufficient, please advise more.

The construction of the whole development environment can be divided into the following several steps:

(1) installation of JDK;

(2) Eclipse installation;

(3) c\c++ compiler installation (MINGW) and environment variable configuration;

(4) Eclipse related settings and testing;

These are described in the order described below.

1, the installation of JDK;

Because eclipse requires JDK at run time, make sure you have a JDK on your computer and you have configured the environment variables. The test method is to open the Windows command line tool (CMD), input Java, java-version, and javac-version when the output is correct installation. If you have never installed or installed an error on your computer, it is recommended that you remove it from your computer (Control Panel-Uninstall program), and then start again with the following steps.

The official download address for JDK is: http://www.oracle.com/technetwork/java/javase/downloads/index.html, select the appropriate version depending on the number of digits in the operating system. Download Complete installation, installation method is very simple, you need to pay attention to the point is: installation process, there are two times to select the path, these two times to choose a different installation path, otherwise run javac-version will be an error. The reason is that when you install to the same directory, there is a file overwrite, causing the Javac.exe file to be incorrect. After installation, you need to set three environment variables, the configuration method is: Right-click My Computer-> Properties-> Advanced-> Environment variables, environment variables are divided into user environment variables and system environment variables, set system environment variables can be:

(1)Java_home: This is the path of the JDK just installed, I am: C:\Program files\java\jdk1.7.0_45;

(2)Path: set to%java_home%\bin;%java_home%\jre\bin;

(3)Class_path: set for.; %java_home%\lib\dt.jar;%java_home%\lib\tools.jar;

After the setup is completed, the test is done according to the method described above, run Java, java-version and javac-version test pass.

2. Download the eclipse IDE for C + +

To avoid installing the CDT, you can download the Eclipse IDE for C + + directly by downloading the address: http://www.eclipse.org/downloads/or http://www.eclipse.org/downloads/ PACKAGES/ECLIPSE-IDE-CC-DEVELOPERS/HELIOSSR1, there are 32 and 64-bit version, everyone look at the next bar.

When the download is complete, install it by default path. After the installation is complete, you need to set up the Eclipse working directory as a future code engineering storage path.

3, c\c++ compiler installation (MINGW) and environment variable configuration

In order to compile the C program under the Windows platform, you also need to install a C compiler, this article selected is MinGW. The download address is:http://www.mingw.org/download.shtml, after downloading installs completes, needs to configure the following environment variable:

(1)Path: add C:\MinGW\bin to the environment variable; It's best to put it on the front and remember to add a semicolon (;).

(2)Library_path:C:\MinGW\lib;

(3)C_include_path:C:\MinGW\include;

(4)Cplus_include_path:c:\mingw\include\c++\; C:\mingw\include\c++\3.2.3\mingw32; C:\mingw\include\c++\3.2.3\backward; C:\MinGW\include;

When the setting is complete, enter GCC-V in the command line, and output the GCC version information, or enter mingw32-make.exe-version and output version information.

20170816 add: If the new C project is compiled, there is no need to panic in English errors such as "Can don't find" and "path" in the console bar of Eclipse. First check whether the PATH environment variables are correctly configured in the C:\MinGW\bin, if not configured on the configuration can be, if the configuration is still the above error, will C:\MinGW\bin\ Mingw32-make.exe is renamed as Make.exe after the backup because eclipse compiles the C code by default looking for an executable named Make.exe.

4, Eclipse related settings and testing

When you open eclipse, create a new C or C + + project and choose MinGW GCC in the Hello World C project,toolchains column, creating a basic C language program. Follow the process to compile, connect, run, you can see the console column output Hello world ... This completes the C\c++ language development environment under eclipse.

20170816 supplement: In this step, there may be a successful compilation of the *.exe file, but at run time, Eclipse still cannot find the executable file error. For this issue, you need to set the execution preference for the project, by clicking the drop-down arrow next to the Run button, selecting Run_configurations, and double-clicking the C + + Application column: Set the location of the engineering and executable files to perform in the main page. Add an environment variable to the environment page C_include_path:C:\MinGW\include, save and exit to execute successfully.

5. Settings for the Eclipse development environment

The C language code can be compiled and linked in 1 to 4, but in order to make your development environment look more comfortable, you need to create an eclipse environment that is appropriate for you, and here is a brief introduction to the settings for the topic theme and C code.

The default installation of the Eclipse main interface is pure white, long watch is easy to make eye fatigue, for this, eclipse provides a lot of color theme theme, choose a suitable for your own, you can refer to this article: Http://blog.csdn.net/Justnow_ /article/details/50173069.

In addition, to implement automatic code completion (the default will be automatically completed after. or->), you need to set up two environment variables under Eclipse, set the method to: After starting Eclipse, enter: windows-->preferences-->c/c+ + Find environment. Add two environment variables:
(1) cplus_include_path:c:\mingw\include\c++\; C:\mingw\include\c++\6.3.0\mingw32; C:\mingw\include\c++\6.3.0\backward; C:\MinGW\include (where 6.3.0 is my gcc version,)
(2) C_include_path:c:\mingw\include;
When Setup is complete, pressing alt+/(some configurations are ctrl+space) triggers the Code hints feature, making writing code more handy.
At this point, you can freely develop the C code under Eclipse.
The next article is going to write about new hires in the workplace, what you need to know and how to get started quickly, and listen to let's.
Self-discipline is free and mutual encouragement.

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.