当前位置:网站首页>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": [
]
}
]
}边栏推荐
- Opencv_ 100 questions_ Chapter V (21-25)
- Dlib face detection
- SQL 注入读写文件
- Multithreading (V) -- concurrency tools (I) -- thread pool (II) -- related contents of ThreadPoolExecutor
- June 9th training day - bit operation
- 六月集训 第二天——字符串
- Install MySQL tutorial
- PHP 开发环境搭建及数据库增删改查
- Redis data structure (VIII) -- Geo
- Computer composition and design work06 —— 基于MIPS
猜你喜欢

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

Bert Chinese classification model training + reasoning + deployment

Piecewise Bezier curve

Reentrantlock underlying AQS source code analysis

Overview of camera image quality
![[reinstall system] 01 system startup USB flash disk production](/img/0d/9b3d4b8e286a75f8b58e35d02f261b.jpg)
[reinstall system] 01 system startup USB flash disk production

Computer composition and design work06 —— 基于MIPS

Redis problem (I) -- cache penetration, breakdown, avalanche

Explanation of sensor flicker/banding phenomenon

leetcode 35. Search insert location
随机推荐
2021 RoboCom 世界机器人开发者大赛-本科组(初赛)
AI作业ch8
LeetCode-1629. Key with the longest key duration
Highlight detection with pairwise deep ranking for first person video summary (thesis translation)
The second day of June training - string
Computer composition and design work05 ——fifth verson
Whether the modification of basic type and reference type is valid
Qt-- realize TCP communication
Information content security experiment of Harbin Institute of Technology
Reentrantlock underlying AQS source code analysis
Deep and detailed analysis of PHP one sentence Trojan horse
June 9th training day - bit operation
Bid farewell to the charged xshell, and the free function of tabby is more powerful
SQL injection based on error reporting
Unreal Engine learning notes
The first principle of thinking method
leetcode 278. First wrong version
六月集训 第二天——字符串
Tomato learning notes-stm32 SPI introduction and Tim synchronization
Leetcode January 10 daily question 306 Additive number