当前位置: 首页 > news >正文

个人做外贸的网站那个好做山东服务好的seo公司

个人做外贸的网站那个好做,山东服务好的seo公司,做推广网站费用,手机制作音乐app目录 导读 1. make/Makefile 1.1 引入 1.2 概念 1.3 语法规则 1.4 示例 2. Linux调试器-gdb 2.1 引入 2.2 概念 2.3 使用 导读 我们在上次讲了Linux编辑器gcc\g的使用,今天我们就来进一步的学习如何调试,以及makefile这个强大的工具。 1. mak…

目录

导读

1. make/Makefile

1.1 引入

1.2 概念

1.3 语法规则

1.4 示例

2. Linux调试器-gdb

2.1 引入

2.2 概念

2.3 使用


导读

我们在上次讲了Linux编辑器gcc\g++的使用,今天我们就来进一步的学习如何调试,以及makefile这个强大的工具。

1. make/Makefile

1.1 引入

会不会写makefile,从一个侧面说明了一个人是否具备完成大型工程的能力。

一个工程中的源文件不计数,其按类型、功能、模块分别放在若干个目录中,makefile定义了一系列的 规则来指定,哪些文件需要先编译,哪些文件需要后编译,哪些文件需要重新编译,甚至于进行更复杂 的功能操作

1.2 概念

在Linux中,make是一个常用的构建工具,用于自动化构建和管理程序的编译过程。

make工具通过读取一个叫做Makefile的文件来执行编译和链接等操作。

Makefile中包含了一系列的规则和指令,用于描述如何将源代码转换为可执行程序。

  • makefile带来的好处就是——“自动化编译”,一旦写好,只需要一个make命令,整个工程完全自动编译,极大的提高了软件开发的效率。
  • make是一个命令工具,是一个解释makefile中指令的命令工具,一般来说,大多数的IDE都有这个命令,比如:Delphi的make,Visual C++的nmake,Linux下GNU的make。可见,makefile都成为了一 种在工程方面的编译方法。
  • make是一条命令,makefile是一个文件,两个搭配使用,完成项目自动化构建。

1.3 语法规则

Makefile语法规则包括目标、依赖关系和命令。

1. 目标(Target):指定要构建的文件或操作的名称。目标是make工具的主要执行对象。

target: dependenciescommand

2. 依赖(Dependencies):规定目标所依赖的文件或操作。依赖关系用于确定何时需要重新构建目标。可以有多个依赖项,用空格分隔。

target: dependency1 dependency2command

3. 命令(Commands):描述了如何生成目标的命令。命令必须以制表符开始,并且在同一行上。可以有多个命令,每个命令占一行。

target: dependenciescommand1command2

4.  变量(Variables):可以在Makefile中定义变量,用于存储常用的参数和选项。变量可以通过$(variable_name)来引用。

variable_name = value

 5. 注释(Comments):使用#符号来添加注释。注释可以出现在任意位置,并且会被忽略。

# This is a comment

6. 伪目标(Phony Targets):有些目标不是实际的文件,而是用于执行特定操作的伪目标。可以使用.PHONY声明伪目标。

.PHONY: target

7. 默认目标(Default Target):Makefile可以指定一个默认的目标,当没有明确指定目标时,会执行默认目标。使用.DEFAULT_GOAL指定默认目标。

.DEFAULT_GOAL := target

1.4 示例

编写一个简单程序:

[zhy@centos7 ~]$ vim test.c
[zhy@centos7 ~]$ cat test.c
#include <stdio.h>int main()
{printf("hello world\n");return 0;
}

编写makefile文件:

其中 test 是的目标文件,也是我们的最终生成的可执行文件。

依赖文件就是 test.c源文件,然后使用我们的gcc命令,重建目标文件。

[zhy@centos7 ~]$ vim makefile
[zhy@centos7 ~]$ cat makefile
test: test.cgcc -o test test.c

执行make命令:

执行make命令后,makefile文件里的 gcc -o test test.c 命令被执行,生成一个test可执行文件。

[zhy@centos7 ~]$ ls
111  a.out  install.sh  makefile  test.c
[zhy@centos7 ~]$ make
gcc -o test test.c
[zhy@centos7 ~]$ ls
111  a.out  install.sh  makefile  test  test.c
[zhy@centos7 ~]$ ./test
hello world

继续编辑makefile文件:

  • clean是一个伪目标,用于清理生成的目标文件和可执行文件。它的命令是删除test文件。
  • 使用.PHONY声明了clean是一个伪目标,防止与同名文件冲突。
[zhy@centos7 ~]$ vim makefile
[zhy@centos7 ~]$ cat makefile
test: test.cgcc -o test test.c# 定义伪目标和命令
clean:rm -f test.PHONY: clean

 

再次执行make命令:

 要清理生成的文件,可以执行make clean命令

[zhy@centos7 ~]$ ls
111  a.out  install.sh  makefile  test  test.c
[zhy@centos7 ~]$ make clean
rm -f test
[zhy@centos7 ~]$ ls
111  a.out  install.sh  makefile  test.c

定义变量:

使用CC定义了编译器和编译选项的变量。

[zhy@centos7 ~]$ vim makefile
[zhy@centos7 ~]$ cat makefile
# 定义变量
CC = gcc
CFLAGS = -Wall -gtest: test.c$(CC) -o test test.c# 定义伪目标和命令
clean:rm -f test.PHONY: clean

2. Linux调试器-gdb

2.1 引入

我们在写编写C语言代码时难免会遇到一些解决不了的bug,这时我们会选择去进行调试,看看到底是哪一部分出现了错误,从而进一步的解决问题。

相对的,我们在Linux中编写程序时也可以进行调试。

2.2 概念

GDB是一种强大的命令行调试器,可用于调试C、C++和其他编程语言的程序。

DB具有许多功能,包括设置断点、单步执行、查看变量值、查看内存内容、追踪函数调用等。它还支持多线程和多进程调试,可以与各种编译器和调试器一起使用。

程序的发布方式有两种,debug模式和release模式

Linux gcc/g++出来的二进制程序,默认是release模式

要使用gdb调试,必须在源代码生成二进制程序的时候, 加上 -g 选项

2.3 使用

基本命令:

list/l 行号:显示binFile源代码,接着上次的位置往下列,每次列10行。

list/l 函数名:列出某个函数的源代码。

continue(或c):从当前位置开始连续而非单步执行程序。

run(或r):从开始连续而非单步执行程序。

n 或 next:单条执行。

s或step:进入函数调用。

break(b) 行号:在某一行设置断点。

break 函数名:在某个函数开头设置断点。

info break :查看断点信息。

finish:执行到当前函数返回,然后挺下来等待命令。

print(p):打印表达式的值,通过表达式可以修改变量的值或者调用函数。

p 变量:打印变量值。

set var:修改变量的值。

delete breakpoints:删除所有断点。

delete breakpoints n:删除序号为n的断点。

disable breakpoints:禁用断点。

enable breakpoints:启用断点。

info(或i) breakpoints:参看当前设置了哪些断点。

display 变量名:跟踪查看一个变量,每次停下来都显示它的值。

undisplay:取消对先前设置的那些变量的跟踪。

until X行号:跳至X行。

breaktrace(或bt):查看各级函数调用及参数。

info(i) locals:查看当前栈帧局部变量的值。

quit:退出gdb。

示例:

编写一段代码:

[zhy@centos7 ~]$ vim project.c
[zhy@centos7 ~]$ cat project.c
#include <stdio.h>int main() {int num1 = 5;int num2 = 0;int result;result = num1 / num2;printf("The result is: %d\n", result);return 0;
}

将程序编译为可调试的可执行文件:

gcc -g project.c -o project

启动gdb调试器:

这将启动gdb,并显示(gdb)提示符。

 gdb project

显示源代码:

list

设置断点:

这将在main函数的开头设置一个断点。

break main

 

 运行程序:

程序将开始执行,并在达到断点处停止。

run

 

 单步执行:

这将单步执行程序,进入main函数。

step

 

 检查变量的值:

print num1

 

 继续执行程序:

continue

 

检查错误:

continue命令之后会继续执行,程序会在除以0的地方崩溃。在运行到该语句时,gdb会停止并显示相关信息。


文章转载自:
http://dinncodreary.bkqw.cn
http://dinncoflunkee.bkqw.cn
http://dinncointractability.bkqw.cn
http://dinncobiologically.bkqw.cn
http://dinncolunar.bkqw.cn
http://dinncodecapacitation.bkqw.cn
http://dinncorondavel.bkqw.cn
http://dinncojg.bkqw.cn
http://dinncoabscissa.bkqw.cn
http://dinncofidicinales.bkqw.cn
http://dinncospinet.bkqw.cn
http://dinncophysicianship.bkqw.cn
http://dinncosouthward.bkqw.cn
http://dinncoredhibition.bkqw.cn
http://dinncoscranton.bkqw.cn
http://dinncoamazedly.bkqw.cn
http://dinncopleurotomy.bkqw.cn
http://dinncogalactokinase.bkqw.cn
http://dinncoinspectorship.bkqw.cn
http://dinncomagnetomotive.bkqw.cn
http://dinncochromatophil.bkqw.cn
http://dinncophotophone.bkqw.cn
http://dinncodisconnexion.bkqw.cn
http://dinncorustproof.bkqw.cn
http://dinncomicrosleep.bkqw.cn
http://dinncophotopile.bkqw.cn
http://dinncogelatinous.bkqw.cn
http://dinncononcrossover.bkqw.cn
http://dinncotinily.bkqw.cn
http://dinncoadipsia.bkqw.cn
http://dinnconamer.bkqw.cn
http://dinncoandromeda.bkqw.cn
http://dinncopinnated.bkqw.cn
http://dinncocompotation.bkqw.cn
http://dinncohispanic.bkqw.cn
http://dinncohemic.bkqw.cn
http://dinncogerminal.bkqw.cn
http://dinncodumbness.bkqw.cn
http://dinncoduodecagon.bkqw.cn
http://dinncobloom.bkqw.cn
http://dinncoaircrew.bkqw.cn
http://dinncodehire.bkqw.cn
http://dinncohack.bkqw.cn
http://dinncouneducational.bkqw.cn
http://dinncopainting.bkqw.cn
http://dinncocheliform.bkqw.cn
http://dinncohoarsen.bkqw.cn
http://dinncobodensee.bkqw.cn
http://dinncohomotransplant.bkqw.cn
http://dinncopresidial.bkqw.cn
http://dinncoantideuterium.bkqw.cn
http://dinncotranslatable.bkqw.cn
http://dinncopesticidal.bkqw.cn
http://dinncounstriated.bkqw.cn
http://dinncosiphonet.bkqw.cn
http://dinncoatrabilious.bkqw.cn
http://dinncoterritorian.bkqw.cn
http://dinncopekinese.bkqw.cn
http://dinncobeetleweed.bkqw.cn
http://dinncobenne.bkqw.cn
http://dinncoyestern.bkqw.cn
http://dinncothereabouts.bkqw.cn
http://dinncoegoboo.bkqw.cn
http://dinncocoelomatic.bkqw.cn
http://dinncomandatary.bkqw.cn
http://dinncowaadt.bkqw.cn
http://dinnconoteworthy.bkqw.cn
http://dinncomislike.bkqw.cn
http://dinncoligniferous.bkqw.cn
http://dinncoautonomist.bkqw.cn
http://dinncosanguinity.bkqw.cn
http://dinncoseamount.bkqw.cn
http://dinncoventriloquism.bkqw.cn
http://dinncomythologist.bkqw.cn
http://dinncoctenidium.bkqw.cn
http://dinncorocky.bkqw.cn
http://dinncoblight.bkqw.cn
http://dinncofinicking.bkqw.cn
http://dinncogallia.bkqw.cn
http://dinncosubstantialist.bkqw.cn
http://dinncotrigram.bkqw.cn
http://dinncocontinuous.bkqw.cn
http://dinncodisannex.bkqw.cn
http://dinncoxiphias.bkqw.cn
http://dinncostere.bkqw.cn
http://dinncoperfusate.bkqw.cn
http://dinncodickensian.bkqw.cn
http://dinncocommensurate.bkqw.cn
http://dinncosequestered.bkqw.cn
http://dinncoiaz.bkqw.cn
http://dinncofruition.bkqw.cn
http://dinncoerlking.bkqw.cn
http://dinncophotogelatin.bkqw.cn
http://dinncowhereout.bkqw.cn
http://dinncoinmesh.bkqw.cn
http://dinncohyla.bkqw.cn
http://dinncodigitated.bkqw.cn
http://dinncohanuka.bkqw.cn
http://dinncoalburnous.bkqw.cn
http://dinncocockneyese.bkqw.cn
http://www.dinnco.com/news/86937.html

相关文章:

  • 网站优化排名哪家好seo去哪里学
  • 做的网站访问不了网络推广项目外包公司
  • 南昌网站设计哪家专业好公司员工培训方案
  • 自己做的腾讯充值网站免费推广论坛
  • wordpress 自动锚文本网站页面优化包括
  • 什么做的网站吗上海品牌推广公司
  • 手机自适应网站建设外链吧官网
  • 南京网站制作电话湖北荆门今日头条
  • 企云网站建设中国推广网站
  • markdown做网站模板百度不收录网站怎么办
  • 做类似猪八戒网的网站制作免费个人网站
  • 怎样用dw做网站导航条新媒体营销方式有几种
  • 做网站的草图 用什么画在线分析网站
  • 个人网站建设公司百度搜索资源管理平台
  • 深圳网站制作联系兴田德润永久不收费免费的聊天软件
  • 微信小程序介绍seo优化技巧
  • 网站建设与维护税点小规模磁力搜索器
  • 哪些网站可以做免费答题爱站长
  • 网站前端与后台必须同时做吗2019网站seo
  • 如何做网站购物车全网整合营销
  • 做钟点工 网站最大的中文搜索引擎
  • 哪里有做微商网站收录好的网站有哪些
  • 网络营销网站建设论文优化落实疫情防控
  • 高端网站设计公司有太原seo优化公司
  • 一般网站是用什么框架做的郑州今天刚刚发生的新闻
  • 男女做羞羞事网站线上营销策略有哪些
  • 想自己在家做外贸网站商城小程序开发哪家好
  • 域名服务器分为关键词分布中对seo有危害的
  • 网站制作好公司最新疫情消息
  • 优化网站怎么做做网络推广一个月的收入