Linux C/C ++ Development Environment Setup Guide

Source: Internet
Author: User

Ubuntu does not use the built-in C/C ++ development environment. You need to configure it yourself. A collection of posts in the Ubuntu Chinese forum.

1. Install the basic development environment

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 ubuntu6.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 file library.
You can search for build-essential in the new version or enter the following command:

sudo apt-get install build-essential

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

#include<stdio.h>int main(){   printf("Hello Ubuntu!\n");   return 0;}

$ 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, some other things need to be transferred, such as libglib2.0-Doc, libgtk2.0-Doc help document, devhelp help document view, Glade-gnome, Glade-common, and Glade-Doc graphic interface design.

sudo apt-get install gnome-core-develsudo apt-get install libglib2.0-doc libgtk2.0-docsudo apt-get install devhelpsudo apt-get install glade-gnome glade-common glade-doc

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

# 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 (break ), gtk_object (window); gtk_container_add (gtk_container (window), button); gtk_widget_show (window);/* display a window */gtk_main (); /* enter the main loop */Return (0 );}

Compile and run the following command:

$ gcc gtkhello.c -o gtktest `pkg-config --cflags --libs gtk+-2.0`$ ./gtktest

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

GTK Testing

C Language Testing

2. Install IDE development tools
Famous development tools include kdeveloper, anjuta, eclipse + CDT.
Here, kdeveloper is a KDE platform. On the gnome platform, you need to install a lot of KDE. If you don't like it, you give up. Although it is said that kdeveloper is powerful. Eclipse + CDT seems to be good for use, but there are two main points of discomfort, one is that the Code cannot be automatically completed, and the other is that the compilation speed is slow.
Install and configure eclipse + CDT.

The Java Runtime Environment and eclipse3.3.0 installation are not described in detail.
See: http://blog.chinaunix.net/u/21684/showart_384208.html for details
1. Download CDT (http://www.eclipse.org/cdt/downloads.php) (only 4.0.x can be downloaded, if it is eclipse3.3.0 other select the appropriate version)
2. Install the CDT plug-in (the links method to install the plug-in to facilitate plug-in management)
A. Create a folder named CDT in the eclipse directory (eclipse_home ).
Create a folder eclipse in the folder CDT (don't be surprised that it is eclipse)
B. decompress the content in the downloaded cdt-master-4.0.0.zip file to/eclipse_home/CDT/eclipse.
C. Create a folder named links in eclipse_home.
Add the file CDT. Link to the new links. The file content is Path =/eclipse_home/CDT.
For example, my path =/opt/Eclipse/CDT
D. Complete the installation of the CDT plug-in. Start eclipse and you will see more C and C ++ development environments.

3. install and configure anjuta
A. Ubuntu feisty (for gusty, see below) Repository (only i386 and only binaries)

1. Add Deb http://anjuta.org/apt./In Your/etc/APT/sources. List
2. sudo apt-Get update
3. sudo apt-Get install anjuta
4. sudo apt-Get install anjuta-dev libgbf-dev libgdl-Dev (if you want to write anjuta plugins or report bugs)

Note !! If you have installed older anjuta-2.2.0 previusly using this repository, make sure to remove the file/etc/APT/preferences or remove the following version pin from the file before following the above steps. the version pin is no longer needed:


B. Ubuntu gusty Repository

1. Add Deb http://ppa.launchpad.net/robster/ubuntu gutsy universe in your/etc/APT/sources. List
2. sudo apt-Get update
3. sudo apt-Get install anjuta
4. sudo apt-Get install anjuta-dev libgbf-dev libgdl-Dev (if you want to write anjuta plugins or report bugs)


Note: We recommend that you use the new version.


Topic: QT vs GTK/GTK +

QT is a multi-platform C ++ graphical user interface application framework. It provides the functions required for application developers to create an artistic graphical user interface. QT is fully object-oriented and easily scalable, and allows true component programming. Since the beginning of 1996, QT has entered the business field and has become the basis for thousands of successful applications around the world. QT is also the basis for the popular Linux Desktop Environment Kde, which is a standard component of all major Linux distributions.

Qt supports the following platforms:
* MS/Windows-95, 98, NT 4.0, me, and 2000 * UNIX/X11-Linux, Sun Solaris, HP-UX, Compaq Tru64 UNIX, ibm aix, sgi irix and many other X11 platforms * Macintosh-Mac OS X * embedded-Frame Buffer) supported Linux platforms.

QT is a product of trolltech. QT is released according to different versions:

Qt Enterprise Edition and QT Professional edition are provided for commercial software development. They provide traditional commercial software releases and free upgrades and technical support services. To get the latest offer, go to the price and feasibility page on trolltech's website or contact your sales@trolltech.com. The Enterprise Edition has more extension modules than the Professional Edition.

Qt Free Edition is a UNIX/X11 version provided by QT only for the development of free and open source software. Under the Q Public License and the GNU General Public License, it is free of charge. The latest version can be downloaded here.

QT/Embedded Free Edition is an embedded version provided by QT to develop free software. It is free of charge under the GNU General Public License.

C naturally chooses GTK +, C ++ chooses QT. Generally. Qt comes out earlier than the C ++ standard, so it is different from the standard C ++. I heard that C ++ of QT is not pure. GTK + is also bound to other languages. c ++'s gtkmm and Python's pygtk can be used across platforms, but wxwidget seems to have more people to choose from across platforms.
I used a short time to choose what tool to program in Linux, and now I chose QT. I think you can use any tool to compile some small programs, we can't go back to the previous situation where everything was done by ourselves under the crisp C. In this way, people are trained, but their time is limited. QT is a good choice when we need to deal with large programs. There are only a few users currently. Qt can be associated with VC in windows, which is really good news for those of us who are familiar with VC! I still only use the open-source version, and I want to use its enterprise version better in the future.

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.