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

VS2017下OpenGL C++项目头文件多错误求助

Fixing Your OpenGL Project Compile Errors in VS2017

Hey there, let's work through these two compile issues step by step—since you're a C++ beginner diving into LearnOpenGL, I know these little roadblocks can feel pretty frustrating. Let's break them down:

1. Error: "name followed by '::' must be a class or namespace it is in (FileSystem::getPath)"

This error means your compiler doesn't recognize FileSystem as a valid class or namespace when it tries to resolve FileSystem::getPath. Here's what to check:

  • Double-check the filesystem.h inclusion: Make sure you've added #include "filesystem.h" at the top of your main.cpp, and that the filesystem.h file is actually in your project directory (or in a folder VS is set to look for headers).
  • Verify the FileSystem namespace/class: Open up filesystem.h and confirm there's a properly declared namespace FileSystem that contains the getPath function. Typos happen—maybe it's spelled FileSys instead of FileSystem, or the function is named differently?
  • Check project include paths: If filesystem.h is in a subfolder (like utils/), you need to either use #include "utils/filesystem.h" or add that subfolder to your project's include directories. To do this in VS2017:
    1. Right-click your project in Solution Explorer → Properties
    2. Go to Configuration Properties → C/C++ → General
    3. Add the folder path to Additional Include Directories

2. Error: Cannot open source file "root_directory.h"

Even after downloading the file, the compiler can't find it—here's how to fix that:

  • Place root_directory.h in the right spot: Either put it in the same folder as filesystem.h, or in a folder that's already in your project's include paths.
  • Fix the include statement in filesystem.h: If filesystem.h uses #include <root_directory.h> (angle brackets), change it to #include "root_directory.h" (double quotes). Angle brackets tell the compiler to look in system library paths, while double quotes prioritize your project's local directories.
  • Add the file's folder to include paths: If you keep root_directory.h in a separate folder, add that folder to your project's Additional Include Directories using the same steps as above.
  • Check for filename typos: Make sure the downloaded file is named exactly root_directory.h (no extra spaces, wrong capitalization—Windows is case-insensitive, but it's still good practice to match what the header expects).

Quick Extra Tip for VS2017

Since LearnOpenGL relies on modern C++ features, make sure your project is set to use C++17 or later:

  1. Right-click your project → Properties
  2. Go to Configuration Properties → C/C++ → Language
  3. Set C++ Standard to ISO C17 Standard (/std:c17)

That should get you past these two errors. Let me know if you hit any other snags!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 11:10:36