0

I'm trying to start a new project in C++ using SDL, and keep getting this error when compiling.

The code for the file is below:

#include <stdio.h>
#include <SDL2/SDL.h>

int main(int argc, char *argv[]) {
    // attempt to initialize graphics system
    if (SDL_Init(SDL_INIT_VIDEO) != 0)
    {
        printf("error initializing SDL: %s\n", SDL_GetError());
        return 1;
    }

    printf("initialization successful!\n");

    // clean up resources before exiting
    SDL_Quit();
}

This is the makefile I'm using:

build:
    g++ -Wfatal-errors \
    ./main.cpp \
    -I"C:\libsdl\include" \
    -L"C:\libsdl\lib" \
    -lmingw32 \
    -lSDL2main \
    -lSDL2 \
    -lSDL2_image \
    -o main.exe

And the console output:

In file included from c:\include\process.h:13:0,
             from C:\libsdl\include/SDL2/SDL_thread.h:99,
             from C:\libsdl\include/SDL2/SDL_audio.h:35,
             from C:\libsdl\include/SDL2/SDL.h:36,
             from ./main.cpp:6:
c:\include\sys\types.h:208:9: error: '_ino_t' does not name a type
typedef _ino_t   ino_t;
     ^~~~~~
compilation terminated due to -Wfatal-errors.
make: *** [build] Error 1
genpfault
  • 51,148
  • 11
  • 85
  • 139
MWaring
  • 21
  • 2
  • 1
    That is a compiler error, not a linker error. The same error message is mentioned in [this question](https://stackoverflow.com/questions/38436542/mingw-cxxtest-bizarre-errors). – Drew Dormann Sep 02 '22 at 15:48
  • 1
    What is your exact build toolchain? It seems you're using windows, but if you're using a makefile - are you using mingw? Did you build SDL yourself? – Ofek Shilon Sep 02 '22 at 16:38
  • @OfekShilon Yes, I'm on Windows, compiling with a makefile and MinGW, I've put the SDL.dll file in with MinGW files and now, if I compile with the 32 bit version of SDL, I get an error saying 'This App Can't Run on your PC', with 64 bit, it simply cannot compile, giving me these errors `main.cpp:(.text+0x1b): undefined reference to 'SDL_GetError'` for any SDL function used. – MWaring Sep 06 '22 at 16:06
  • What do you mean "put the SDL.dll file in with the MinGW files"? Put it where exactly? And again - did you build SDL yourself? where did you put the generated sdl.lib, and did you direct VS to import from there? – Ofek Shilon Sep 06 '22 at 16:19
  • @OfekShilon I've put SDL.dll in the 'bin' folder of C:/MinGW which is where I installed MinGW. I downloaded the SDL files from libsdl.org and I put the files in the lib folder (.a files) into a folder in my C: drive which I then link in the makefile using `-LC:/libsdl/lib`. I'm not using VS, instead I'm hoping to recompile using CMD myself and the makefile. – MWaring Sep 07 '22 at 11:17

0 Answers0