简体   繁体   English

Makefile 编译错误,Visual Studio Code 无法识别包含文件

[英]Makefile Compile Error and Visual Studio Code did not recognize include files

I use visual Studio Code and gcc-12.1.0, x86_64-w64-mingw32 and SDL2.我使用 Visual Studio Code 和 gcc-12.1.0、x86_64-w64-mingw32 和 SDL2。

I have folowing Makefile:我有以下 Makefile:

all:
    g++ -I scr/include -L scr/lib -o main main.cpp -lmingw32 -lSDL2main -lSDL2

If I only have one main.cpp comiling and everything works.如果我只有一个 main.cpp 正在编译并且一切正常。 But now I added Header files and other C++ files.但现在我添加了 Header 文件和其他 C++ 文件。 But I see already in Visual Studio Code that the Include.cpp and.h are getting an error that the file is not found.但我已经在 Visual Studio Code 中看到 Include.cpp 和 .h 收到找不到文件的错误。 But the Files in die Directory and same project as main.cpp但是目录中的文件和与 main.cpp 相同的项目

Error错误

What do I have to change or what I´m doing wrong?我必须改变什么或我做错了什么?

BR druckgott BR德鲁戈特

It was my makefile, now it works:这是我的 makefile,现在它可以工作了:

all:
g++ -I scr/include -L scr/lib -o main main.cpp MSController.cpp MSGameWindow.cpp MSEventHandler.cpp -lmingw32 -lSDL2main -lSDL2

g++ should be able to handle it, but for local includes you would usually use #include "" not #include <> . g++ 应该能够处理它,但是对于本地包含,您通常会使用#include ""而不是#include <> Otherwise, try to compile manually from the command line and see if the issue is related to your makefile / vs-code or if the include really can't be found.否则,尝试从命令行手动编译,看看问题是否与您的 makefile / vs-code 有关,或者是否真的找不到包含。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM