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文件路径,

相关推荐
love530love8 小时前
ComfyUI Hunyuan-3D-2 插件安装问题解决方案
人工智能·windows·python·3d·comfyui·hunyuan-3d-2·pygit2
菩提树下的凡夫9 小时前
基于windows X64 NVIDA显卡的onnxruntime环境下GPU加速C++部署教程
windows
取个名字太难了a9 小时前
用户 APC 的执行过程(下)
windows
jerwey10 小时前
VSCode + Copilot下:配置并使用 DeepSeek
ide·vscode·copilot
QQ121546146812 小时前
使用远程桌面连接Windows 2012 R2 Standard服务器报错:出现身份验证错误。要求的函数不受支持。这可能是由于CredSSP加密数据库修正。
服务器·windows·windows server
奔跑吧 android12 小时前
【vscode】【Continue】【插件使用】
ide·vscode·编辑器
worilb13 小时前
WinSW XML 配置参数介绍
windows
耀临光14 小时前
分享5款满足各类需求的小软件
windows
积跬步,慕至千里15 小时前
AI平台Dataiku 支Windows系统安装过程总结
windows
FL162386312916 小时前
[C++][cmake]基于C++在windows上部署yolo26的目标检测onnx模型
c++·windows·目标检测