"错误:'sem_t'和#34;的冲突类型在Ubuntu上编译eglibc-2.19时

时间:2015-10-04 04:30:30

标签: c ubuntu compiler-errors building eglibc

我试图在我通过

下载的Ubuntu 14.04 LTS上构建eglibc-2.19
apt-get source libc6

我遵循了INSTALL指令,但在遇到nptl时遇到了这个错误

gcc sem_init.c -c -std=gnu99 -fgnu89-inline -fno-stack-protector -O2 -Wall -Winline -Wwrite-strings -fmerge-all-constants -frounding-math -g -Wstrict-prototypes      -U_FORTIFY_SOURCE   -I../include -I/home/gpanda/wksp/glibc/tmp2/glibc-build/nptl  -I/home/gpanda/wksp/glibc/tmp2/glibc-build  -I../sysdeps/unix/sysv/linux/x86_64/64/nptl  -I../sysdeps/unix/sysv/linux/x86_64/64  -I../nptl/sysdeps/unix/sysv/linux/x86_64  -I../nptl/sysdeps/unix/sysv/linux/x86  -I../sysdeps/unix/sysv/linux/x86  -I../sysdeps/unix/sysv/linux/x86_64  -I../sysdeps/unix/sysv/linux/wordsize-64  -I../nptl/sysdeps/unix/sysv/linux  -I../nptl/sysdeps/pthread  -I../libpthread/sysdeps/pthread  -I../sysdeps/pthread  -I../ports/sysdeps/unix/sysv/linux  -I../sysdeps/unix/sysv/linux  -I../sysdeps/gnu  -I../sysdeps/unix/inet  -I../nptl/sysdeps/unix/sysv  -I../ports/sysdeps/unix/sysv  -I../sysdeps/unix/sysv  -I../sysdeps/unix/x86_64  -I../nptl/sysdeps/unix  -I../ports/sysdeps/unix  -I../sysdeps/unix  -I../sysdeps/posix  -I../libpthread/sysdeps/posix  -I../nptl/sysdeps/x86_64/64  -I../sysdeps/x86_64/64  -I../sysdeps/x86_64/fpu/multiarch  -I../sysdeps/x86_64/fpu  -I../sysdeps/x86/fpu  -I../sysdeps/x86_64/multiarch  -I../nptl/sysdeps/x86_64  -I../sysdeps/x86_64  -I../sysdeps/x86  -I../sysdeps/ieee754/ldbl-96  -I../sysdeps/ieee754/dbl-64/wordsize-64  -I../sysdeps/ieee754/dbl-64  -I../sysdeps/ieee754/flt-32  -I../sysdeps/wordsize-64  -I../sysdeps/ieee754  -I../sysdeps/generic  -I../libpthread/include -I../libpthread  -I../nptl  -I../ports  -I.. -I../libio -I.  -I../libpthread/include  -D_LIBC_REENTRANT -include ../include/libc-symbols.h   -DNOT_IN_libc=1 -DIS_IN_libpthread=1 -DIN_LIB=libpthread    -o /home/gpanda/wksp/glibc/tmp2/glibc-build/nptl/sem_init.o -MD -MP -MF /home/gpanda/wksp/glibc/tmp2/glibc-build/nptl/sem_init.o.dt -MT /home/gpanda/wksp/glibc/tmp2/glibc-build/nptl/sem_init.o
In file included from sem_init.c:20:0:
../libpthread/include/semaphore.h:28:0: warning: "SEM_FAILED" redefined [enabled by default]
 #define SEM_FAILED ((void *) 0)
 ^
In file included from ../libpthread/include/semaphore.h:26:0,
                 from sem_init.c:20:
../nptl/sysdeps/unix/sysv/linux/x86/bits/semaphore.h:33:0: note: this is the location of the previous definition
 #define SEM_FAILED      ((sem_t *) 0)
 ^
In file included from sem_init.c:20:0:
../libpthread/include/semaphore.h:30:28: error: conflicting types for ‘sem_t’
 typedef struct __semaphore sem_t;
                            ^
In file included from ../libpthread/include/semaphore.h:26:0,
                 from sem_init.c:20:
../nptl/sysdeps/unix/sysv/linux/x86/bits/semaphore.h:40:3: note: previous declaration of ‘sem_t’ was here
 } sem_t;
   ^
make[2]: *** [/home/gpanda/wksp/glibc/tmp2/glibc-build/nptl/sem_init.o] Error 1
make[2]: Leaving directory `/home/gpanda/wksp/glibc/tmp2/eglibc-2.19/nptl'
make[1]: *** [nptl/subdir_lib] Error 2
make[1]: Leaving directory `/home/gpanda/wksp/glibc/tmp2/eglibc-2.19'
make: *** [all] Error 2

这是libpthread和nptl之间的某种冲突吗?如何解决这个问题? 提前谢谢。

2 个答案:

答案 0 :(得分:1)

考虑到LinuxThreads已被NPTL取代,所以我只是从eglibc目录中删除了附加的libpthread,并重新进行了configure和make,然后现在一切似乎都没问题了。

请参阅LinuxThreadsNPTL

顺便说一句,因为我没有使用标准/ usr路径作为" - prefix =" configure的选项,所以我需要将libstdc ++。so.6和libgcc_s.so.1复制到我当前的构建路径以获取" make check"通过。

请参阅glibc Known_testsuite_failures

答案 1 :(得分:1)

我得到了同样的错误,因为我运行了一个普通的./configure --prefix=/opt,所以我改为运行apt-get source -b eglibc,并注意到它使用的配置标志:

(exec 3>&1; exit `( ( (  cd build-tree/i386-libc && CC="i686-linux-gnu-gcc-4.8" CXX="i686-linux-gnu-g++-4.8" AUTOCONF=false MAKEINFO=: /home/sashoalm/Workspace/apt-get-source/libc/eglibc-2.19/configure --host=i686-linux-gnu --build=$configure_build --prefix=/usr --without-cvs --enable-add-ons=libidn,"nptl " --enable-profile --without-selinux --enable-stackguard-randomization --enable-obsolete-rpc --with-pkgversion="Ubuntu EGLIBC 2.19-0ubuntu6.9" --with-bugurl="https://bugs.launchpad.net/ubuntu/+source/eglibc/+bugs"   --with-headers=/home/sashoalm/Workspace/apt-get-source/libc/eglibc-2.19/debian/include --enable-kernel=2.6.24 --with-selinux --enable-multi-arch ) 2>&1 3>&-; echo $? >&4) | tee  -a build-tree/log-build-i686-linux-gnu-libc >&3) 4>&1`)

由于glibc坚持从一个单独的目录构建,因此命令相对复杂,比apt-get source更复杂。实际的配置标志是:

--host=i686-linux-gnu --build=$configure_build --prefix=/usr --without-cvs --enable-add-ons=libidn,"nptl " --enable-profile --without-selinux --enable-stackguard-randomization --enable-obsolete-rpc --with-pkgversion="Ubuntu EGLIBC 2.19-0ubuntu6.9" --with-bugurl="https://bugs.launchpad.net/ubuntu/+source/eglibc/+bugs" --with-headers=/home/sashoalm/Workspace/apt-get-source/libc/eglibc-2.19/debian/include --enable-kernel=2.6.24 --with-selinux --enable-multi-arch

当然,它适用于那些参数,因为这是Ubuntu维护者用来编译包的原因。

我真的不知道哪些标志可以防止错误,但是如果你使用那个命令,或者你的Ubuntu系统上apt-get source -b eglibc提供的确切参数,它应该可以运行得很好。