2

I try to compile a c++ code with the library SDL2 at school in debian x32 but I got few error:

main.cpp:(.text+0x39): undefined reference to `SDL_CreateWindow'
main.cpp:(.text+0x59): undefined reference to `SDL_CreateRenderer'
main.cpp:(.text+0x69): undefined reference to `SDL_RenderPresent'
main.cpp:(.text+0x75): undefined reference to `SDL_Delay'
collect2: error: ld returned 1 exit status

My main.cpp:

#include "SDL2/SDL.h"

int main()
{
    SDL_Window *screen;
    SDL_Renderer *renderer;

    screen = SDL_CreateWindow("test", SDL_WINDOWPOS_CENTERED, 20, 500, 300, SDL_WINDOW_SHOWN);
    renderer = SDL_CreateRenderer(screen, -1, SDL_RENDERER_PRESENTVSYNC);
    SDL_RenderPresent(renderer);
    SDL_Delay(1);
    return 0;
}

In terminal, I write:

g++ main.cpp -L. -lSDL2 -lSDL2main

In the same folder I have:

  • A folder "SDL2" with all .h file
  • The files:
    • libSDL2.a
    • libSDL2.dll.a
    • libSDL2main.a

Because I am at school, I don't have root permission so I can't install anything.

I my own computer on windows or debian it work perfectly.

Dash
  • 21
  • 3

0 Answers0