linux c语言编程,在终端输出"how are you",Linux下面如何进行C语言编程(国外英文资料).doc...

Linux下面如何进行C语言编程(国外英文资料)

Linux下面如何进行C语言编程(国外英文资料)

Compile the source program

Under Linux, if you want to compile a C source program, we will use GNU's GCC compiler. Here is an example

How to use the GCC compiler.

Suppose we have the following very simple source program (hello.c) :

Int main (int argc, char * * argv)

{

Printf (" Hello Linux \ n ");

}

To compile this program, we simply execute on the command line:

GCC -o hello hello. C

GCC compiler will generate a hello executable files for us.. / hello, you can see the output of the program. The command line to GCC says we are in GCC to compile the source program, we -o said we ask the compiler to give us the output of an executable file named hello, hello. Is our c source program files.

GCC compiler has many options, generally we only know a few of them will be enough. -o option we already know, said we require the output of the executable file name. The -c option said we only request object code compiler output, output and unnecessary executable file. The -g option said we are asking the compiler when compiling information after we debug the program.

Know the three options, we can build our own source program written in simple, if you want to know more options, you can view the GCC documentation, there are many details of other options.

2. Write a Makefile

Suppose we had a program like this, source code as follows:

/ *...

# include "mytool1. H"

# include "mytool2. H"

Int main (int argc, char * * argv)

{

Mytool1_print (" hello ");

Mytool2_print (" hello ");

}

/ * mytool1.h * /

# # ifndef _MYTOOL_1_H

# define _MYTOOL_1_H

Void mytool1_print (char * print_str);

# endif

/ * mytool1.c * /

# include "mytool1. H"

Void mytool1_print (char * print_str)

{

Printf (" This is mytool1 print % s \ n ", print_str);

}

/ * mytool2.h * /

# # ifndef _MYTOOL_2_H

# define _MYTOOL_2_H

Void mytool2_print (char * print_str);

# endif

/ * mytool2.c /

# include "mytool2. H"

Void mytool2_print (char * print_str)

{

Printf (" This is mytool2 print % s \ n ", print_str);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值