[Linux + C] new journey C Programming in linux

Source: Internet
Author: User

Before the opening

I believe that many students choose. net, java, Or something like bugs. To some extent, they are not subjective, but forced to work. As for why the Microsoft faction wants to go to linux again, I don't want to provoke a so-called factional debate here. Even if the first bug was programming in linux, windows would be replayed today.

In addition, I would like to tell you the good news that c #, the programming language ranking in February, has reached the fourth place ~ ~

At the beginning of this article, worms will learn programming in linux with people who share the same interests. Many people speak the same language, and each pass is a hundred links. Here I will not speak out, just want to say that the cloud is not good. Different programming languages have different application scenarios and fields. You asked c coder to develop web applications, and he would chase you across the street with a broom. You asked c # coder to develop underlying support systems related to O & M. He could only smile. In addition, the bugs in this series do not want to discuss with you about mono running. net in linux. Simply be a linux enthusiast from Microsoft ~ ~ The application and popularization of the Linux operating system in the server field has a long history, which stems from its open-source features and its security and stability surpassing that of Windows.

Linux coder does not need to read the communication between the new and new beginners in this series. As a result, it has suffered a lot from the beginning of 0. This series has been recorded, so that later users do not have to fill in any traps.


--------------------------------------------------------------------------------

Select

System: ubuntu10.10

Development Tool: eclipse cdt version

Development language: C

Those who have read the previous blog post of worms should know the reason for choosing these. These have been used in fastdfs APIs before and are a little familiar with them. However, blog posts will restart from 0 to explain the entire process.


--------------------------------------------------------------------------------

Learning Materials

Ubuntu community: http://forum.ubuntu.org.cn/

Mandatory: http://people.ubuntu.com /~ Happyaron/udc-cn/

Eclipse JRE :. Http://www.oracle.com/technetwork/java/javase/downloads/index.html

Eclipse cdt version: http://www.eclipse.org/downloads/

C


--------------------------------------------------------------------------------

Environment

Run the terminal after installing ubuntu

 

Run the sudo su command.

Enter the password and get the root permission.

Run the command nautilus to manage folders as Administrator roles

 

You can download the required resources in the browser.

You can also use wget

 

Check important libevent Libraries

If not, click here.

Wget http://www.monkey.org /~ Provos/libevent-2.0.12-stable.tar.gz

For programs developed on the linux operating system, gcc alone is not acceptable.
It also requires a build-essential Software Package

That is to say, only when the Compilation Program has this software package can it know where the header file is and where the library function is.
The dependent software package will be downloaded to form a development environment. Of course, the dependency package required for the build-essential package installation is unavailable to you.

Check the most common vim

First hello world

First, let's try it with the traditional notepad.

Use the cd command to select a directory and then create a new c-type file under the directory.

 

Write a simple c program

? 1234567 # include <stdio. h> intmain (void) {printf ("Hello, world! \ N "); return 0 ;}

Compile with gcc

Assume that the source program file name is chongzi. c.

1. No option to compile the link
Usage: # gcc chongzi. c
Function: Pre-processes, assembles, compiles, and links chongzi. c to form executable files. The output file is not specified here. The default output is a. out.

2. Option-o
Usage: # gcc chongzi. c-o chongzi
Function: Pre-processes, assembles, compiles, and links chongzi. c to form the executable chongzi. The-o option is used to specify the name of the output file.

3. Option-E
Usage: # gcc-E chongzi. c-o chongzi. I
Purpose: print the chongzi. c preprocessing to the chongzi. I file.

4. Option-S
Usage: # gcc-S chongzi. I
Purpose: Compile the pre-processing output file chongzi. I into the chongzi. s file.

5. Option-c
Usage: # gcc-c chongzi. s
Purpose: Compile the chongzi. s Assembly output file and output the chongzi. o file.

6. No option Link
Usage: # gcc test. o-o chongzi
Purpose: link the compiled output file chongzi. oto the final Executable File chongzi.

7. Option-O
Usage: # gcc-O1 chongzi. c-o chongzi
Purpose: Use compile optimization level 1 to compile the program. Level 1 ~ 3. The higher the level, the better the optimization effect, but the longer the Compilation Time.

Run the generated program

Use Eclipse to play c Programs

 

Starting the Eclipse cdt version will initially make everyone who has set up a workspace and played java very familiar with copying it.

Here we create a new c Project

 

Set Project Properties

 

If you load an existing project, set the path in the default location.

However, many programs use make. sh to generate and execute the command. You need to change the configuration in the property.

Compile and run

Gbd debugging

Many c bulls are not debugging this way. They are writing logs !!!!

But I will not talk about how to debug it at 1.1 points.

Recommend a link http://fanqiang.chinaunix.net/program/other/2006-07-14/4834.shtml

 

Author: stay up late bugs
 

 

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.