skip to Main Content

I use visual Studio Code and gcc-12.1.0, x86_64-w64-mingw32 and SDL2.

I have folowing 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. But now I added Header files and other C++ files. But I see already in Visual Studio Code that the Include .cpp and .h are getting an error that the file is not found.
But the Files in die Directory and same project as main.cpp

Error

What do I have to change or what I´m doing wrong?

BR druckgott

2

Answers


  1. Chosen as BEST ANSWER

    It was my makefile, now it works:

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

  2. g++ should be able to handle it, but for local includes you would usually use #include "" not #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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search