当多个定义链接。collect2:错误ld返回1退出状态

时间:2022-02-14 09:44:42

I am having problems compiling Emacs 23.3 Release Candidate 2:

我在编译Emacs 23.3版本候选2时遇到了问题:

I run autogen.sh, ./configure, make and finally make install where I get this error:

我运行autogen。sh, ./配置,make,最后在我得到这个错误的地方进行安装:

 gcc -std=gnu99     -I. -I../src -I../lib -I/home/john/bin/emacs/rc/emacs-24.3/lib-src -I/home/john/opt/emacs/rc/emacs-24.3/lib-src/../src -I/home/
john/bin/emacs/rc/emacs-24.3/lib-src/../lib  -Wl,-znocombreloc   -g3 -O2 -DEMACS_NAME="\"GNU Emacs\"" \
          -DVERSION="\"24.3\"" /home/john/bin/emacs/rc/emacs-24.3/lib-src/etags.c \
          regex.o ../lib/libgnu.a  -o etags
regex.o: In function `stpncpy':
/usr/include/bits/string3.h:160: multiple definition of `stpncpy'
/tmp/ccntBfBN.o:/usr/include/bits/string3.h:160: first defined here
regex.o: In function `realpath':
/usr/include/bits/stdlib.h:37: multiple definition of `realpath'
/tmp/ccntBfBN.o:/usr/include/bits/stdlib.h:37: first defined here
regex.o: In function `ptsname_r':
/usr/include/bits/stdlib.h:53: multiple definition of `ptsname_r'
/tmp/ccntBfBN.o:/usr/include/bits/stdlib.h:53: first defined here
regex.o: In function `wctomb':
/usr/include/bits/stdlib.h:74: multiple definition of `wctomb'
/tmp/ccntBfBN.o:/usr/include/bits/stdlib.h:74: first defined here
regex.o: In function `mbstowcs':
/usr/include/bits/stdlib.h:95: multiple definition of `mbstowcs'
/tmp/ccntBfBN.o:/usr/include/bits/stdlib.h:95: first defined here
regex.o: In function `wcstombs':
/usr/include/bits/stdlib.h:114: multiple definition of `wcstombs'
/tmp/ccntBfBN.o:/usr/include/bits/stdlib.h:114: first defined here
regex.o: In function `read':
/usr/include/bits/unistd.h:35: multiple definition of `read'
/tmp/ccntBfBN.o:/usr/include/bits/unistd.h:35: first defined here
regex.o: In function `pread':
/usr/include/bits/unistd.h:57: multiple definition of `pread'
/tmp/ccntBfBN.o:/usr/include/bits/unistd.h:57: first defined here
regex.o: In function `pread64':
/usr/include/bits/unistd.h:77: multiple definition of `pread64'
/tmp/ccntBfBN.o:/usr/include/bits/unistd.h:77: first defined here
regex.o: In function `readlink':
/usr/include/bits/unistd.h:99: multiple definition of `readlink'
/tmp/ccntBfBN.o:/usr/include/bits/unistd.h:99: first defined here
regex.o: In function `readlinkat':
/usr/include/bits/unistd.h:121: multiple definition of `readlinkat'
/tmp/ccntBfBN.o:/usr/include/bits/unistd.h:121: first defined here
regex.o: In function `getcwd':
/usr/include/bits/unistd.h:136: multiple definition of `getcwd'
/tmp/ccntBfBN.o:/usr/include/bits/unistd.h:136: first defined here
regex.o: In function `getwd':
/usr/include/bits/unistd.h:150: multiple definition of `getwd'
/tmp/ccntBfBN.o:/usr/include/bits/unistd.h:150: first defined here
regex.o: In function `confstr':
/usr/include/bits/unistd.h:165: multiple definition of `confstr'
/tmp/ccntBfBN.o:/usr/include/bits/unistd.h:165: first defined here
regex.o: In function `getgroups':
/usr/include/bits/unistd.h:181: multiple definition of `getgroups'
/tmp/ccntBfBN.o:/usr/include/bits/unistd.h:181: first defined here
regex.o: In function `ttyname_r':
/usr/include/bits/unistd.h:197: multiple definition of `ttyname_r'
/tmp/ccntBfBN.o:/usr/include/bits/unistd.h:197: first defined here
regex.o: In function `getlogin_r':
/usr/include/bits/unistd.h:213: multiple definition of `getlogin_r'
/tmp/ccntBfBN.o:/usr/include/bits/unistd.h:213: first defined here
regex.o: In function `gethostname':
/usr/include/bits/unistd.h:230: multiple definition of `gethostname'
/tmp/ccntBfBN.o:/usr/include/bits/unistd.h:230: first defined here
regex.o: In function `getdomainname':
/usr/include/bits/unistd.h:248: multiple definition of `getdomainname'
/tmp/ccntBfBN.o:/usr/include/bits/unistd.h:248: first defined here
../lib/libgnu.a(c-strcasecmp.o): In function `stpncpy':
/usr/include/bits/string3.h:160: multiple definition of `stpncpy'
/tmp/ccntBfBN.o:/usr/include/bits/string3.h:160: first defined here
../lib/libgnu.a(c-strcasecmp.o): In function `realpath':
/usr/include/bits/stdlib.h:37: multiple definition of `realpath'
/tmp/ccntBfBN.o:/usr/include/bits/stdlib.h:37: first defined here
../lib/libgnu.a(c-strcasecmp.o): In function `ptsname_r':
/usr/include/bits/stdlib.h:53: multiple definition of `ptsname_r'
/tmp/ccntBfBN.o:/usr/include/bits/stdlib.h:53: first defined here
../lib/libgnu.a(c-strcasecmp.o): In function `wctomb':
/usr/include/bits/stdlib.h:74: multiple definition of `wctomb'
/tmp/ccntBfBN.o:/usr/include/bits/stdlib.h:74: first defined here
../lib/libgnu.a(c-strcasecmp.o): In function `mbstowcs':
/usr/include/bits/stdlib.h:95: multiple definition of `mbstowcs'
/tmp/ccntBfBN.o:/usr/include/bits/stdlib.h:95: first defined here
../lib/libgnu.a(c-strcasecmp.o): In function `wcstombs':
/usr/include/bits/stdlib.h:114: multiple definition of `wcstombs'
/tmp/ccntBfBN.o:/usr/include/bits/stdlib.h:114: first defined here
../lib/libgnu.a(c-strncasecmp.o): In function `stpncpy':
/usr/include/bits/string3.h:160: multiple definition of `stpncpy'
/tmp/ccntBfBN.o:/usr/include/bits/string3.h:160: first defined here
../lib/libgnu.a(c-strncasecmp.o): In function `realpath':
/usr/include/bits/stdlib.h:37: multiple definition of `realpath'
/tmp/ccntBfBN.o:/usr/include/bits/stdlib.h:37: first defined here
../lib/libgnu.a(c-strncasecmp.o): In function `ptsname_r':
/usr/include/bits/stdlib.h:53: multiple definition of `ptsname_r'
/tmp/ccntBfBN.o:/usr/include/bits/stdlib.h:53: first defined here
../lib/libgnu.a(c-strncasecmp.o): In function `wctomb':
/usr/include/bits/stdlib.h:74: multiple definition of `wctomb'
/tmp/ccntBfBN.o:/usr/include/bits/stdlib.h:74: first defined here
../lib/libgnu.a(c-strncasecmp.o): In function `mbstowcs':
/usr/include/bits/stdlib.h:95: multiple definition of `mbstowcs'
/tmp/ccntBfBN.o:/usr/include/bits/stdlib.h:95: first defined here
../lib/libgnu.a(c-strncasecmp.o): In function `wcstombs':
/usr/include/bits/stdlib.h:114: multiple definition of `wcstombs'
/tmp/ccntBfBN.o:/usr/include/bits/stdlib.h:114: first defined here
../lib/libgnu.a(getopt.o): In function `stpncpy':
/usr/include/bits/string3.h:160: multiple definition of `stpncpy'
/tmp/ccntBfBN.o:/usr/include/bits/string3.h:160: first defined here
../lib/libgnu.a(getopt.o): In function `realpath':
/usr/include/bits/stdlib.h:37: multiple definition of `realpath'
/tmp/ccntBfBN.o:/usr/include/bits/stdlib.h:37: first defined here
../lib/libgnu.a(getopt.o): In function `ptsname_r':
/usr/include/bits/stdlib.h:53: multiple definition of `ptsname_r'
/tmp/ccntBfBN.o:/usr/include/bits/stdlib.h:53: first defined here
../lib/libgnu.a(getopt.o): In function `wctomb':
/usr/include/bits/stdlib.h:74: multiple definition of `wctomb'
/tmp/ccntBfBN.o:/usr/include/bits/stdlib.h:74: first defined here
../lib/libgnu.a(getopt.o): In function `mbstowcs':
/usr/include/bits/stdlib.h:95: multiple definition of `mbstowcs'
/tmp/ccntBfBN.o:/usr/include/bits/stdlib.h:95: first defined here
../lib/libgnu.a(getopt.o): In function `wcstombs':
/usr/include/bits/stdlib.h:114: multiple definition of `wcstombs'
/tmp/ccntBfBN.o:/usr/include/bits/stdlib.h:114: first defined here
../lib/libgnu.a(getopt.o): In function `gets':
/usr/include/bits/stdio2.h:94: multiple definition of `gets'
/tmp/ccntBfBN.o:/usr/include/bits/stdio2.h:94: first defined here
../lib/libgnu.a(getopt.o): In function `fgets':
/usr/include/bits/stdio2.h:109: multiple definition of `fgets'
/tmp/ccntBfBN.o:/usr/include/bits/stdio2.h:109: first defined here
../lib/libgnu.a(getopt.o): In function `fgets_unlocked':
/usr/include/bits/stdio2.h:125: multiple definition of `fgets_unlocked'
/tmp/ccntBfBN.o:/usr/include/bits/stdio2.h:125: first defined here
../lib/libgnu.a(getopt.o): In function `read':
/usr/include/bits/unistd.h:35: multiple definition of `read'
/tmp/ccntBfBN.o:/usr/include/bits/unistd.h:35: first defined here
../lib/libgnu.a(getopt.o): In function `pread':
/usr/include/bits/unistd.h:57: multiple definition of `pread'
/tmp/ccntBfBN.o:/usr/include/bits/unistd.h:57: first defined here
../lib/libgnu.a(getopt.o): In function `pread64':
/usr/include/bits/unistd.h:77: multiple definition of `pread64'
/tmp/ccntBfBN.o:/usr/include/bits/unistd.h:77: first defined here
../lib/libgnu.a(getopt.o): In function `readlink':
/usr/include/bits/unistd.h:99: multiple definition of `readlink'
/tmp/ccntBfBN.o:/usr/include/bits/unistd.h:99: first defined here
../lib/libgnu.a(getopt.o): In function `readlinkat':
/usr/include/bits/unistd.h:121: multiple definition of `readlinkat'
/tmp/ccntBfBN.o:/usr/include/bits/unistd.h:121: first defined here
../lib/libgnu.a(getopt.o): In function `getcwd':
/usr/include/bits/unistd.h:136: multiple definition of `getcwd'
/tmp/ccntBfBN.o:/usr/include/bits/unistd.h:136: first defined here
../lib/libgnu.a(getopt.o): In function `getwd':
/usr/include/bits/unistd.h:150: multiple definition of `getwd'
/tmp/ccntBfBN.o:/usr/include/bits/unistd.h:150: first defined here
../lib/libgnu.a(getopt.o): In function `confstr':
/usr/include/bits/unistd.h:165: multiple definition of `confstr'
/tmp/ccntBfBN.o:/usr/include/bits/unistd.h:165: first defined here
../lib/libgnu.a(getopt.o): In function `getgroups':
/usr/include/bits/unistd.h:181: multiple definition of `getgroups'
/tmp/ccntBfBN.o:/usr/include/bits/unistd.h:181: first defined here
../lib/libgnu.a(getopt.o): In function `ttyname_r':
/usr/include/bits/unistd.h:197: multiple definition of `ttyname_r'
/tmp/ccntBfBN.o:/usr/include/bits/unistd.h:197: first defined here
../lib/libgnu.a(getopt.o): In function `getlogin_r':
/usr/include/bits/unistd.h:213: multiple definition of `getlogin_r'
/tmp/ccntBfBN.o:/usr/include/bits/unistd.h:213: first defined here
../lib/libgnu.a(getopt.o): In function `gethostname':
/usr/include/bits/unistd.h:230: multiple definition of `gethostname'
/tmp/ccntBfBN.o:/usr/include/bits/unistd.h:230: first defined here
../lib/libgnu.a(getopt.o): In function `getdomainname':
/usr/include/bits/unistd.h:248: multiple definition of `getdomainname'
/tmp/ccntBfBN.o:/usr/include/bits/unistd.h:248: first defined here
../lib/libgnu.a(getopt1.o): In function `stpncpy':
/usr/include/bits/string3.h:160: multiple definition of `stpncpy'
/tmp/ccntBfBN.o:/usr/include/bits/string3.h:160: first defined here
../lib/libgnu.a(getopt1.o): In function `realpath':
/usr/include/bits/stdlib.h:37: multiple definition of `realpath'
/tmp/ccntBfBN.o:/usr/include/bits/stdlib.h:37: first defined here
../lib/libgnu.a(getopt1.o): In function `ptsname_r':
/usr/include/bits/stdlib.h:53: multiple definition of `ptsname_r'
/tmp/ccntBfBN.o:/usr/include/bits/stdlib.h:53: first defined here
../lib/libgnu.a(getopt1.o): In function `wctomb':
/usr/include/bits/stdlib.h:74: multiple definition of `wctomb'
/tmp/ccntBfBN.o:/usr/include/bits/stdlib.h:74: first defined here
../lib/libgnu.a(getopt1.o): In function `mbstowcs':
/usr/include/bits/stdlib.h:95: multiple definition of `mbstowcs'
/tmp/ccntBfBN.o:/usr/include/bits/stdlib.h:95: first defined here
../lib/libgnu.a(getopt1.o): In function `wcstombs':
/usr/include/bits/stdlib.h:114: multiple definition of `wcstombs'
/tmp/ccntBfBN.o:/usr/include/bits/stdlib.h:114: first defined here
../lib/libgnu.a(getopt1.o): In function `gets':
/usr/include/bits/stdio2.h:94: multiple definition of `gets'
/tmp/ccntBfBN.o:/usr/include/bits/stdio2.h:94: first defined here
../lib/libgnu.a(getopt1.o): In function `fgets':
/usr/include/bits/stdio2.h:109: multiple definition of `fgets'
/tmp/ccntBfBN.o:/usr/include/bits/stdio2.h:109: first defined here
../lib/libgnu.a(getopt1.o): In function `fgets_unlocked':
/usr/include/bits/stdio2.h:125: multiple definition of `fgets_unlocked'
/tmp/ccntBfBN.o:/usr/include/bits/stdio2.h:125: first defined here
collect2: error: ld returned 1 exit status
make[1]: *** [etags] Error 1
make[1]: Leaving directory `/home/john/bin/emacs/rc/emacs-24.3/lib-src'
make: *** [lib-src] Error 2

I have never seen an error like this before. What does this mean?

我以前从未见过这样的错误。这是什么意思?

2 个解决方案

#1


16  

I had a similar problem on an older Linux version (RHEL 4.9).

我在旧的Linux版本(RHEL 4.9)上遇到了类似的问题。

Following Eric Johnson's link, configuring like so worked for me:

按照Eric Johnson的链接,像so那样配置对我来说是可行的:

./configure CPPFLAGS="-fgnu89-inline"

#2


5  

I was trying to build and install GNU emacs-24.3:

我正在尝试构建和安装GNU emacs-24.3:

> uname -a
Linux mymachine 2.6.18-274.12.1.el5 #1 SMP Tue Nov 8 21:37:35 EST 2011 x86_64 x86_64 x86_64 GNU/Linux
> pwd
emacs-24.3
> ./configure
> make

and greeted with almost exactly the same "multiple definition" errors as user815423426 reported.

而user815423426报告的“多重定义”错误与user815423426几乎完全相同。

Before fully understanding what "-fgnu89-inline" means, I just used Nemo's magic line, and voila, it went through:

在完全理解“-fgnu89-inline”是什么意思之前,我使用了Nemo的魔术线。

> ./configure CPPFLAGS="-fgnu89-inline"
> make
> make install

Salute to our experts!

为我们的专家们致敬!

#1


16  

I had a similar problem on an older Linux version (RHEL 4.9).

我在旧的Linux版本(RHEL 4.9)上遇到了类似的问题。

Following Eric Johnson's link, configuring like so worked for me:

按照Eric Johnson的链接,像so那样配置对我来说是可行的:

./configure CPPFLAGS="-fgnu89-inline"

#2


5  

I was trying to build and install GNU emacs-24.3:

我正在尝试构建和安装GNU emacs-24.3:

> uname -a
Linux mymachine 2.6.18-274.12.1.el5 #1 SMP Tue Nov 8 21:37:35 EST 2011 x86_64 x86_64 x86_64 GNU/Linux
> pwd
emacs-24.3
> ./configure
> make

and greeted with almost exactly the same "multiple definition" errors as user815423426 reported.

而user815423426报告的“多重定义”错误与user815423426几乎完全相同。

Before fully understanding what "-fgnu89-inline" means, I just used Nemo's magic line, and voila, it went through:

在完全理解“-fgnu89-inline”是什么意思之前,我使用了Nemo的魔术线。

> ./configure CPPFLAGS="-fgnu89-inline"
> make
> make install

Salute to our experts!

为我们的专家们致敬!