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

Source: Internet
Author: User

Text/Zhang Shanyou

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

Bytes

Download anjuta-1.1.97-1.rh90.i386.rpm

Bytes

Download anjuta-1.0.2-1.i386.rpm

Heanet.dl.sourceforge.net/sourceforge/anjuta/anjuta-1.0.2-1.i386.rpm

Download gtkmm2-2.2.3-fr1.i386.rpm

Ftp.freshrpms.net/pub/freshrpms/redhat/9/gtkmm2/gtkmm2-2.2.3-fr1.i386.rpm

Download gtkmm2-devel-2.2.3-fr1.i386.rpm

Bytes

Download libsigc ++-1.2.5-fr1.i386. rpm

Bytes

Download glademm-1.1.3d-SNAP.i586.rpm

Loban.caltech.edu/gchch/glademm-1.1.3d-SNAP.i586.rpm

Downloading libsigc ++-devel-1.2.5-fr1.i386.rpm

Bytes

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.


Figure 1

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 'What's 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:


Figure 2

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 user_data)
{
GtkWidget * entry = lookup_widget (GTK_WIDGET (button), "entry ");
GtkWidget * msgbox = gnome_app_new ("Hello World", "Hello World ");
Gchar * text1, * text2;
Text1 = gtk_entry_get_text (GTK_ENTRY (entry ));
Text2 = strcat ("Hello,", text1 );
Gnome_app_message (GNOME_APP (msgbox), text2 );
}

Generate, execute, and issue the target code.

Now it's time to test your program. It must be interesting. Select menu item create> Create project. Then Anjuta starts to compile and link the source program main. c, interface. c, support. c and callbacks. c in the project, and then places the generated Executable File hello in the src directory. The compiler generally uses gcc.

If you are lucky to have no error information during the compilation process, choose "Create-> Execute Program". Then Anjuta opens a terminal window and runs your application HelloWorld on it! Enter your name in the input box and click OK. Hope that your application will return you a greeting: Hello... you can enter another greeting word, and then click Exit to see if the program can Exit normally. It would be nice to exit normally! Your hard work has finally come to an end!

In this case, you can install your application in the Windows system: choose to create a single menu-> install although you may not want to create a tarball file for your application, however, you may need to release the software later. Before you release an application, you must fill in the TODO, ChangeLog, INSTALL, and README files. To create an application release, click Create-> Create a release package may take several seconds to create, and it will eventually go to/home/(username) create a file helloworld-0.1.tar.gz under the/Projects/helloworld/directory.

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.