Establish development environments such as C, C ++, and GTK in Ubuntu

Source: Internet
Author: User
I want to learn about C and C ++ Program Development in Linux. I have been studying the establishment of the C language compiling environment in Linux over the past few days, because the library file is missing in the newly installed ubuntu, therefore, it is impossible to compile the simplest C language file. Therefore, you must first configure it. I have some experiences over the past few days. I will write it down and learn it with you.
I thought it was very troublesome to install the configuration, and then I found that with the help of a new one, I can quickly configure it (on the premise that your source network speed is faster ).
I first installed a new ubuntu7.10, and configured the source, input method, and Chinese environment according to the help in the Wiki. Then, configure the compiling environment.

1. Configure gcc
The newly installed system already has GCC, but no GCC file can be compiled. Because there are no necessary header files, you need to install the build-essential software package.
Installed with this package will automatically install g ++, libc6-dev, Linux-libc-Dev, libstdc ++ 6-4.1-dev and other necessary software and header files
Library.
You can search for build-essential in the new version or enter the following command:

Code:
Sudo apt-Get install build-essential

After the installation is complete, write a C language program testc. C to test it.

Code:
Int main ()
{
Printf ("Hello Ubuntu! /N ");
Return 0;
}

Code:
$ GCC testc. C-o testc
$./Testc

Display
Hello Ubuntu!
In this way, the C language compiler is successfully installed;

2. Install the GTK Environment

To install the GTK environment, you only need to install a gnome-core-devel, which integrates many other packages. In addition, we need to convert some other things, such as libglib2.0.
-Doc, libgtk2.0-Doc help document, devhelp help document view, Glade-gnome, Glade-common, Glade-Doc Diagram
Interface design.

Code:
Sudo apt-Get install gnome-core-devel
Sudo apt-Get install libglib2.0-Doc libgtk2.0-Doc
Sudo apt-Get install devhelp
Sudo apt-Get install Glade-gnome Glade-common Glade-Doc

After the installation is complete, we also make a test program.

Code:
# Include <GTK/GTK. h>
Void Hello (gtkwidget * widget, gpointer data)
{
G_print ("Hello Ubuntu! /N ");
}
Gint delete_event (gtkwidget * widget, gdkevent * event, gpointer data)
{
G_print ("delete event occurred/N ");
Return (true );
}
Void destroy (gtkwidget * widget, gpointer data)
{
Gtk_main_quit ();
}
Int main (INT argc, char * argv [])
{
Gtkwidget * window;
Gtkwidget * button;
Gtk_init (& argc, & argv );
Window = gtk_window_new (gtk_window_toplevel );
Gtk_signal_connect (gtk_object (window), "delete_event", gtk_signal_func (delete_event), null );
Gtk_signal_connect (gtk_object (window), "Destroy", gtk_signal_func (destroy), null );
Gtk_container_set_border_width (gtk_container (window), 10 );
Button = gtk_button_new_with_label ("Hello Ubuntu! ");
Gtk_signal_connect (gtk_object (button), "clicked", gtk_signal_func (Hello), null );
Gtk_signal_connect_object (gtk_object (button ),
"Clicked", gtk_signal_func (gtk_widget_destroy), gtk_object (window ));
Gtk_container_add (gtk_container (window), button );
Gtk_widget_show (button );
Gtk_widget_show (window);/* display a window */
Gtk_main ();/* enter the main loop */
Return (0 );
}

Compile and run the following command:

Code:
$ GCC gtkhello. C-o gtktest 'pkg-config -- cflags -- libs GTK +-1000'
$./Gtktest


A window with a button is displayed. click the button to close the window. The command line displays Hello Ubuntu!

3 QT/KDE

Libraries and tools (software packages ):

Code:
Kdesdk


Library and tool documentation (Software Package ):

Code:
Kdesdk-doc-html


IDE (Software Package ):

Code:
Kdevelop


IDE documentation (Software Package ):

Code:
Kdevelop-Doc

This article Reprinted from http://forum.ubuntu.org.cn/viewtopic.php? T = 40971


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.