# Shared library problem

**URL:** <https://discourse.libsdl.org/t/shared-library-problem/7101>\
**Category:** SDL Development\
**Created:** [July 24, 2002, 12:50am UTC](https://discourse.libsdl.org/t/shared-library-problem/7101 "2002-07-24T00:50:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gib\_Bogle](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/g/d2c977/32.png) [@Gib\_Bogle](https://discourse.libsdl.org/u/Gib_Bogle)\
**Post date:** [July 24, 2002, 12:50am UTC](https://discourse.libsdl.org/t/shared-library-problem/7101/1 "2002-07-24T00:50:01Z")

</div>

I’ve run into an odd problem that may have nothing to do with SDL, but  
someone else here might have encountered something similar.

I have created a shared library of graphics functions using SDL/OpenGL,  
and it works fine when I link it with a test program.

I now want to use it with my real program, which has three threads. To  
make life simple I call the graphics master function from the main  
thread (i.e. I don’t start a new thread). I find that the execution is  
jumping to code that I have not called. I now have the very simple case  
where the graphics function is called first thing when from main(), and  
an exit() call follows immediately after that. In the graphics function  
I write out a message, call the shared library function that initializes  
SDL and OpenGL, then return.

When I run this I see the message from the graphics function, but not  
debugging messages from the shared library function. Instead I get  
messages from a function in the main program that I am not invoking.

This testing version of my real program should only use a single thread,  
therefore I presume multi-threading is not an issue. As far as I can  
see I’m linking the shared library in just the same way in the graphics  
test program and in the program with the bizarre behaviour. It seems  
that somehow the entry address for the initialization function is  
getting corrupted, and instead of going there the execution jumps to an  
unrelated function.

What sort of error gives this sort of behaviour?

thanks  
Gib
