5

我收到了这组 gcc 错误,我似乎无法从谷歌或手册页中得到答案。关于这些意味着什么或从哪里开始寻找的任何见解?

这是makefile中的行:

#After building several otehr bits of code into static libraries
...
# Grand finally link all the object files into one
        gcc --shared  \
        -m64 \
        -Wl,--whole-archive ./release64/*.a \
        -o ./release64/libMYLIB.so.1.0
        ln -sf libArcGIS.so.1.0 ./release64/libMYLIB.so
        ln -sf libArcGIS.so.1.0 ./release64/libMYLIB.so.1

我收到以下错误(还有很多我拿了前 n 只是为了给出一个想法:

/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgcc.a(_muldi3.o): In function `__multi3':
(.text+0x0): multiple definition of `__multi3'
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgcc.a(_muldi3.o):(.text+0x0): first defined here
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgcc.a(_negdi2.o): In function `__negti2':
(.text+0x0): multiple definition of `__negti2'
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgcc.a(_negdi2.o):(.text+0x0): first defined here
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgcc.a(_lshrdi3.o): In function `__lshrti3':
(.text+0x0): multiple definition of `__lshrti3'
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgcc.a(_lshrdi3.o):(.text+0x0): first defined here
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgcc.a(_ashldi3.o): In function `__ashlti3':
(.text+0x0): multiple definition of `__ashlti3'
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgcc.a(_ashldi3.o):(.text+0x0): first defined here
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgcc.a(_ashrdi3.o): In function `__ashrti3':
(.text+0x0): multiple definition of `__ashrti3'
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgcc.a(_ashrdi3.o):(.text+0x0): first defined here
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgcc.a(_cmpdi2.o): In function `__cmpti2':
(.text+0x0): multiple definition of `__cmpti2'
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgcc.a(_cmpdi2.o):(.text+0x0): first defined here
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgcc.a(_ucmpdi2.o): In function `__ucmpti2':
(.text+0x0): multiple definition of `__ucmpti2'
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgcc.a(_ucmpdi2.o):(.text+0x0): first defined here
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgcc.a(_clear_cache.o): In function `__clear_cache':
(.text+0x0): multiple definition of `__clear_cache'
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgcc.a(_clear_cache.o):(.text+0x0): first defined here
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgcc.a(_enable_execute_stack.o): In function `__enable_execute_stack':
(.text+0x0): multiple definition of `__enable_execute_stack'
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgcc.a(_enable_execute_stack.o):(.text+0x0): first defined here
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgcc.a(_absvsi2.o): In function `__absvsi2':
(.text+0x0): multiple definition of `__absvsi2'
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgcc.a(_absvsi2.o):(.text+0x0): first defined here
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgcc.a(_absvsi2.o): In function `__absvdi2':
(.text+0x20): multiple definition of `__absvdi2'
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgcc.a(_absvsi2.o):(.text+0x20): first defined here
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgcc.a(_absvdi2.o): In function `__absvti2':
(.text+0x0): multiple definition of `__absvti2'
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgcc.a(_absvdi2.o):(.text+0x0): first defined here
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgcc.a(_addvsi3.o): In function `__addvsi3':
(.text+0x0): multiple definition of `__addvsi3'
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgcc.a(_addvsi3.o):(.text+0x0): first defined here
/usr/lib/gcc/x86_64-redhat-linux/4.4.5/libgcc.a(_addvsi3.o): In function `__addvdi3':

更新

我试图结合的静态库是:

-rw-rw-r-- 1 mehoggan mehoggan  487770 Jan  3 11:17 libfreetype.a
-rw-rw-r-- 1 mehoggan mehoggan  227814 Jan  3 11:17 libjpeg.a
-rw-rw-r-- 1 mehoggan mehoggan  258576 Jan  3 11:17 libpng.a
-rw-rw-r-- 1 mehoggan mehoggan 2392136 Jan  3 11:17 libSkia.a
-rw-rw-r-- 1 mehoggan mehoggan  696756 Jan  3 11:17 libSQlite.a
-rw-rw-r-- 1 mehoggan mehoggan 1517832 Jan  3 11:16 libSymbolXLib.a
-rw-rw-r-- 1 mehoggan mehoggan  928934 Jan  3 11:17 libxml2.a

我对每个文件进行了单独编译,因此没有执行链接。我查看了源代码,没有看到任何涉及 libgcc 的内容。这就是为什么这个错误对我来说不是。

4

2 回答 2

21

你错过了一个结束--no-whole-archive。那是

    gcc --shared  \
    -m64 \
    -Wl,--whole-archive ./release64/*.a -Wl,--no-whole-archive \
    -o ./release64/libMYLIB.so.1.0
    ln -sf libArcGIS.so.1.0 ./release64/libMYLIB.so
    ln -sf libArcGIS.so.1.0 ./release64/libMYLIB.so.1

如果没有关闭--no-whole-archive,初始--whole-archive值将影响传递给链接器的所有库,特别是 libgcc,它总是隐式传递。这就是为什么你会得到重复的符号。

于 2013-02-13T21:30:29.917 回答
1

它的意思就是它所说的。有两个或多个 .a 文件包含 .o 文件,这些文件包含这些函数的定义。特别是,您的目录看起来好像包含 libgcc.a 的两个变体或包含它的副本的内容。

根本不要对 libgcc.a 这样做。要省略 libgcc,请添加 -nostdlib 甚至 -nodefaultlibs。

于 2012-01-03T18:28:18.340 回答