Visual Studio 2019
准备配置文件
创建Project1.vcxproj
配置文件,文件中添加如下内容
Debug
x64
Linux
Project1
15.0
Linux
1.0
Generic
{2238F9CD-F817-4ECC-BD14-2524D2669B35}
true
D:/Linux/linux-3.4.39.6818/include;
D:/Linux/linux-3.4.39.6818/arch/arm/include;
D:/Linux/linux-3.4.39.6818/arch/arm/include/generated;
D:/Linux/linux-3.4.39.6818/arch/arm/mach-s5p6818/include;
D:/Linux/linux-3.4.39.6818/arch/arm/plat-s5p6818/include;
D:/Linux/linux-3.4.39.6818/arch/arm/plat-s5p6818/common;
D:/Linux/linux-3.4.39.6818/arch/arm/plat-s5p6818/GEC6818/include;
%(AdditionalIncludeDirectories)
__KERNEL__;CONFIG_RWSEM_GENERIC_SPINLOCK
使用
1.将配置文件拷贝到工程目录中(可以修改为项目的名字),双击运行
2.点击显示所有,会显示配置文件下所有文件
3.Ctrl点击需要的目录,包括到项目中
Visual Studio Code
准备配置文件
创建.vscode/c_cpp_properties.json
配置目录及文件,文件中添加如下内容
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"D:/Linux/linux-3.4.39.6818/kernel/include",
"D:/Linux/linux-3.4.39.6818/kernel/arch/arm/include",
"D:/Linux/linux-3.4.39.6818/kernel/arch/arm/include/generated",
"D:/Linux/linux-3.4.39.6818/kernel/arch/arm/mach-s5p6818/include",
"D:/Linux/linux-3.4.39.6818/kernel/arch/arm/plat-s5p6818/include",
"D:/Linux/linux-3.4.39.6818/kernel/arch/arm/plat-s5p6818/common",
"D:/Linux/linux-3.4.39.6818/kernel/arch/arm/plat-s5p6818/xxx/include"
],
"defines": [
"__KERNEL__",
"CONFIG_RWSEM_GENERIC_SPINLOCK"
],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
使用
1.将配置文件目录.vscode
(含文件)拷贝到工程目录中
2.在工程目录中右键菜单选择 Open VSCode Here
其他
1.VS2019安装文件比较大,安装时要选择Linux开发组件;VSCode安装包小,安装后再安装C/C++插件。
2.配置文件的实质作用是添加一些Linux内核的头文件和必要宏定义,例中事先已经把板商提供的源码中内核kernel/目录拷贝D:/Linux/linux-3.4.39.6818/下。
项 | 描述 |
---|---|
kernel/include | 内核头文件 |
kernel/arch/arm/include | 内核平台相关 |
kernel/arch/arm/include/generated | 内核编译后生成的头文件放置目录 |
kernel/arch/arm/mach-s5p6818/include | mach-xx需要根据芯片选择 |
kernel/arch/arm/plat-s5p6818/include | plat-xx需要根据芯片选择 |
kernel/arch/arm/plat-s5p6818/common | plat-xx目录下其他有头文件的位置 |
kernel/arch/arm/plat-s5p6818/xxx/include | plat-xx目录下其他有头文件的位置 |
添加VS2019的右键菜单
1.在D盘创建目录VsMenu/Linux, 把配置文件拷贝到该目录下;
2.在VsMenu/Linux目录下创建文件menureg.bat,添加如下内容后双击运行;
@Echo off
SET src="\"%~dp0\Project1.vcxproj\""
SET des="\"%%V\Project0.vcxproj\""
SET string="cmd.exe /c copy %src% %des% & start devenv.exe %des%"
REG ADD HKEY_CLASSES_ROOT\Directory\Background\shell\myvs /t REG_SZ /d "Open VS-Linux Here" /f > nul
REG ADD HKEY_CLASSES_ROOT\Directory\Background\shell\myvs\Command /t REG_SZ /d %string% /f > nul
3.在VsMenu/Linux目录下创建文件menudel.bat,用于删除菜单,内容如下:
@Echo off
REG DELETE HKEY_CLASSES_ROOT\Directory\Background\shell\myvs /f > nul
4.任意目录空白处右键,选择Open VS-Linux Here
打开工程