[C++] SDL2 - Undefined references to functions at school

Need help with C, C++, perl, python, etc?

Re: [C++] SDL2 - Undefined references to functions at school

Postby peter_irich » 2017-02-12 14:40

Functions with very similar names are in library libSDL2-2.0.so.0 -> libSDL2-2.0.so.0.2.0 in package libsdl2-2.0-0.
For examlpe, SDL_RenderCopy but not Renderer, SDL_CreateRGBSurfaceFrom. Check your source.

Peter.
Last edited by peter_irich on 2017-02-12 19:53, edited 1 time in total.
peter_irich
 
Posts: 1169
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation

Re: [C++] SDL2 - Undefined references to functions at school

Postby phenest » 2017-02-12 18:04

commodorejohn wrote:
Code: Select all
commodorejohn@devuan:~$ gcc sdltest.c `sdl2-config --cflags --libs` -o sdltest
/tmp/ccCtWq9W.o: In function `main':
sdltest.c:(.text+0x15f): undefined reference to `SDL_CreateRGBSurfaceWithFormat'
sdltest.c:(.text+0x2c2): undefined reference to `SDL_RendererFillRect'
sdltest.c:(.text+0x326): undefined reference to `SDL_RendererCopy'
sdltest.c:(.text+0x341): undefined reference to `SDL_RendererPresent'
collect2: error: ld returned 1 exit status

I really don't understand why this is happening. Any advice on resolving this issue?

What is the output of:
Code: Select all
sdl2-config --cflags --libs

And what is the contents of your sdltest.c source code?
NEC Spirit 550 P4 3.8GHz HT - 2GB RAM - nVidia 7600GT - Pioneer BDR-209DBK
ASUS Sabertooth P67 i7 3770K - 32GB RAM - 2x nVidia 660GTX SLI'd
User avatar
phenest
 
Posts: 1571
Joined: 2010-03-09 09:38
Location: The Matrix

Re: [C++] SDL2 - Undefined references to functions at school

Postby commodorejohn » 2017-02-12 21:58

peter_irich wrote:Functions with very similar names are in library libSDL2-2.0.so.0 -> libSDL2-2.0.so.0.2.0 in package libsdl2-2.0-0.
For examlpe, SDL_RenderCopy but not Renderer, SDL_CreateRGBSurfaceFrom. Check your source.

Thank you, well-spotted. The "render"/"renderer" typo was the bulk of it, and the other problem was that I was going off the SDL wiki without noticing that SDL_CreateRGBSurfaceWithFormat wasn't added until 2.0.5. It builds and runs without issue now.
commodorejohn
 
Posts: 35
Joined: 2011-06-29 10:26

Previous

Return to Programming

Who is online

Users browsing this forum: No registered users and 2 guests

fashionable