Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: static libs problem  (Read 5806 times)

0 Members and 1 Guest are viewing this topic.

fastrgv

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Email
static libs problem
« 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>
« Last Edit: April 24, 2016, 04:57:49 am by fastrgv »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
AW: static libs problem
« Reply #1 on: April 24, 2016, 03:38:32 pm »
Where does it abort?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

fastrgv

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Email
Re: static libs problem
« Reply #2 on: April 24, 2016, 08:07:42 pm »
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

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
AW: static libs problem
« Reply #3 on: April 24, 2016, 08:11:27 pm »
So it crashes somewhere in pthread. Did you build SFML yourself?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

fastrgv

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Email
Re: static libs problem
« Reply #4 on: April 24, 2016, 08:49:09 pm »
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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: static libs problem
« Reply #5 on: April 24, 2016, 08:56:24 pm »
Don't construct SFML resources at global scope.
Laurent Gomila - SFML developer

fastrgv

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Email
Re: static libs problem
« Reply #6 on: April 24, 2016, 09:17:22 pm »
Ok.  I put those 2 declarations inside main, like the tutorial example.
But it still acts the same?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: static libs problem
« Reply #7 on: April 24, 2016, 09:22:59 pm »
Give us the new callstack then.
Laurent Gomila - SFML developer

fastrgv

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Email
Re: static libs problem
« Reply #8 on: April 24, 2016, 09:31:08 pm »
...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

fastrgv

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Email
Re: static libs problem
« Reply #9 on: April 24, 2016, 09:39:55 pm »
So sorry, my mistake.
(somehow my edits did not save...)
The declarations inside main fixed it.
Thank you.
Rod