Build a C/C ++ IDE development environment on Linux

Source: Internet
Author: User
The Anjuta package is not provided in Redhatlinux, and a Glade application interface design tool is provided above. In Linux, the Anjuta, Glade, and Glademm software packages can be used to build an IDE environment for C/C ++ software development under linux, and GTK ++/Gnome Application Development. Previously developed Lin

The Anjuta package is not provided in Redhat linux, and a Glade application interface design tool is provided above. In Linux, the Anjuta, Glade, and Glademm software packages can be used to build an IDE environment for C/C ++ software development under linux, and GTK ++/Gnome Application Development.

It was difficult to write a good graphical user interface when developing a Linux program. After the birth of the GIMP Toolkit (GTK), it became easier. It is easier for Damon Chaplin to write the GLADE tool to generate a graphical user interface in the GTK environment. However, GLADE is still not an "integrated development environment" (such as Visual Basic), because programmers cannot manually modify the code generated by GLADE in the GLADE environment. Now, all this has become the past: Anjuta was born!

Anjuta uses GLADE to generate beautiful user interfaces, and with its powerful source code editing capabilities, it is becoming an excellent integrated environment (IDE) for rapid application development ). In the past, people used GLADE as the interface, used emacs or vi to edit programs, and used a terminal simulator to edit development projects. With Anjuta, all these complicated and scattered tasks can be completed in a unified, integrated, and natural environment.

I. software preparation:

Download libzvt-2.0.1-0.ximian.6.6.i386.rpm
Http://tux.cprm.net/pub/ximian/xd2/redhat-9-i386/libzvt-2.0.1-0.ximian.6.6.i386.rpm

Download anjuta-1.1.97-1.rh90.i386.rpm
Http://rpm.pbone.net/index.php3/stat/4/idpl/772608/com/anjuta-1.1.97-1.rh90.i386.rpm.html

Download anjuta-1.0.2-1.i386.rpm
Http://heanet.dl.sourceforge.net/sourceforge/anjuta/anjuta-1.0.2-1.i386.rpm

Download gtkmm2-2.2.3-fr1.i386.rpm
Http://ftp.freshrpms.net/pub/freshrpms/redhat/9/gtkmm2/gtkmm2-2.2.3-fr1.i386.rpm

Download gtkmm2-devel-2.2.3-fr1.i386.rpm
Http://ftp.freshrpms.net/pub/freshrpms/redhat/9/gtkmm2/gtkmm2-devel-2.2.3-fr1.i386.rpm

Download libsigc ++-1.2.5-fr1.i386. rpm
Http://ftp.freshrpms.net/pub/freshrpms/redhat/9/libsigc++/libsigc++-1.2.5-fr1.i386.rpm

Download glademm-1.1.3d-SNAP.i586.rpm
Http://loban.caltech.edu/gchch/glademm-1.1.3d-SNAP.i586.rpm

Downloading libsigc ++-devel-1.2.5-fr1.i386.rpm
Http://ftp.freshrpms.net/pub/freshrpms/redhat/9/libsigc++/libsigc++-devel-1.2.5-fr1.i386.rpm

II. install the software package

Install redhat linux 9 and select install software development items. then install Glade and log on as the root user to install the following software packages.

Rpm-ivh libzvt-2.0.1-0.ximian.6.6.i386.rpm // dependent package for anjuta
Rpm-ivh ibsigc ++-1.2.5-fr1.i386. rpm
Rpm-ivh gtkmm2-devel-2.2.3-fr1.i386.rpm
Rpm-ivh ibsigc +++-devel-1.2.5-fr1.i386.rpm
Rpm-ivh gtkmm2-2.2.3-fr1.i386.rpm
Rpm-ivh glademm-1.1.3d-SNAP.i586.rpm
Rpm-ivh anjuta-1.0.2-1.i386.rpm
Rpm-Uvh anjuta-1.1.97-1.rh90.i386.rpm

Note: directly install the anjuta-1.1.97 will find that the software cannot be compiled, here pay attention to a few issues

1. to install the libzvt package of Ximian, install
2. install Anjuta 1.0.1 before updated via rpm-Uvh Anjuta 1.1.97.

3. develop the C/C ++ program on Anjuta1.1.97

Let's first use Anjuta to create a simple Hello World program.

Create a new project

Open Anjuta first. Choose menu item programming> more programming tools> Anjuta IDE. The GNOME Application Genie "GNOME2.0 Application Wizard" will appear. Even if you only need to click the Next button, you do not have to worry about the information in the Wizard dialog box. here, you still want to read every piece of information in the dialog box. Now, after you have read the information in the Wizard step 1 dialog box, click Next.

Step 2 is critical. Here you need to determine the type of the application you want to create. Let's Select "Gnome2.0 project" and continue. Step 3: determine the basic configurations of the application. Enter the configuration information of the application very carefully. In this tutorial, enter the following information.

Project name: HelloWorld (Program project name) note that the project name cannot contain spaces
Program version: 0.1 (version)
Author: (your name)
Program Name: helloworld (program name)
Programming Language: three options are available: C, C ++, and C/C ++.
Program Type: three options are available: executable program, dynamic link library, and static link Library.

The fourth step is to compile the project description;

Step 5 is other options of the project, including the GNU copyright statement and program localization support items. if you do not want them, you can remove them. You 'd better select an icon for this application project, which will appear in the GNOME Application menu. Here, we select Hello World example as the project name and Applications in the Group domain. Click "Next" and "Finish. This application project is created.

Because we just set up a subprogram, we can easily move forward. If we are creating an application project to be used in the real world, we should be very careful when entering the parameters for each step of the application Genie, because they are very important to your application projects.

Design user interface

After the conversation with the application wizard ends, Anjuta starts to establish the directory structure of your application project, run the parameter configuration script, and create the application project itself. The entire creation process is displayed in the lower part of the Anjuta development environment. After the creation process is complete, the application project tree is displayed on the left of the screen. This tree structure contains your source program file, description file and graphic file.

Now it is time to start GLADE and use it to design a graphical user interface. Go to the menu item project> edit graphical interface to run GLADE. You will see three windows: 1) Glade main window, 2) properties window, and 3) drawing tool window.

Just take a simple GTK window. Click the first item (hello_app) listed in the Glade main window and press Del to delete the key. Click the first icon in the tool window. Then a blank GtkWindow is built. This will be the main windows window1 of our application. Go to the Properties window and enter the title "Hello World !". Now, go to the tool window and select a table (table) with two rows and two columns to be placed on window1. In this way, the main window is split into four parts of the same size.

Now, remove the two buttons from the tool window and add them to the two boxes in the main window. Set the names and attributes of these two buttons as follows:

Left button:
Name: BT_ OK
Label: OK
Right button:
Name: BT_EXIT
Label: Exit

Add a tag control to the left of the upper half of the window, and add an Entry control to the right of the upper half. The name of the input box is ENTRY. Set the label property of the preceding tag control to Whats your name, sir ?.

Now, on the Signals tab of the attribute window, connect the two buttons with the Clicked event. Use the reverse call function name preset by GLADE. Do not forget to click the Add button. This common error may result in a blank callbacks. c file. On the source file callbacks. c, we will add the source code through the Anjuta interface.

Currently, the main window does not seem so beautiful. You can try to change the width and height of the window, and modify the properties of the horizontal and vertical inclusive boxes to see if the window looks better. (Note: You can go to the menu View, select the control tree, and then select the control .) The following are some attribute settings:

* Set the Homogeneous attribute of the following horizontal inclusion box to Yes;

* Set the attribute Fill of the button for locating the attribute window to Yes;

* Set the Grow attribute of window1 in the main window to No.

After changing these attributes, my main window will look like this:

After the interface is designed, click "Save disk" in the Glade main window, and then click "join. this updates the source file interface under the src directory of your application project based on the newly designed interface. c. Now, choose Project> Exit to return to the Anjuta user interface. Start programming!

Edit program

Now back to the Anjuta environment, you should be able to see callbacks in the project source program list on the left side of the screen. c. double click to open the program. in this way, you can edit the program on the left of the Anjuta integrated development environment.

Sometimes, if a thing is colored, it will become easier to understand and more interesting. This is the case for Anjuta's "syntax emphasizing color" function (on the "Format" menu). Anjuta also has many useful functions that you can play. Maybe it is good to take some time to get familiar with this integrated environment.

Now back to the callbacks. c file, we can see two reverse call functions: on_BT_ OK _clicked and on_BT_EXIT_clicked. let's add a function call in the second function: gtk_main_quit (). In this way, the function becomes:

# Ifdef HAVE_CONFIG_H
# Include
# Endif
# Include
# Include "callbacks. h"
# Include "interface. h"
# Include "support. h"
Void on_BT_ OK _clicked (GtkButton * button, gpointer user_data)
{
Gtk_main_quit ();
}

This function is called to end the entire application when you click the exit button. Similarly, we add the following function calls to the on_BT_ OK _clicked function:

Void on_BT_ OK _clicked (GtkButton * button, gpointer us

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.