sfml sdl2 windows vscode 调试和coderunner插件运行

链接库写在编译链接命令里,如果没有使用到不会加入到生成的可执行文件里。所以tasks.json可以这样写,

复制代码
{
	"version": "2.0.0",
	"tasks": 
	[
		{
			"type": "cppbuild",
			"label": "C/C++: g++.exe 生成活动文件",
			"command": "D:\\mingw64_1310\\bin\\g++.exe",
			"args": 
			[
				"-fdiagnostics-color=always",
				"-g",
				"-std=c++17",
				"*.cpp",
				
				"-lmingw32",
				"-lSDL2main",
				"-lSDL2",
				"-lSDL2_image",
				"-lSDL2_ttf",
				"-lSDL2_mixer",

				"-lsfml-audio",
				"-lsfml-graphics",
				"-lsfml-window",
				"-lsfml-system"
			],
			"options": 
			{
				"cwd": "${fileDirname}"
			},
			"problemMatcher": 
			[
				"$gcc"
			],
			"group": 
			{
				"kind": "build",
				"isDefault": true
			},
			"detail": "编译器: D:\\mingw64_1310\\bin\\g++.exe",
			"presentation": 
			{            //
                "reveal": "silent",
                "revealProblems": "onProblem",
                "close": true
            }
		}
	]
}

coderunner插件可以如下这样写,

复制代码
{
   
    "code-runner.executorMap": 
    {
        "cpp": "cd $dir && g++ *.cpp -std=c++17 -Wall -fexec-charset=gbk -lmingw32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_ttf -lSDL2_mixer -lsfml-audio -lsfml-graphics -lsfml-window -lsfml-system && ./a",
    }
}

launch.json是如下,

复制代码
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C/C++: g++.exe 生成和调试活动文件",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\a.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "D:\\mingw64_1310\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "将反汇编风格设置为 Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: g++.exe 生成活动文件"
        }
    ]
}

以上都是windows平台。以上2个库都没有包括网络库的链接。

下面的系统环境变量 配置好后有可能需要重启电脑。 操作系统Path设置可以用分号 ; 也把sfml和sdl2的库和包含路径都写上,

新建的CPLUS_INCLUDE_PATH,LIBRARY_PATH,

PATH里面放bin目录的dll文件路径,

相关推荐
番茄去哪了33 分钟前
苍穹外卖day07---Redis缓存优化与购物车功能实现
java·数据库·ide·spring boot·spring·maven·mybatis
水饺编程1 小时前
第4章,[标签 Win32] :TextOut 测试案例2
c语言·c++·windows·visual studio
i建模1 小时前
Omarchy挂载windows磁盘
linux·运维·windows
A懿轩A2 小时前
【Java 基础编程】Java 集合框架详解:List/Set/Map 选型 + ArrayList/HashMap 原理与使用
java·windows·list
ol木子李lo3 小时前
Linux 命令备忘录
linux·运维·服务器·windows·编辑器·ssh·bash
三无少女指南4 小时前
开发者环境配置最佳实践:编辑器Cursor ,VS Code的上位体验实现 AI 与 WSL 联动
运维·c语言·数据库·windows·git·编辑器
水木姚姚4 小时前
string类(C++)
开发语言·c++·windows·vscode·开发工具
人生导师yxc4 小时前
IDE缓存配置等位置更改(自存)
java·ide·intellij-idea
楼田莉子5 小时前
CMake学习:CMake在二进制工程场景上应用
linux·c++·vscode·学习·软件构建
love530love5 小时前
ZeroClaw Reflex UI完整搭建流程——ZeroClaw Gateway + LM Studio + Reflex 本地 AI 管理面板
人工智能·windows·gateway·lm studio·reflex·openclaw·zeroclaw