当前位置:网站首页>Tomato learning notes -vscade configuring makefile (using task.jason and launch.jason)
Tomato learning notes -vscade configuring makefile (using task.jason and launch.jason)
2022-06-12 06:34:00 【GitTomato】
1. Makefile
2. VScode task and launch Study
3. Configuration and use Makefile
1.Makefile
I used to use Visual Studio Conduct C++ Development of , I have no idea Makefile It's something , I can't understand . Until now, it is necessary to Linux Cross platform development on the system , I knew I was wrong .
Don't talk much , A brief introduction ,Makefile It feels like a simple program after use , This program can simplify a lot g++ Compiling work , From input g++ -o xxx yyy become make Simple commands for . and make It can automatically judge whether the source program has been updated according to the time , So you don't have to compile it all every time .
Makefile The format is as follows :
Target: Source
OrderTarget It's the target file ( It can be .exe It can also be .o),Source It's the source file ( It can be .o It can also be .c .cpp etc. ), Simply speaking make The execution logic of a program is the recursion of a function , amount to Target(Source), and Source It can also be a function
- find target, see source, If source Also a target Then recursively enter source function
- perform Order, It's usually g++ -o
It is worth noting that ,makefile Can simplify operations , For example, the following table uses some symbols instead of
1 $< Represents the first matching dependency
2 [email protected] It means a goal
3 $^ All dependence
4 %.o: %.c Automatic matching
Therefore, the following template can be formed
cc = g++
prog = target
obj = srouce1.o srouce2.o ...
all: $(prog) clean // It's used here all, The program runs from top to bottom , See all It is equivalent to all As the main program , Automatically called clean It's more convenient
target: $(obj)
g++ -o $(prog) $(obj)
%.o: %.cpp
g++ -c %.cpp
clean:
rm -f $(obj)2.VScode task,launch
Ref: Vscode in task and launch Some macro definitions of
launch Equivalent to execution .exe Operation of file , Notes are used where it is worth noting , Other places can directly copy
{
"version": "0.2.0",
"configurations": [
{
"name": "g++.exe build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe", // Execute this file
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}", // If the execution of the program will produce a file, it will be placed here
"environment": [],
"externalConsole": true, // If you use the console, you need to open this
"MIMode": "gdb",
"miDebuggerPath": "C:\\Program Files\\MinGW\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "build" // Need to modify here , Follow task in label It's OK to be consistent
}
]
}task Here, it is equivalent to compiling , Usually in vscode Middle configuration c++ Use it like this
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "build", // Follow launch Medium preLaunchTask Agreement
"command": "C:\\Program Files\\MinGW\\mingw64\\bin\\g++.exe", // Compilation task
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
]
}
]
}3. Configuration and use Makefile
I understand launch and task Specific in vscode The function of , We can naturally introduce makefile, Replace task Medium g++ compile , Use make command .
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "build",
"command": "cd ${fileDirname}; make", // If you use it directly here make Will find , Very pit
"args": [
]
}
]
}边栏推荐
- Node. Detailed installation tutorial of CPM and cnpm (including error resolution)
- PHP一句话木马深度详细剖析
- SQL 注入-盲注
- Leetcode January 10 daily question 306 Additive number
- 上传文件(post表单提交form-data)
- MNIST handwritten data recognition by RNN
- Introduction to the method of diligently searching for the alliance procedure
- LeetCode-1189. Maximum number of balloons
- Multithreading (V) -- concurrency tools (I) -- thread pool (II) -- related contents of ThreadPoolExecutor
- About session Getattribute, getattribute error
猜你喜欢

张驰课堂:2022年CAQ中质协六西格玛考试时间通知

Bert use

Multithreading (4) -- no lock (3) -- longadder source code

leetcode 278. First wrong version

Leetcode personal question solution (Sword finger offer3-5) 3 Duplicate number in array, 4 Find in 2D array, 5 Replace spaces

Are you still using like+% for MySQL fuzzy query?

Multithreading (V) -- Concurrent tools (II) -- j.u.c concurrent contracting (I) -- AQS and reentrantlock principles

SQL injection - blind injection

美团获得小样本学习榜单FewCLUE第一!Prompt Learning+自训练实战

夜神模擬器adb查看log
随机推荐
LeetCode-1587. Bank account summary II
AI作业ch8
六月集训 第五天——双指针
Multithreading mode (I) -- protective pause and join source code
LeetCode-剑指Offer(第二版)个人题解完整版
SQL injection based on error reporting
六月集训 第七日 ——哈希表
The principle of SQL injection is to build sqli labs, and SQL injection is simple and practical
Cv2.fillpoly coco annotator segment coordinate conversion to mask image
基于报错的 SQL 注入
platform driver
LeetCode-219. Duplicate Element II present
五月集训(第28天)——动态规划
MNIST handwritten data recognition by RNN
张驰咨询:流程是一剂万能良药吗?
集合判断存在交集
PHP 读写 COOKIE
Tomato learning notes -seq2seq
SQL 注入-盲注
Computer composition and design work05 ——fifth verson