|
al_install_system fails inside shared library |
Brooklyn
Member #12,433
December 2010
|
I've been writing a game engine for about six years now using Allegro as a back-end. Lately I've been upgrading the most recent version to use the various newer versions of C++, Visual Studio, and Allegro 5 seen here. I've been doing some internal testing by outputting a compiled library and then having simple sample games using said output. However, for some reason, the call al_install_system(ALLEGRO_VERSION_INT, std::atexit) returns false inside the function a2de_init() (Engine/a2de_base.cpp) when it is called from any of the sample games but not from the testing project for the library. The documentation says nothing about what could cause the failure and only states: "Don't call it inside a shared library unless you know what you are doing." This is not helpful. Why does it fail? Why shouldn't it be called inside a shared library? What must I know to do this correctly?
|
torhu
Member #2,727
September 2002
|
Not sure what the problem might be, but aren't you supposed to use AND instead of OR here? bool result = system_init_result || image_init_result || primitives_init_result || font_init_result || ttf_init_result || install_audio_result || acodec_init_result || native_dialog_init_result || install_keyboard_result || install_mouse_result || install_joystick_result; And you shouldn't need to call any of the al_uninstall* functions, Allegro uses atexit to have them called automatically. APPEND: |
Brooklyn
Member #12,433
December 2010
|
You're right! Fixed. Frustratingly enough (not the funny kind of frustrating), a previously-created sample game works just fine and their main functions, Property Sheets, and Property Managers are exactly the same... Anyway, I've "fixed" the problem by calling al_install_system(ALLEGRO_INT, std::atexit) just prior to the sample game's call to a2de::a2de_init(). It returns true when called from the game binary. Since the system is already installed a2de_init()'s version always returns true. An actual fix would be nice. More descriptive errors or documentation explaining why the system was not installed correctly would be great.
|
torhu
Member #2,727
September 2002
|
Brooklyn
Member #12,433
December 2010
|
Passing a nullptr atexit pointer to al_install_system still returns false for the newer project.
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
Are you sure your library and your game are using the same versions of allegro? That is the first thing that comes to mind when al_init fails. Also, something to note about using al_install_system inside a dll is that the dll has its own entry and exit point separate from main's entry and exit point. If al_uninstall_system is running inside the dll's exit function it can cause problems with the main exit function, causing things to be destroyed twice. I've run into that problem before. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Brooklyn
Member #12,433
December 2010
|
Yep, that was it. The engine test project was using the dynamic versions of the Allegro library, but the actual Library project that outputs the static library for others to use was using the Monolithic version. Since each test game was using the dynamic versions of Allegro, there was a version mis-match. Thanks guys.
|
Felix-The-Ghost
Member #9,729
April 2008
|
Brooklyn said: I've been writing a game engine for about six years now using Allegro as a back-end. This and your avatar remind me of the Charred Dirt project (R.I.P. forum) with ShadowFang. You know him? |
Brooklyn
Member #12,433
December 2010
|
Felix-The-Ghost said: This and your avatar remind me of the Charred Dirt project (R.I.P. forum) with ShadowFang. You know him? Nope.
|
|