Linux build c/c++ide development environment _unix Linux

Source: Internet
Author: User
Tags gtk

Wen/Zhang Shanyu

Redhat Linux does not provide a Anjuta software package, which provides a Glade application interface design tool. Linux uses Anjuta and Glade as well as GLADEMM software packages to build a Linux IDE environment under which C + + software development can be developed for gtk+/gnome applications.

It's hard to write a good graphical user interface when you are developing a Linux program before. After the birth of the GIMP Toolkit (GTK), it became easier. It is much easier when Damon Chaplin writes out GLADE, a tool for generating graphical user interfaces in GTK environments. But GLADE is still not an "integrated development environment" (such as Visual Basic, etc.) because programmers cannot manually modify the code generated by GLADE in GLADE environments. Now, all this has become the past: Anjuta was born!

Anjuta's ability to use GLADE to generate graceful user interfaces, coupled with its own powerful source editing capabilities, is becoming an integrated environment (IDE) for rapid application development. Previously, people used GLADE to do the interface, using Emacs or VI and so on to edit the program, and then use some kind of terminal simulator to edit the development project. With Anjuta, all these miscellaneous tasks can be done in a unified, integrated, and natural environment.

First, software preparation:

Download libzvt-2.0.1-0.ximian.6.6.i386.rpm

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

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

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

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

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

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

Download glademm-1.1.3d-snap.i586.rpm

loban.caltech.edu/gchch/glademm-1.1.3d-snap.i586.rpm

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

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

Second, install the package


Install the Redhat Linux 9 option to install the software development item, so that the Glade is installed, and then the root user is logged in to install the following package.

RPM-IVH libzvt-2.0.1-0.ximian.6.6.i386.rpm//anjuta Dependency Package
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: The direct installation anjuta-1.1.97 will find that the software can not be compiled, here should pay attention to a few problems

1, to install the Ximian version of the LIBZVT software package, is to install I mentioned above
2, first installs Anjuta 1.0.1, then updated via RPM-UVH Anjuta 1.1.97

Third, carry out the development of the first Anjuta1.1.97 on C + + program

Let's start with Anjuta to build a simple Hello World program.

To create a new project

Please open Anjuta first. Please choose menu item Programming-> more programming tools-->anjuta IDE. The Gnome Application Wizard "GNOME2.0 application Wizard" will appear. Although people simply click on the "Next" button and do not have to go through the wizard dialog box, here is the hope that you can read every piece of information on the dialog. Now, after you have read the information on the first step of the wizard dialog, press the Next button.

The second step is critical. Here you need to decide the type of application you want to build. Let's choose "Gnome2.0 Project" and go on. The third step is to determine the basic configuration of your application. Please fill in the application configuration information very carefully. In this tutorial, please enter the following information.

Project Name: HelloWorld (Program project name) Note No spaces in the middle of the project name
Program version: 0.1 (version number)
Program Author: (Your name)
Program Name: HelloWorld (program name)
Program language: C,c++ and C/C + + three choices, here is the choice of
Program type: There are three choice executable programs, dynamic link library and static link library.

The fourth step below is to write a description of the project;

The fifth step is the project's other options, GNU Copyright notices and program localization support items, if you don't want to, you can remove them. You may want to select an icon for this application project that will appear in the Gnome application menu. Here we select Hello World example as the project name and select applications in the Group domain. Finally, click the Next button and the Finish button. The application project is now set up.

Because we are just building an example program, we can move forward easily. If we are building an application project to be used in the real world, we should be careful when filling in the parameters of each step of the application wizard, because they are very important to your application project.

  Designing the user interface

At the end of the conversation with the Application wizard, Anjuta begins to build the directory structure of your application project, run the parameter configuration scripts, and establish the application project itself. The entire creation process is shown in the lower part of the Anjuta development environment. When the creation process is complete, the left side of the screen shows the application project tree structure. This tree structure contains your source program files, description files, and graphics files.


Figure 1

It's time to start GLADE and use it to design a graphical user interface. Please go to the menu item Item-> Edit the graphical interface to run GLADE. You will see three windows: 1 Glade main window, 2 Property window, and 3 drawing tool window.

Just take a simple GTK window and do it. Click the first item (HELLO_APP) listed on the Glade main window and press Del to delete the key. Now to the tool window (Palette), click on the first icon. Then a blank Gtkwindow was built. This will be the main window Window1 of our application. Then to the Property window (properties), typing the title "Hello world!". Now go to the tool window and select a table (table) 2 rows 2 columns to place on the main window Window1. In this way, the main window is cut into 4 parts of the same size.

Now remove the two buttons from the tool window and add them to the two boxes below the main window. Then set the name and label properties of the two buttons as follows:

Left button:
Name: BT_OK
Tags: OK
Right button:
Name: Bt_exit
Tags: Exit

In the top half of the window, add a Label control to the left, and an input box to the right of the upper half to Entry the control. The name of the input box is ENTRY. Place the Label property of the Label control as ' What ' your name,sir? '.

Now connect the two buttons on the property file (Signals tab) of the Properties window with the clicked event. Use the Glade preset reverse call Function name. Please do not forget to click the Add button. This common error can result in the creation of a blank callbacks.c file. On the source file callbacks.c, we will add the source code through the Anjuta interface.

Now, the main window does not look so beautiful. You can try changing the width and height of the window and try to change the properties of the horizontal and vertical containment boxes to see if you can make the window look better. (Note: You can go to menu view, select the control tree, and then select the control.) The following are the settings for some properties:

* Homogeneous the properties of the horizontal containment box below to Yes;
* Set the properties of the button of the positioning file of the property window to Yes;
* Grow the properties of the main window Window1 to No.

After changing these properties, my main window looks as follows:


Figure 2

After designing the interface, click on the "Save" button on the main window of the Glade, then click on the "link Edit" button. This updates the source file interface.c of your application project's SRC directory according to your newly designed interface. Now, let's Select the menu Project-> Exit and return to the Anjuta user interface. Start programming!

  editing programs

Now back in the Anjuta environment, you should be able to see callbacks.c in the list of project sources on the left side of the screen. Double click to open the program. This allows us to edit the program on the left side of the Anjuta integrated development environment.

Sometimes a thing becomes easier to understand and more interesting if it is colored. This is the case for Anjuta's syntax accent color feature (on the Format menu). Anjuta also has a lot of useful features, you can play slowly. Maybe it's good to take some time to familiarize yourself with this integrated environment.

Now back to the callbacks.c file, we see two reverse call functions: on_bt_ok_clicked and on_bt_exit_clicked. Let's add a function call to 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 ();
}

The purpose of this function call is that the entire application will end when the user clicks 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 target code, execution, and distribution.

Now it's time to test your program; it must be fun. First select the menu item to create-> create the project. Then Anjuta starts compiling and linking the source program in the project MAIN.C, interface.c, support.c and CALLBACKS.C, and then the resulting executable file hello to the src directory. The compiler typically uses GCC.

If you are lucky that the compilation process does not have any error messages, select the menu item "Create-> Execute program" So Anjuta opens up a terminal window and runs your application on it helloworld! Please enter your name in the input box and click the OK button. Hopefully, your application will back you up with a greeting: Hello ... You can then typing a greeting, and then click Exit button to see if the program can exit normally. If the normal exit, that's good! Your hard work has finally come to an end!

You can then install your application into a Windows system: Select menu items to create a-> installation although you may not want to create a tarball file for your application right now, you may need to do so later when you want to release the software. Before you release the application, be sure to fill in the Todo,changelog,install and README files. To create an application release, click Create-> Create a release suite The process may last a few seconds and eventually create a file in the/home/(username)/projects/helloworld/Directory Helloworld-0.1.tar.gz.

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.