Skip to content
Advertisement

Undefined references to functions found within SDL2/SDL2_framerate.h

I’m having an issue compiling my code which is using the library.

First of all, I have ran a sudo apt-get install libsdl2-* and installed everything they could give me.

Next up, I manually built the darned thing. I found the source online at this url. I’m not exactly sure where to put the compile .so object I generated with:

gcc -c -fpic -lSDL2 SDL2_framerate.c -o SDL2_framerate.so

So I tried to manually compile with the shared object I generated. No luck, the thing does compile, however it segmentation faults on me immediately. I tried compiling without -fpic and still no luck.

The segmentation fault is being caused by SDL_initFramerate according to GDB. I’m assuming this is because it’s looking for the function in the wrong place, once again, I’m totally uncertain where exactly this is supposed to go as I haven’t been able to locate where on my system libsdl2.so is (or some version of libsdl2).

I’m at a loss, I’d like to use what this library has to offer, but it seems like either there is a bug in the library (or more likely a user error), or it’s not fully implemented yet.

I’m hoping someone has seen a similar issue to this, or has a better understanding of what’s going on and how to go about fixing it.

Advertisement

Answer

I figured out what I was doing wrong eventually. First of all, I wasn’t passing the FPSmanager object to the correct functions, which means I wasn’t using the functions correctly.

Secondly, I figured out that you have to compile it with the -SDL2_gfx linking flag. Not exactly sure where or how to figure out what compiler flags you need without trial and error (I’m sure there’s a nicer way to do it, I just haven’t found it).

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement