SFML community forums
Help => Audio => Topic started by: fastrgv on April 24, 2016, 02:00:26 am
-
I have a simple C++ program that compiles and runs fine using shared SFML libs,
but aborts [with a seg.fault] using static libs:
string const scifi("quick_portal.wav");
if( !sbLaser.loadFromFile(scifi) )
{
cout<<"sfml-audio problem loading file: "<<scifi<<endl;
exit (EXIT_FAILURE);
}
sound.setBuffer(sbLaser);
sound.setVolume(50);
sound.setLoop(false);
sound.play();
sleep(2);
cout<<"...done..."<<endl;
return 0;
I built SFML v2.3.2 from source on my build machine running OpenSUSE 13.2 with no errors.
I have used ldd to ensure you would have a chance to execute the binaries, if you choose.
I sent both the static and shared versions.
I am attaching my build files.
Thanks,
<fastrgv@gmail.com>
-
Where does it abort?
-
it aborts somewhere before the program entry point. GDB traceback says something like this:
#0 0x00007ffff6c24244 in pthread_mutex_lock ()
from /home/rufascube/myapps/cpp/sdl_apps/nusfml/libs/gnu/libpthread.so.0
#1 0x000000000040bd73 in sf::AlResource::AlResource() ()
#2 0x000000000040779e in sf::SoundSource::SoundSource() ()
#3 0x0000000000404f19 in sf::Sound::Sound() ()
#4 0x0000000000404e15 in __static_initialization_and_destruction_0 (
__initialize_p=1, __priority=65535) at trysnd.cc:27
#5 0x0000000000404e5c in _GLOBAL__sub_I_sound () at trysnd.cc:51
#6 0x000000000040d05d in __libc_csu_init (argc=1, argv=0x7fffffffdfa8,
envp=0x7fffffffdfb8) at elf-init.c:88
#7 0x00007ffff5e6fa95 in __libc_start_main () from /lib64/libc.so.6
#8 0x0000000000404bd5 in _start () at ../sysdeps/x86_64/start.S:122
I could not include my whole build because it was about 3MB and that is too big to attach.
Rod
-
So it crashes somewhere in pthread. Did you build SFML yourself?
-
yes, built it myself from source...first the shared libs, then the static. Absolutely no problem during build. The shared libs I generated work perfectly, not so with the static.
-
Don't construct SFML resources at global scope.
-
Ok. I put those 2 declarations inside main, like the tutorial example.
But it still acts the same?
-
Give us the new callstack then.
-
...looks pretty much the same:
(gdb) backtrace
#0 0x00007ffff6c24244 in pthread_mutex_lock ()
from /home/rufascube/myapps/cpp/sdl_apps/nusfml/libs/gnu/libpthread.so.0
#1 0x000000000040bd73 in sf::AlResource::AlResource() ()
#2 0x000000000040779e in sf::SoundSource::SoundSource() ()
#3 0x0000000000404f19 in sf::Sound::Sound() ()
#4 0x0000000000404e15 in __static_initialization_and_destruction_0 (
__initialize_p=1, __priority=65535) at trysnd.cc:27
#5 0x0000000000404e5c in _GLOBAL__sub_I_sound () at trysnd.cc:51
#6 0x000000000040d05d in __libc_csu_init (argc=1, argv=0x7fffffffdfa8,
envp=0x7fffffffdfb8) at elf-init.c:88
#7 0x00007ffff5e6fa95 in __libc_start_main () from /lib64/libc.so.6
#8 0x0000000000404bd5 in _start () at ../sysdeps/x86_64/start.S:122
-
So sorry, my mistake.
(somehow my edits did not save...)
The declarations inside main fixed it.
Thank you.
Rod