Creating a dynamic library from static using gcc -shared -m64 -Wl, - the entire archive ./*. A

I get this set of gcc errors and I cannot get a response from google or man pages. Any insight into what this means or where to start looking?

Here is the line in the 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 

I get the following errors (there are many more, I took the top n to give an idea:

 /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': 

Update

The static libraries I'm trying to combine are as follows:

 -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 

I did a separate compilation on each of the files, so no links were made. I looked at the source and I do not see anything related to libgcc. That is why a mistake does not make me with me.

+4
source share
2 answers

It only means what he says. There are two or more .a files containing .o files containing definitions of these functions. In particular, it looks like your directory contains either two variants of libgcc.a, or something that contains a copy of it.

Do not do this with libgcc.a at all. To omit libgcc add -nostdlib or even -nodefaultlibs.

+1
source

You are missing the closing --no-whole-archive . it

  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 

Without closing the --no-whole-archive source --whole-archive will affect all libraries passed to the linker, in particular libgcc, which is always implicitly passed. That is why you get duplicate characters.

+12
source

Source: https://habr.com/ru/post/1389127/


All Articles