CC ++ development with Eclipse platform

xiaoxiao2021-03-05  24

C / C development with Eclipse platform

English original

content:

Installing and running CDT Creating a new project key CDT IDE feature Build and Run Project Debug C / C Project Conclusion Reference About the author to the evaluation of this article

related information:

Working the Eclipse Platformgetting Started with the Eclipse Platform Developing Eclipse plugins for Eclipse for XML development

In the Linux area:

Tutorial Tools & Product Codes and Component Project Articles

How to use C / C Development Toolbox (CDT)

Level: Intermediate Pawel Leszek (Pawel.leszek@ipgate.pl) Independent Software Consultant July 2003

We will outline how to use the Eclipse platform in the C / C development project. Although Eclipse is mainly a Java development environment, its architecture ensures support for other programming languages. In this article, you will learn how to use C / C development toolbox (C / C Development Toolkit, CDT), which is the best C / C toolbox available for Eclipse.

C and C languages ​​are the most popular and most popular programming languages ​​in the world, so the Eclipse Platform provides no support for C / C development. Because the Eclipse platform is just a framework for the developer tool, it does not directly support C / C ; it uses external plug-in to support. This article will show you how to use CDT - a set of plugins for C / C development. CDT project (for links, see References in this article) The "Integrated Development Environment, IDE" is committed to providing a full C / C integrated development environment for the Eclipse platform. Although the project's focus is Linux, it works in all environments that can use the GNU developer tool (including Win32 (Win 95/98 / ME / NT / 2000 / XP), QNX Neutrino and Solaris platforms. CDT is an open source item (according to CommON Public License), which is fully implemented using Java, which is a set of plugins of the Eclipse SDK platform. These plugins add C / C perspective to the Eclipse Workbench (Workbench), which can now use many views and wizards and advanced editing and debugging support to support C / C development. Due to its complexity, CDT is divided into several components, which are in the form of a separate plug-in. Each component operates as an independent project, with its own set of submitters, error categories, and mailing lists. However, all plugins are required for CDT normally. Here is a complete list of CDT plug-in / components:

The primary CDT plug-in is a "frame" CDT plugin. The CDT function Eclipse (CDT Feature Eclipse) is a CDT function component (Feature Component). CDT core (CDT Core) provides a core model, CDOM, and core components (Core Component). The CDT UI is the core UI, view, editor, and wizard. CDT launch (CDT Launch) provides a startup mechanism for external tools such as compilers and debuggers. CDT debug core provides debugging. The CDT debug UI (CDT Debug UI) provides a user interface for the CDT debug editor, view, and wizard. CDT debug MI (CDT Debug MI) is an application connector for debuggers compatible with the MI. Now let's study how to use these components in practical applications. Figure 1 shows the C / C items in Eclipse: Figure 1. Editing the C / C project installation and running CDT before downloading and installing the CDT, first, you must ensure the GNU C Compiler (GNU C Compiler " , GCC) and all included tools (Make, Binutil and GDB) are available. If you are running Linux, you will install the development package by using the package manager that applies to your distribution. On the Windows platform, you will need to install the Cygwin Toolbox (see Resources to get link). Cygwin is a class UNIX environment for Windows, which includes GCC transplants and all necessary development tools, including Automake and GNU debuggers (GNU Debugger, GDB). Cygwin is built on the basis of the Cygwin1.dll library. Cygwin's alternate solution is Minimalist GNU for Windows (see Resources to get link). This tool is a set of free-to-use Windows header files and import libraries that are freely distributed, these header files and import libraries and GNU tools (they allow you to generate local Windows programs that do not depend on any third-party DLL) integrate. If you want to create a Posix's compatible Windows application, then MingW is the best choice. MINGW can even work on Cygwin installation. Solaris and QNX require you to download and install your specific GCC, GNU Make BinUtils, and GDB transplants from the Internet (see Resources to get link). Suppose you have the appropriate Java SDK / JRE and Eclipse platform SDK, and they are running normally. CDT is available in two "ways": stable distribution and trial run (Nightly Build). The trial running version has not been fully tested, but they provide more features and correct current errors. Before installing, check if there is a previous version of the CDT on the disk, if there is, make sure it is completely removed. Because the CDT is not available unloading, it needs to be manually removed. In order to check if the previous version is existing, go to the directory where the CDT plugin is resident: Eclipse / Plugins.

Next, remove all directories that start with the org.eclipse.cdt name. The last thing you need to do is to remove the CDT metadata directory or.eclipse.cdt. *. /. The next step is to download the CDT binarily. Note: Please download the correct CDT suitable for your operating system. Unfortunately, even if the CDT is written in Java, it is not unrelated to the platform. Next, unfolding the archive file into the temporary directory, from the temporary directory to move all plug-in directory content to the Eclipse Plugins subdirectory. You also need to move the Features directory content to the Eclipse Features subdirectory. Now restart Eclipse. After Eclipse starts again, the Update Manager will tell you that it discovers changes and asks if you confirm these changes. Now you will be able to see two available new projects: C and C . Creating a new project After installing CDT in Eclipse, browse to file => new => Project, where you will find three new available item types: C ("Standard C make Project"), C ("STANDARD C Make Project ") and" Convert to C OR C Projects ". Start with "Standard Make C Project" to create a source code file for your project. In the C / C Projects view, click the right mouse button and select New => Simple => file. Name your files and save it. You may use this method to create a number of header files and C / C implementation code files. Finally, it is Makefile, and GNU Make will use it to build binaries. Use the common GNU Make syntax for this makefile (see Resources). Keep in mind: makefile requires you to use Tab characters instead of spaces. You usually import existing source code into Eclipse (see Figure 2). CDT provides a convenient way for performing this: Go to the main menu bar, select File => Import => File System. Click Next, open the source directory, select the directory you want to add the file. Click Select All to select all resources in the directory, then check from head to tail, deselect those resources you don't plan to add. Specifies a workbench project or folder that will be imported. You can also import folders and files by dragging folders and files from the file system and put them in the Navigator view, or by copying and paste. Figure 2. Importing an existing source code CDT project key CDT IDE function CDT IDE is built on a universal scalable editor provided by the CDT UI plugin. However, this module is still in the development phase, so it still lacks some important utilities, such as a class browser or a language document browser. The main function of the CDT ID is: syntax highlighting: CDT IDE identifies C / C syntax, and highlights the syntax to provide a fully configurable code coloring and code formatting function: Figure 3. Syntax highlighted after unsuccessful compilation Error tag

Outline: The OUTLINE window module provides a quick view of the process, variables, declarations, and functions that appear in the source code. With OUTLINE, you can easily find the appropriate references in the source code, or even search all item source code. Code Auxiliary: This code completion function is similar to the feature that can be found in Borland C Builder or MS Visual Studio. It uses code template and only helps to avoid stupid syntax errors: Figure 4. Code auxiliary function code template that helps use the correct language syntax: code template used by code auxiliary function is a standard C / C language syntax structure Definition. You can also define your own code template to extend your own shortcuts, such as shortcuts for Author or Date keywords. In Window => Preferences => C / C => Code Templates, you can add a new template and view the full template list. You can also export and import the template as an XML file. Figure 5. Predefined C / C Code Template

Code History: Even if you don't use CVS or other source code management software, you can track local changes in the project source code. Right-click on the selected file, select Compare With => local history ...: Figure 6. Use the local history function to check the changes in the source code and run the project CDT to provide a setup project build option. Simple method. CDT depends on three GNU tools: GCC, GDB and Make. Therefore, these applications can be used for the platform you want to use for the GDB or the dependence of the GCC and MAKE for compilation. Most Linux (usually and class POSIX) source code packages use the AutoConf script to check the build environment, so you must run the configure command, which is created "makefile" before compiling. CDT does not provide a method of editing an AutoConf script, so you must write them manually; however, you can configure the build option to call the configure command before compiling. If you build a project by calling the Make command, the default setting is no problem, however, if a more complex method is used, you must enter the appropriate command (for example, make -f make_it_all) in the Build Command text box. Next, in the C / C Projects view, select C / C Project, then right-click and select Rebuild Project. All compile messages from the make, compiler, and linkers are redirected to the console window: Figure 7. After the console window with the compiler output, you may want to run your application. All options for running and debugging are located under the RUN menu of the primary Eclipse menu. However, you must define an option for running a project earlier. This step can be done by turning to the main menu (where there is a Run ... option in different profiles for running applications); for example, a profile can be used for testing purposes, and another profile can be Used to run the final version. In addition, you can define the parameters you want to pass to the application, or you can set the environment variable. Other options are used to set the debug option, such as which debugger (GNU GDB or Cygwin GDB) is used. Figure 8 shows that the run profile (Run Profile) is being created for the project. Figure 8. Creating a run profile for the Project When you enter the C / C Projects view, select your item, click the right mouse button and select Properties on the Build Settings tab, you can use more common options for building a project. . These options mainly affect the situation that occurs when the build is stopped due to compilation errors. Debug the C / C project CDT extends the standard Eclipse Debug view that has the function of debugging C / C code. The DEBUG view allows you to manage the program debug or run in the workbench. To start debug the current project, you will be able to set it in the code (and change) breakpoint / monitor points and track the variables and registers in the code during the execution process. The Debug view displays the stack framework of the suspended thread of each target that is debugging. Each thread in the program appears as a node in the tree, and the DEBUG view displays the process of each target that is running.

Eclipse supports debuggers compatible with Machine Interface (MI) by CDT Debug MI (CDT Debug Mi) plugins (one of them). But what is the MI debugger? Typically, the third-party GUI debuggers such as DDD and XXGDB (see References to get links) rely on the command line interface (CLI) of GDB when implementing debugging. Unfortunately, it is confirmed that the interface is very unreliable. GDB / MI provides a new machine-oriented interface that is very suitable for the program that wants to directly parse the GDB output. Conclusion C / C Development Toolbox (CDT) provides a set of powerful plugins that can help you develop C / C applications with Eclipse. Although CDT is still in the development phase, you can use its existing features. Reference

Please join the Eclipse platform community and download the platform from Eclipse.org. The Eclipse platform source code is based on the Common public license. On Eclipse.org, you will also find the terms gonsters and descriptions of the Eclipse project, as well as technical articles and newsgroups. The Eclipse platform white paper describes the main components and functions of Eclipse. Download components of the CDT project from Eclipse.org. Please visit the newsgroups on Eclipse.org to get technical discussions and problems associated with C / C plugins. Developers can participate in discussions related to the C / C IDE implementation of the developer mailing list created by each component in the project. The CDT project uses bugzilla as its error and function tracking system. Enter an error / function report on the Eclipse Bugzilla page is as simple as filling in a web form. For geclipse platforms and start-up articles for its working principles, see the developerWorks article "Working The Eclipse Platform" in Greg Adams and Marc Erickson. To start using the Eclipse platform to develop applications, see the developerWorks article "Getting Started with the eclipse platform" written by David Gallardo. If you are interested in creating your own Eclipse plugin, see the developerWorks article "Developing Eclipse plugins" written by David Gallardo. Download Cygwin Toolbox from Red Hat. Download the MingW Toolbox from Mingw.org. Learn more knowledge about GNU Make syntax on gnu.org. Download the DDD GUI debugger from gnu.org. Download the XXGDB GUI debugger. Please visit WebSphere Studio Plug-In Central to get a directory for plugins that have been verified as "Ready for WebSphere Studio Software". Learning an extension of the IBM WebSphere Studio tool, it provides information and tools that help you use these tools. Since all WebSphere Studio tools are based on WebSphere Studio Workbench, the Workbench is based on the Eclipse framework, so it is easy to extend the product documentation by using the Eclipse help extension. See article "Adding self-help support to websphere studio tools by extending their eclipse help systems". Find more Eclipse user references on developerWorks. About the author Pawel Leszek is a writer of Studio B, he is an independent software consultant and writer specializing in Linux / Win / Mac OS system architecture and management. He has many experience in operating systems, programming languages, and network protocols, especially Lotus Domino and DB2 experience. Pawel is also the author of a series of articles on LinuxWorld, as well as Linux column writers in PC World Polish version. Pawel and his wife and lovely little daughter live in Warsaw. Welcome to ask and make an opinion; you can direct the author's email (Pawel.leszek@ipgate.pl).

转载请注明原文地址:https://www.9cbs.com/read-37393.html

New Post(0)