Linux program entry

xiaoxiao2021-03-06  109

Here you introduce some entry-level knowledge of C / C programming on Linux / UNIX machines.

· Background knowledge required

· The basic environment required to develop

· Wid to get help

· Understand basic steps through an instance

· Data recommendations for various tools and system learning

This article is only an overview, and some of the most basic things are summarized, and the programming involves a lot of tools, and everyone needs to learn from shallow depth.

First www.loveunix.net 2004-04-07Modified 2004-10-14 by carol

Prerequisite Prerequisites:

Write a C program on Linux, at least familiar with the basics of the following aspects: 1. C language programming foundation, at least know some basic grammar, control process, etc. programming common sense. There is a common understanding of the commonly used standard C function library. 2. For Linux / UNIX's operations have common sense, master common shell commands, such as LS, CAT, CP, MKDIR ... etc ... ETC.

Environment Requirements: 1. Linux / UNIX operating system, you can also use Cygwin software under Windows to simulate Linux, but you cannot guarantee all functions. You can also consider installing a Linux environment using VMware on Windows. We will introduce it later about Cygwin and VMware.

We discussed here all by the shell command line. What should I do if I enter Linux in the graphical interface? Just open a terminal program, it is exactly the same as the command line environment (open the start menu to find the terminal command). 2. Essential Development Tools: 1) The input program requires an editor. Commonly used VI, Emacs. Enter vi, Emacs on the command line, ... you can enter the editing environment. To learn more, it is recommended to see unparalleled VI tutorial. I usually use Emacs, so some reference information about Emacs is also included.

2) C language compiler. Commonly used is a GNU C language compiler GCC (compile C program), G (compiled C programs).

Specifically learn the use of GCC / G . When writing large programs, manually entering a gcc command that is very troublesome, at this time, you can use the Makefile tool to simplify the compilation process.

Here is a entry article Linux under C language program - basic knowledge, you can first look at it.

3) Common tools for debugging: GDB. About GDBGET HELP get more help: About Linux documents are very rich. The fastest, convenient, comprehensive information is in your machine, do not waste. Enter the shell command MAN or Info on the command line:

$ Man GCC

This command can get the document of the GNU's C language compiler. Of course, they are English. Enter commands in the command line to see the relevant resources on the LOVEUNIX technology forum >>> Some of the unparalleled replenishment of Linux, entry-door programming information >>>>

Basic Steps Basic Steps: 1. Enter the source code 2. Compile, link, run 3. Debugger We start from the most basic Hello World program: 1. Enter the source code

$ EMACS Hello.c // Enter the Emacs Editor Environment #include // If you don't understand this function, go to the C language book int main () {Printf ("Hello World.n "); // EMACS environment, press the Tab key, have an automatic indentation function exit (0);} Hold down the CTRL button, press X, press C, finally release Ctrl (usually book The top table reached Ctrl-x Ctrl-C or CX, CC). The program retains and exits the EMACS environment. 2. Compile, link, run

$ gcc -o hello hello.c $ ./HELLO / /. The path to the executed program is the current directory Hello World. $

The C program development on a Linux platform has been completed. Debug If you want to use a GDB debugger, then when you are compiled, you can remember to add -g option

$ GCC -G -O Hello Hello.c $ gdb hello // Enter GDB debugging environment

4. CVS version control software - Tools for collaborative work and retention

Learn a good book recommendation for Linux program programming:

Linux program design

Advanced Programming of UNIX Environment, is very famous, commonly known as APUE

Advanced Linux Programming

The Art of Unix Programming

All the above books have downloaded, it is recommended to choose the buying back system for yourself.

There are also a lot of information on the Internet.

Development tools:

Cygwin

WinCVS Confidential Operation Guide by Chen Xianbo

VMware

Installing Red Hat Linux 9 in VMware by unknown

vi

Vim Junior Tutorial By Unparalleled

Emacs

Emacs use step by step by carol

GCC

Makefile

Write Makefile by with me

Chen Hao

GDB

Recommended learning site:

LOVEUNIX Technology Forum

Program design

Chinaunix

Essence

LinuxSir

LinuxForum

转载请注明原文地址:https://www.9cbs.com/read-97475.html

New Post(0)