1

The project dir as follows:

-Project
|--lib
|--include
  |--GL
    |--glew.h
|--PBF_CUDA
  |--main.cpp

The c_cpp_properties.json like this:

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceRoot}/**",
                "D:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.2/include/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "D:/Program Files (x86)/mingw-w64/i686-8.1.0-win32-dwarf-rt_v6-rev0/mingw32/bin/gcc.exe",
            "cStandard": "c11",
            "cppStandard": "c++11",
            "intelliSenseMode": "clang-x86"
        }
    ],
    "version": 4
}

When running this project, its got error:

[Running] cd "blabla" && g++ main.cpp -o main && "blabla/"main
In file included from main.cpp:4:
Renderer/RenderDevice.h:4:10: fatal error: GL/glew.h: No such file or directory
 #include <GL/glew.h>
          ^~~~~~~~~~~
compilation terminated.

[Done] exited with code=1 in 0.657 seconds

Something wrong is IntelliSense can find GL/glew.h, but compiler cannot find it.

How to fix this problem? Thanks!

luneice
  • 157
  • 1
  • 10
  • The ```GL/glew.h``` in project include folder not in ```D:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.2/include/GL```. – luneice May 30 '20 at 11:38
  • Does `#include "GL/glew.h"` work instead if `#include ` – drescherjm May 30 '20 at 11:43
  • Tried to change it to "", it also got other error ```RenderDevice.h:1:9: warning: #pragma once in main file #pragma once ^~~~ RenderDevice.h:4:10: fatal error: GL/glew.h: No such file or directory #include "GL/glew.h" ^~~~~~~~~~~ compilation terminated.``` – luneice May 30 '20 at 11:45
  • You should add `-I` option. VS Code won't do it for you automatically. What is the contents of `tasks.json`? – Evg May 30 '20 at 12:04
  • Does any extendsion should be installed? Are there some example? – luneice May 30 '20 at 12:12
  • ***Does any extendsion should be installed?*** No. This should help with the files: [https://code.visualstudio.com/docs/cpp/config-mingw](https://code.visualstudio.com/docs/cpp/config-mingw) – drescherjm May 30 '20 at 12:13
  • To be honest I don't fully understand the overlap between `c_cpp_properties.json` and `tasks.json` – drescherjm May 30 '20 at 12:16
  • 1
    @drescherjm, `c_cpp_*` is for IntelliSense, `tasks.json` is for compiler invocation. – Evg May 30 '20 at 12:17
  • See [this question](https://stackoverflow.com/questions/56096045/vscode-cannot-find-header-when-compile-while-intellisense-can) and [this one](https://stackoverflow.com/questions/60219223/how-do-i-specify-the-include-path-when-i-build-a-program-in-vscode). – Evg May 30 '20 at 12:18
  • I had just found this one: [https://stackoverflow.com/questions/52910102/vscode-c-task-json-include-path-and-libraries](https://stackoverflow.com/questions/52910102/vscode-c-task-json-include-path-and-libraries) – drescherjm May 30 '20 at 12:20
  • 1
    The `tasks.json` just allows you to create tasks which you can map to keyboard shortcuts. So for example, you could set up a `task` to invoke your `compiler` and build your project. You can also set up `tasks` to do other stuff as well. I would also recommend learning and using `CMake`. It's helpful when projects become non-trivial – WBuck May 30 '20 at 13:14

0 Answers0