安徽理工大学:《Linux开发基础 Development Foundation on Linux OS》课程教学资源(PPT课件讲稿)Section 2、3 GNU C/C++编程(CGI programming in GNU C/C++ language)

安藏理工大学 ANHUI UNIVERSITY OF SCIENCE TECHNOLOGY Section 2 GNU C/C++programming 3
3 Section 2 GNU C/C++ programming

安藏理工大学 ANHUI UNIVERSITY OF SCIENCE TECHNOLOGY What is GNU? The GNU operating system is a complete free software system,upward-compatible with Unix.GNU stands for "GNU's Not Unix".Richard Stallman made the Initial Announcement of the GNU Project in September 1983. Source: http://www.gnu.org/gnu/initial- announcement.html 4
4 What is GNU? ➢ The GNU operating system is a complete free software system, upward-compatible with Unix. GNU stands for “GNU's Not Unix”. Richard Stallman made the Initial Announcement of the GNU Project in September 1983. Source: http://www.gnu.org/gnu/initialannouncement.html

安藏理工大学 ANHUI UNIVERSITY OF SCIENCE TECHNOLOGY What is Free Software? > "Free software"is a matter of liberty,not price.To understand the concept,you should think of "free"as in "free speech",not as in "free beer". > Free software is a matter of the users'freedom to run,copy, distribute,study,change and improve the software.More precisely, it refers to four kinds of freedom,for the users of the software: The freedom to run the program,for any purpose (freedom O). The freedom to study how the program works,and adapt it to your needs(freedom 1).Access to the source code is a precondition for this. The freedom to redistribute copies so you can help your neighbor (freedom 2). ▣ The freedom to improve the program,and release your improvements to the public,so that the whole community benefits (freedom 3).Access to the source code is a precondition for this. 5
5 What is Free Software? ➢ “Free software” is a matter of liberty, not price. To understand the concept, you should think of “free” as in “free speech”, not as in “free beer”. ➢ Free software is a matter of the users' freedom to run, copy, distribute, study, change and improve the software. More precisely, it refers to four kinds of freedom, for the users of the software: The freedom to run the program, for any purpose (freedom 0). The freedom to study how the program works, and adapt it to your needs (freedom 1). Access to the source code is a precondition for this. The freedom to redistribute copies so you can help your neighbor (freedom 2). The freedom to improve the program, and release your improvements to the public, so that the whole community benefits (freedom 3). Access to the source code is a precondition for this

安藏理工大学 ANHUI UNIVERSITY OF SCIENCE TECHNOLOGY What is gcc? >GCC,the GNU Compiler Collection. >The GNU Compiler Collection includes front ends for C,C++,Objective-C,Fortran,Java, and Ada,as well as libraries for these languages (libstdc++,libgcj,...).GCC was originally written as the compiler for the GNU operating system.The GNU system was developed to be 100%free software,free in the sense that it respects the user's freedom. Source:http://gcc.gnu.org 6
6 What is gcc? ➢ GCC, the GNU Compiler Collection. ➢ The GNU Compiler Collection includes front ends for C, C++, Objective-C, Fortran, Java, and Ada, as well as libraries for these languages (libstdc++, libgcj,...). GCC was originally written as the compiler for the GNU operating system. The GNU system was developed to be 100% free software, free in the sense that it respects the user's freedom. Source: http://gcc.gnu.org

安藏理工大学 ANHUI UNIVERSITY OF SCIENCE TECHNOLOGY 2.1GNUC/C++编译器的使用 gcc通过扩展名来判断文件的类型,从而确定用何种方式处理该文件 后缀名 说明 .c C语言源代码文件 .C/.cc/.cxx C++源代码文件 .h 程序所包含的头文件 i 已经预处理过的C语言源代码文件 .ii 已经预处理过的C++源代码文件 .m Objective-C语言源代码文件 .S 汇编语言源代码文件 .S 经过预编译的汇编语言源代码文件 .a/.so 编译后的库代码 .0 编译后的目标文件
7 后缀名 说明 .c C语言源代码文件 .C/.cc/.cxx C++源代码文件 .h 程序所包含的头文件 .i 已经预处理过的C语言源代码文件 .ii 已经预处理过的C++源代码文件 .m Objective-C语言源代码文件 .s 汇编语言源代码文件 .S 经过预编译的汇编语言源代码文件 .a/.so 编译后的库代码 .o 编译后的目标文件 2.1 GNU C/C++编译器的使用 gcc通过扩展名来判断文件的类型,从而确定用何种方式处理该文件

安藏理工大坚 ANHUI UNIVERSITY OF SCIENCE TECHNOLOGY 2.1GNUC/C++编译器的使用 gcc编译器选项和参数 参数 含义 -o Place the output into -c Compile and assemble,but do not link -ggdb Produce debugging information for use by GDB. -0 the compiler tries to reduce code size and execution time, without performing any optimizations that take a great deal of com-pilation time. -9 Produce debugging information in the operating system's native format.GDB can work with this debugging information. -I Add the directory dir to the list of directories to be searched for header files.Directories named by-I are searched before the -L Search the library named library when linking 8
8 2.1 GNU C/C++编译器的使用 gcc 编译器选项和参数 参数 含义 -o Place the output into -c Compile and assemble, but do not link -ggdb Produce debugging information for use by GDB. -O the compiler tries to reduce code size and execution time, without performing any optimizations that take a great deal of com-pilation time. -g Produce debugging information in the operating system's native format. GDB can work with this debugging information. -I Add the directory dir to the list of directories to be searched for header files. Directories named by -I are searched before the -L Search the library named library when linking

安藏理工大學 ANHUI UNIVERSITY OF SCIENCE TECHNOLOGY 2.1GNUC/C++编译器的使用 1、直接通过编译生成目标代码可执行文件: $gcc hello.c -o hello 2、如果一个程序包含有多个源文件,则也可直接生成目标代码: void f1() f printf“y%sln”,"function1")月 } void f2() { printf("%sIn","function 2"); main() { 10; 20时 } $gcc f1.c f2.c main.c -o main 9
9 2.1 GNU C/C++编译器的使用 1、直接通过编译生成目标代码可执行文件: $gcc hello.c –o hello 2、如果一个程序包含有多个源文件,则也可直接生成目标代码: void f1() { printf(“%s\n”, "function 1"); } void f2() { printf("%s\n", "function 2"); } main() { f1(); f2(); } $gcc f1.c f2.c main.c –o main

安藏理工大学 ANHUI UNIVERSITY OF SCIENCE TECHNOLOGY > Linux.上广泛使用的C语言编译器是GNUC编译器,GNU C建立在自由软件基金会的编程许可证的基础上,可以自 由发布。在Liux下,一个完整的C语言开发环境到少包 括以下三个组成部分 √函数库glibc(在/usr/八ib和/ib目录中) √ 编译器gcc √ 系统头文件glibc_header(*.h) >gbc是构成一个完整的C语言开发环境所必不可少的组成 部分,也是Linux下C语言的主要函数库。 > glibc headerr中包含了系统编译源代码所需要的声明文 件,如果缺少系统头文件,很多用到系统功能的C程序将无 法编译。(包含在/usr/include/及其子目录中) 10
10 ➢ Linux上广泛使用的C语言编译器是GNU C编译器,GNU C建立在自由软件基金会的编程许可证的基础上,可以自 由发布。在Linux下,一个完整的C语言开发环境到少包 括以下三个组成部分: ✓函数库glibc (在/usr/lib和/lib目录中) ✓编译器gcc ✓系统头文件glibc_header (*.h) ➢ glibc是构成一个完整的C语言开发环境所必不可少的组成 部分,也是Linux下C语言的主要函数库。 ➢ glibc_header中包含了系统编译源代码所需要的声明文 件,如果缺少系统头文件,很多用到系统功能的C程序将无 法编译。(包含在/usr/include/及其子目录中)

安藏理工大学 ANHUI UNIVERSTTY OF SCIENCE TECHNOLOGY 2.2 GNUC/C+函数库 定义:是一些预先编译好的函数的集合,那些函数都是按照可再使用 的原则编写的。它们通常是一组相互关联的用来完成某项常见工作的 函数构成(比如c库里面的标准输入输出函数、时间函数和数学函数 等)。 >函数库中的函数可以通过连接程序与应用程序进行连接,而不必在每 次开发程序时都对这些通用的函数进行编译。 不同类型的应用程序将会使用不同的函数库。如数学应用将使用数学 库libm(/usr/ib/Iibm.a,/usr/Iib/ibm.so),标准的C库 libc(/usr/lib/libc.a,/usr/lib/libc.so). 注意:*.h只是对函数的声明(declaration),函数的定义是在具体的函 数库中 11
11 2.2 GNU C/C++函数库 ➢ 定义:是一些预先编译好的函数的集合,那些函数都是按照可再使用 的原则编写的。它们通常是一组相互关联的用来完成某项常见工作的 函数构成(比如c库里面的标准输入输出函数、时间函数和数学函数 等)。 ➢ 函数库中的函数可以通过连接程序与应用程序进行连接,而不必在每 次开发程序时都对这些通用的函数进行编译。 ➢ 不同类型的应用程序将会使用不同的函数库。如数学应用将使用数学 库libm(/usr/lib/libm.a, /usr/lib/libm.so),标准的C库 libc(/usr/lib/libc.a,/usr/lib/libc.so)。 注意:*.h只是对函数的声明(declaration),函数的定义是在具体的函 数库中

安藏理工大学 ANHUI UNIVERSITY OF SCIENCE TECHNOLOGY > 所有的程序都将使用标准的C函数库bc,该库中包含了内存管理或 输入输出操作的基本函数,这些库都存放在/usr/b或/ib这些系统 公用的目录中,系统中的任何用户都可以利用这些库。 注:用户可以自己定义自己的函数库! 库可以有三种使用的形式: 静态库(*.):代码在编译时就已连接到开发人员开发的应用程序 中。静态库在程序编译时会被连接到目标代码中,程序运行时将 不再需要该静态库 1 共享库(shared object,以*.so作为后缀):只是在程序开始运行 时才载入,在编译时,只是简单地指定需要使用的库函数。 动态库:是共享库的另一种变化形式,也是在程序运行时载入 使用的库函数不是在程序运行开始,而是在程序中的语句需要使 用该函数时才载入。类似于windows OS中的DLL文件。 12
12 ➢ 所有的程序都将使用标准的C函数库libc,该库中包含了内存管理或 输入输出操作的基本函数,这些库都存放在/usr/lib或/lib这些系统 公用的目录中,系统中的任何用户都可以利用这些库。 注:用户可以自己定义自己的函数库! ➢ 库可以有三种使用的形式: ✓ 静态库(*.a):代码在编译时就已连接到开发人员开发的应用程序 中。静态库在程序编译时会被连接到目标代码中,程序运行时将 不再需要该静态库 ✓ 共享库(shared object,以*.so作为后缀):只是在程序开始运行 时才载入,在编译时,只是简单地指定需要使用的库函数。 ✓ 动态库:是共享库的另一种变化形式,也是在程序运行时载入, 使用的库函数不是在程序运行开始,而是在程序中的语句需要使 用该函数时才载入。类似于windows OS中的DLL文件
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 安徽理工大学:《Linux开发基础 Development Foundation on Linux OS》课程教学资源(PPT课件讲稿)Section 1 Shell编程 Shell programming on Linux OS.ppt
- 清华大学出版社:《智能技术》课程教学资源(PPT课件讲稿)第8章 机器学习 machine learning.ppt
- 清华大学出版社:《智能技术》课程教学资源(PPT课件讲稿)第4章 模糊逻辑技术 fuzzy logic(编著:曹承志).ppt
- 清华大学出版社:《智能技术》课程教学资源(PPT课件讲稿)第6章 遗传算法(genetic algorithms,GA).ppt
- 安徽理工大学:《计算机安全与密码学 Computer Security and Cryptography》课程教学资源(课件讲稿)密钥管技术理 Key Management.pdf
- 哈尔滨工程大学:《计算机安全与密码学 Computer Security and Cryptography》课程教学资源(课件讲稿)数字签名技术 Digital Signature.pdf
- 哈尔滨工程大学:《计算机安全与密码学 Computer Security and Cryptography》课程教学资源(课件讲稿)公钥密码体制 Public Key Cryptography.pdf
- 哈尔滨工程大学:《计算机安全与密码学 Computer Security and Cryptography》课程教学资源(课件讲稿)散列函数与消息认证码 Hash and Message Authentication Code.pdf
- 哈尔滨工程大学:《计算机安全与密码学 Computer Security and Cryptography》课程教学资源(课件讲稿)序列密码 Sequential Cipher.pdf
- 哈尔滨工程大学:《计算机安全与密码学 Computer Security and Cryptography》课程教学资源(课件讲稿)分组密码 Block Cipher.pdf
- 安徽理工大学:《计算机安全与密码学 Computer Security and Cryptography》课程教学资源(课件讲稿)利用重合指数法破解Virginia加密 Breaking Virginia Encryption.pptx
- 哈尔滨工程大学:《计算机安全与密码学 Computer Security and Cryptography》课程教学资源(课件讲稿)传统密码技术 Classical cryptography.pdf
- 安徽理工大学:《计算机安全与密码学 Computer Security and Cryptography》课程教学资源(课件讲稿)Preliminary knowledge.pptx
- 《计算机安全与密码学 Computer Security and Cryptography》课程教学资源(课件讲稿)2020年上半年我国互联网网络安全监测数据分析报告.pdf
- 安徽理工大学:《计算机安全与密码学 Computer Security and Cryptography》课程教学资源(课件讲稿)Security Situation(2019).pptx
- 《计算机导论 Introduction to Computer Science》课程配套教材教学资源(参考资料)负数在计算机中的存储和计算形式.docx
- 《计算机导论 Introduction to Computer Science》课程配套教材教学资源(参考资料)C语言中int型变量表示的数的范围.docx
- 《计算机导论 Introduction to Computer Science》课程配套教材教学资源(参考资料)浮点数在内存中的表示.docx
- 清华大学出版社:《计算机导论 Introduction to Computer Science》课程配套教材教学资源(PPT课件讲稿,第3版)第9章 计算机学科方法论.ppt
- 清华大学出版社:《计算机导论 Introduction to Computer Science》课程配套教材教学资源(PPT课件讲稿,第3版)第8章 计算机领域的典型问题.ppt
- 清华大学出版社:《GNU/Linux编程指南》参考书籍【美】K. Wall,M. Watson, M. Whitis(共39章).pdf
- 安徽理工大学:《Linux开发基础 Development Foundation on Linux OS》课程教学资源(PPT课件讲稿)Section 4 Perl programming.ppt
- 安徽理工大学:《Linux开发基础 Development Foundation on Linux OS》课程教学资源(PPT课件讲稿)Section 4 Perl编程(附Perl源代码).ppt
- 安徽理工大学:信息安全专业教学资源(讲稿)学科前沿讲座之一.pptx
- 信息安全专业参考书籍:《Mathematics for Computer Science》计算机科学数学(revised Monday 5th June, 2017,Eric Lehman、F Thomson Leighton、Albert R Meyer).pdf
- 安徽理工大学:信息安全专业教学资源(讲稿)Advance in Intrusion Detection Techniques.ppt
- 安徽理工大学:信息安全专业教学资源(讲稿)Bot、Botnet及其检测技术.pdf
- 信息安全专业教学资源(讲稿)Artificial Immune Systems——An Emerging Technology.ppt
- 信息安全专业教学资源(讲稿)Introduction to Artificial Immune Systems(AIS).ppt
- 安徽理工大学:信息安全专业教学资源(讲稿)Differential Privacy.pdf
- 信息安全专业教学资源(讲稿)An Introduction to Artificial Immune Systems(ES2001).ppt
- 安徽理工大学:信息安全专业教学资源(讲稿)信息安全学科综述 An Overview of Information Security.ppt
- 安徽理工大学:信息安全专业教学资源(讲稿)信息安全专业介绍 An Introduction to Specialty in Information.ppt
- 信息安全专业教学资源(讲稿)Malware and Artificial Immune Systems.pdf
- Computational Intelligence(Concepts to Implementations)Part 1.pdf
- 安徽理工大学:《数据结构》课程教学资源(2016计算机网络课程设计任务书).doc
- 安徽理工大学:《数据结构》课程教学资源(2018计算机专业实习设计任务书).docx
- 安徽理工大学:《数据结构》课程教学资源(PPT课件讲稿,C语言版,2018)第1章 绪论(主讲:孙克雷).pptx
- 安徽理工大学:《数据结构》课程教学资源(PPT课件讲稿,C语言版,2018)第2章 线性表.pptx
- 安徽理工大学:《数据结构》课程教学资源(PPT课件讲稿,C语言版,2018)第3章 栈和队列.pptx