0

I started using SDL today and had some trouble before, now I got it running but it won't let me init it.

# **Code -->**

#include <iostream>
#include <SDL2/SDL.h>
#undef main

using namespace std;

int main(){
    if(SDL_Init(SDL_INIT_EVERYTHING)<0){
        cout << "error starting sdl" << endl;
    }
    return 0;
}

Output -->

PS C:\Users\aashi\OneDrive\CPP_Projects> cd "c:\Users\aashi\OneDrive\CPP_Projects" ; if ($?) { g++ hellDEmo.cpp -o hellDEmo } ; if ($?) { .\hellDEmo } c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\aashi\AppData\Local\Temp\cc8Ya8Za.o:hellDEmo.cpp:(.text+0x1e): undefined reference to `SDL_Init' collect2.exe: error: ld returned 1 exit status*

what's the problem in code or compiler?

  • Neither, the problem is the way you are **building** the program. You are failing to **link** the SDL library with your program. Since your program does not build you cannot say that you have got your program running. – john Jan 02 '23 at 12:31

0 Answers0