VSCode使用graphics.h(Windows)

1.进入官网,下载EasyX图形库

在 Dev-C++ 或 Code::Blocks 下面配置 EasyX - CodeBus

2.解压后得到三个有用的文件(2个头文件,1个静态库)

需要EasyX(已有),gdi32,ole32这三个库

 这个没有那另外2个库,怪不得我搞了好久都没有弄好

 

3.进入官网,下载TDM-GCC tdm-gcc

运行安装之后:

4.配置VSCode

(1)ctrl+shift+p  输入 build,创建一个"tasks.json"在".vscode"文件夹中

 (2)tasks.json大致如下:

 

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "cpp build",
            "type": "cppbuild",
            "command": "E:/TDM-gcc/bin/g++.exe",
            "args": [
                "-g",
                "${file}",
                "-L",
                "E:\\TDM-gcc\\x86_64-w64-mingw32\\lib",
                "-lEasyX",
                "-lgdi32 ",
                "-lole32",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "detail": "compiler: E:/TDM-gcc/bin/g++.exe",
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

(3)".vscode"目录下创建launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "gdb Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "E:\\TDM-gcc\\bin/gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description":  "Set Disassembly Flavor to Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "cpp build"
        }
    ]
}

(4)目录结构

 

 

5.将第2步解压得到的graphics.h和exayx.h头文件放入E:\TDM-gcc\x86_64-w64-mingw32\include

将libEasyX.a文件放入E:\TDM-gcc\x86_64-w64-mingw32\lib

(我的安装目录是E:\TDM-gcc)

6.编写一个简单的main.cpp

#include <graphics.h>
#include <conio.h>
int main()
{
    int gd=DETECT,gm;
    initgraph(&gd,&gm,(char*)"");
    circle(200,200,100);
    getch();
    return 0;
}

 7.开始运行调试

 8.结果

  • 8
    点赞
  • 70
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值