Compilation error from CVS with "--static" configuration
hi,
I am trying to debug qemu with "--static" configuration but got the following error message:
gcc -DQEMU_TOOL -Wall -O2 -g -fno-strict-aliasing -I. -g -static -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -o qemu-img qemu-img.c block.c block-raw.c block-cow.c block-qcow.c aes.c block-vmdk.c block-cloop.c block-dmg.c block-bochs.c block-vpc.c block-vvfat.c block-qcow2.c -lz -lrt /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_cancel.o)(.text+0x2e):
In function `aio_cancel':
: undefined reference to `pthread_mutex_lock' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_cancel.o)(.text+0x4f):
In function `aio_cancel':
: undefined reference to `pthread_mutex_unlock' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_cancel.o)(.text+0x113):
In function `aio_cancel':
: undefined reference to `pthread_mutex_unlock' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_misc.o)(.text+0x165):
In function `__aio_init':
: undefined reference to `pthread_mutex_lock' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_misc.o)(.text+0x1e8):
In function `__aio_enqueue_request':
: undefined reference to `pthread_self' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_misc.o)(.text+0x1ee):
In function `__aio_enqueue_request':
: undefined reference to `pthread_getschedparam' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_misc.o)(.text+0x203):
In function `__aio_enqueue_request':
: undefined reference to `pthread_mutex_lock' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_misc.o)(.text+0x3a4):
In function `__aio_enqueue_request':
: undefined reference to `pthread_cond_signal' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_misc.o)(.text+0x3b4):
In function `__aio_enqueue_request':
: undefined reference to `pthread_mutex_unlock' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_misc.o)(.text+0x4cc):
In function `__aio_enqueue_request':
: undefined reference to `pthread_attr_init' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_misc.o)(.text+0x4d9):
In function `__aio_enqueue_request':
: undefined reference to `pthread_attr_setdetachstate' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_misc.o)(.text+0x4ed):
In function `__aio_enqueue_request':
: undefined reference to `pthread_create' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_misc.o)(.text+0x4f8):
In function `__aio_enqueue_request':
: undefined reference to `pthread_attr_destroy' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_misc.o)(.text+0x555):
In function `__aio_enqueue_request':
: undefined reference to `pthread_mutex_unlock' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_misc.o)(.text+0x576):
In function `handle_fildes_io':
: undefined reference to `pthread_self' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_misc.o)(.text+0x58c):
In function `handle_fildes_io':
: undefined reference to `pthread_getschedparam' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_misc.o)(.text+0x5c1):
In function `handle_fildes_io':
: undefined reference to `pthread_setschedparam' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_misc.o)(.text+0x60a):
In function `handle_fildes_io':
: undefined reference to `pthread_mutex_lock' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_misc.o)(.text+0x6d4):
In function `handle_fildes_io':
: undefined reference to `pthread_cond_signal' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_misc.o)(.text+0x6df):
In function `handle_fildes_io':
: undefined reference to `pthread_mutex_unlock' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_misc.o)(.text+0x772):
In function `handle_fildes_io':
: undefined reference to `pthread_mutex_lock' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_misc.o)(.text+0x981):
In function `handle_fildes_io':
: undefined reference to `pthread_mutex_lock' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_misc.o)(.text+0x9e8):
In function `handle_fildes_io':
: undefined reference to `pthread_cond_timedwait' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_misc.o)(.text+0xa25):
In function `handle_fildes_io':
: undefined reference to `pthread_attr_init' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_misc.o)(.text+0xa2d):
In function `handle_fildes_io':
: undefined reference to `pthread_attr_setdetachstate' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_misc.o)(.text+0xa3e):
In function `handle_fildes_io':
: undefined reference to `pthread_create' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_misc.o)(.text+0x1af):
In function `__aio_init':
: undefined reference to `pthread_mutex_unlock' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_notify.o)(.text+0x8b):
In function `__aio_notify_only':
: undefined reference to `pthread_create' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_notify.o)(.text+0xa9):
In function `__aio_notify_only':
: undefined reference to `pthread_attr_init' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_notify.o)(.text+0xb1):
In function `__aio_notify_only':
: undefined reference to `pthread_attr_setdetachstate' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_notify.o)(.text+0x15c):
In function `__aio_notify':
: undefined reference to `pthread_cond_signal' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_notify.o)(.text+0x1a7):
In function `__aio_notify':
: undefined reference to `pthread_create' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_notify.o)(.text+0x1fc):
In function `__aio_notify':
: undefined reference to `pthread_create' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_notify.o)(.text+0x21c):
In function `__aio_notify':
: undefined reference to `pthread_attr_init' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_notify.o)(.text+0x22c):
In function `__aio_notify':
: undefined reference to `pthread_attr_setdetachstate' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_notify.o)(.text+0x242):
In function `__aio_notify':
: undefined reference to `pthread_attr_init' /usr/lib/gcc/i386-redhat-linux/3.4.2/../../../librt.a(aio_notify.o)(.text+0x24f):
In function `__aio_notify':
: undefined reference to `pthread_attr_setdetachstate'
collect2: ld returned 1 exit status
make: *** [qemu-img] Error 1
It seems that in the Makefile it misses to link library pthread.
I modified Makefile and rebuild it without any problem.
ifdef CONFIG_STATIC
LDFLAGS+=-static
LIBS+=-lpthread
endif
ifdef BUILD_DOCS
DOCS=qemu-doc.html qemu-tech.html qemu.1 qemu-img.1 else
DOCS=
endif
Thanks,
Neo
Signature · 2 lines
I would remember that if researchers were not ambitious probably today we haven't the technology we are using!