This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problems linking c++ statically on AIX using gcc 3.2


>>>>> Mads  writes:

Mads> I am aware of the recommandation of native binutils, but was trying gnu
Mads> binutils to avoid the following problem:

Mads> bash-2.05$ g++ test.o testlib.a -o test
Mads> ld: 0711-317 ERROR: Undefined symbol: .undefinedfunction()
Mads> ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
Mads> information.
Mads> collect2: ld returned 8 exit status

Mads> Removing testlibunused from the archive is not an option.

Mads> The example works on HP, Sun and Linux, but not on AIX.

Mads> How do I link the example on AIX? Is it possible?

	This is not problem which is solved by using GNU Binutils instead
of the AIX tools.  This is a limitation of GCC due to the way that it
interacts with AIX's garbage-collecting linker and scanning for static
constructors, destructors and exception handling frame information.

	GCC searches for static constructors, destructors, and EH routines
before linking because it does not know which of those routines will be
used.  If GCC performed an initial link step to apply archive library
semantics, the linker would garbage-collect the unreferenced static
constructors, destructors, and EH information before they were discovered.

	Most developers consider working static constructors, destructors,
and EH more fundamental than support for archives which contain references
to missing symbols.

	Your choices are:

1) Do not create archives containing references to undefined functions.

2) Provide dummy definitions of the undefined functions.

3) Design the source files containing the unused functions which reference
undefined functions so that they do not contain static constructors and
destructors, and do not use exception handling.  This allows those source
files to be compiled with -fno-exceptions and those functions will not be
referenced implicitly during the link step.

4) Develop a robust solution for this limitation of GCC.

5) Use a different compiler on AIX.

David


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]