views:

35

answers:

2

Whenever I link in either FreeMagic & GraphicsMagic, i get a SIGABRT as soon as main starts, possibly even before. Any ideas?

It is not sufficient to just add the link flags, but for instance adding the call to FreeImage_Initialise(FALSE); somewhere in main() makes the program die in a SIGABRT.

Stacktrace from where it crashes:

#0  0x00007ffff6c47a75 in *__GI_raise (sig=<value optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0x00007ffff6c4b5c0 in *__GI_abort () at abort.c:92
#2  0x00007ffff73f41d1 in MHD_start_daemon_va () from /usr/lib/libmicrohttpd.so.5
#3  0x00007ffff73f481f in MHD_start_daemon () from /usr/lib/libmicrohttpd.so.5
#4  0x00000000004036f2 in main (argc=1, argv=0x7fffffffec98) at pasar.c:769

It always happen whenever I try to call MDH_start_daemon().

The same thing also happened when I link in another, unrelated as far as I know, image library, AfterImage.

Adding -pthread to LDFLAGS and CFLAGS makes no difference.

A: 

Looking at code for MHD_start_daemon_va(), it appears that it will call abort() (via mhd_panic) IFF pthread_mutex_lock() fails.

Does relinking your program with gcc -pthread ... help?

Employed Russian
Interesting, but no. No difference.
Amigable Clark Kant
A: 

Problem solved. I added -fPIC to CFLAGS and what-do-you-know, it works. Very interesting. If someone could explain why that is, would be very nice. You will then get my accept.

If no other answer appears shortly, I will accept my own answer.

Amigable Clark Kant