[gnu.g++.help] _CTOR_LIST and _DTOR_LIST on DS3100

jj00@eurotherm.co.uk (John Juer) (10/11/90)

>  I have built g++ 1.37.1 and libg++ 1.37.0 on the DecStation 3100 but
>  run into problems whenever I try to make one of the test programs:
>
>  g++  test.hello.o -L/other/X.V11R4.mips/pdsoft/libg++-1.37.0/src -lg++ -lm  -
o test0
>  ld:
>  Undefined:
>  __DTOR_LIST__
>  __CTOR_LIST__
>  *** Error code 1

We run g++ 1.37.1 on Dec 3100

You have to use collect. In your makefile put

COFFLAGS = -DUSE_COLLECT -DEXTENDED_COFF

If you run g++ with the -v it should do something like

g++ -O -o myprog -v main.o lib/pr.a lib/ut.a lib/sy.a lib/co.a lib/lx.a \
lib/sy.a cft/cftout.o
g++ version 1.37.1 (based on GCC 1.37)
 ld -r -o /usr/tmp/cca27472.R -G 8 /lib/crt0.o main.o lib/pr.a lib/ut.a lib/sy
.a lib/co.a lib/lx.a lib/sy.a cft/cftout.o -L/usr/local/lib -lg++ /usr/local/lib
/gcc-gnulib -lc
collect -o /usr/tmp/cca27472.S /usr/tmp/cca27472.R
as /usr/tmp/cca27472.S -o /usr/tmp/cca27472.O
ld -o myprog /usr/tmp/cca27472.R /usr/tmp/cca27472.O

You also need a couple of routines to actually use the lists
of constructors/destructors set up by collect. We have


void
__do_global_init ()
{
  extern void (*__CTOR_LIST__)();
  register void (**ppf)() = &__CTOR_LIST__;
  register int *pi = (int *)ppf;
  register int nc = *pi;
  ppf++;

  while (nc)
    {
      (*ppf)();
      nc--;
      ppf++;
    }
}

__main() {  /* g++ calls this directly after entry into main */
__do_global_init();
}

in the g++ library , and a similar hack for exit.


Janet:    jj00@uk.co.eurotherm    | Eurotherm Limited, Faraday Close,
Internet: jj00@eurotherm.co.uk    | Durrington, Worthing, W.Sussex, England.
UUCP:     {ukc,uunet}!etherm!jj00 | Phone: +44 903 68500 x2229 Fax: +44 903 65982