You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Windows的Visual Studio 2015中引入BGI图形库?

Setting up BGI Graphics Library for Visual Studio 2015 (and General Windows VS Guide)

Hey there! I’ve tackled this exact problem for academic projects before, so let me break down how to get BGI working in VS2015, plus the general steps that apply to most Windows versions of Visual Studio.

Step-by-Step for Visual Studio 2015

First, you’ll need the Windows-compatible BGI files: graphics.h, winbgim.h (the Windows adaptation of BGI), and either libbgi.a or bgi.lib. You can find these from trusted academic resources or open-source collections built for BGI on Windows.

Once you have those files, follow these steps:

  1. Add header files to your project’s include path
    • Open your VS2015 project, right-click it in the Solution Explorer, and select Properties.
    • Navigate to Configuration Properties > C/C++ > General.
    • In the Additional Include Directories field, add the folder path where you stored graphics.h and winbgim.h.
  2. Configure library file paths
    • Still in the Properties window, go to Linker > General.
    • In Additional Library Directories, add the folder containing libbgi.a or bgi.lib.
  3. Link the BGI library
    • Go to Linker > Input.
    • In Additional Dependencies, add the name of your BGI library file (e.g., libbgi.a or bgi.lib).
  4. Add required Windows system libraries
    • Head to Linker > Command Line.
    • In Additional Options, paste these flags:
      -lmsimg32 -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32
      
      These link system libraries that BGI relies on for Windows graphics.
  5. Test your setup
    • Create a simple test program to verify everything works:
      #include <graphics.h>
      
      int main() {
          // Create a 640x480 window
          initwindow(640, 480, "BGI Test");
          // Draw a circle at the center
          circle(320, 240, 100);
          // Wait for user input before closing
          getch();
          closegraph();
          return 0;
      }
      
    • Compile and run—you should see a window with a circle if everything’s set up correctly.

General Method for Windows Visual Studio (VS2017+)

The core process is nearly identical to VS2015, with one extra tweak for newer versions:

  1. Follow steps 1-4 from the VS2015 guide above (header paths, library paths, linking BGI, adding system libraries).
  2. Set the character set to Multi-Byte
    • In your project’s Properties, go to Configuration Properties > General.
    • Under Character Set, select Use Multi-Byte Character Set (newer VS versions default to Unicode, which can cause BGI function errors).

Key Notes

  • Make sure you’re using a Windows-adapted BGI library (like winbgim)—the original DOS BGI won’t work natively on Windows.
  • Match your library file’s architecture (32-bit/64-bit) to your project’s build platform (found under Configuration Manager).
  • If you hit compiler errors, double-check that your paths are correctly entered, and verify that graphics.h doesn’t have outdated syntax (some versions need small tweaks like replacing int far with int to work with modern VS compilers).

内容的提问来源于stack exchange,提问作者Salman Ahmed

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 10:05:00