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

相关推荐
薛定猫AI40 分钟前
OpenAI Codex本地完整配置教程|(Windows/Mac/Linux全平台,修复鉴权报错)
linux·windows·macos
w01_02_032 小时前
deepseek, harness , windows , 安装。
windows
辻弋2012 小时前
手动关服务会自动重启、组策略家庭版用不了——Windows Update Blocker用“禁用+锁定”双保险,让Win10/11自动更新彻底闭嘴
服务器·人工智能·windows·电脑·开源软件
吃杠碰小鸡2 小时前
VsCode中开发Java项目
java·vscode
qinwsq2 小时前
Gmssl windows下编译
windows·gmssl
明王明王3 小时前
Ubuntu 26.04 使用 Windows Spotlight:给 Bing Wallpaper 加上 Spotlight 支持
linux·windows·ubuntu
Kismet_nvi3 小时前
Python 基础核心知识点总结
开发语言·windows·python
IT大白鼠4 小时前
MSF环境搭建全教程(Kali/Windows/Mac/Docker)
windows·macos·msf
2501_915106326 小时前
Swift 开发环境搭建指南:三条路径按目标对号入座
开发语言·vscode·ios·objective-c·个人开发·swift·敏捷流程
孫治AllenSun7 小时前
【JavaAI】LangChain4J(1) Windows 安装 Ollama 本地大模型
人工智能·windows