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

相关推荐
EnCi Zheng5 分钟前
SpringBoot + PostgreSQL 密码认证失败 Windows 系统解决方案
windows·spring boot·postgresql
Damon小智2 小时前
玩转CodeX:CodeX安装教程(Windows+Linux+MacOS)
linux·windows·macos·ai·ai编程·codex·gpt-5
用户31187945592182 小时前
DOpusInstall-13.2.exe 安装方法,简单几步完成
windows
Ching·2 小时前
RK3568入门之VScode远程连接开发板,直接开发板上面编程和实验
linux·ide·vscode·编辑器·rk3568
青草地溪水旁3 小时前
Visual Studio Code中launch.json深度解析:C++调试的艺术
c++·vscode·json
张某人的胡思乱想5 小时前
Create/Assemble/Link x64 Windows
windows
ThisIsMirror6 小时前
CompletableFuture并行任务超时处理模板
java·windows·python
逆境清醒6 小时前
VS Code配置Python开发环境系列(1)___VScode的安装 ,VScode常用快捷键
vscode·python·visual studio code
say_fall7 小时前
精通C语言(2.结构体)(内含彩虹)
c语言·开发语言·windows
长源Gingko7 小时前
Windows中在QTCreator中调试,提示缺少debug information files问题的解决
windows·qt