This is the mail archive of the gcc-bugs@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]

dynamic linking of c++ libs / gcc2.95 - binutils 2.9.1.0.25


Hi,

    after finding out that you need the very latest binutils (2.9.1.0.25)
for compiling gcc.295 on solaris 
(see http://egcs.cygnus.com/ml/gcc-bugs/1999-08/msg00113.html)
I run into another problem which is most likely related to the binutils
again.

    If you link a dynamic library that contains references to 
iostream against an executable that uses iostream you get undefined
results in the iostream output. The following sh script demonstrates
the problem:


--------------------------------   
#!/bin/sh

echo '
#include <iostream>
#include <iomanip>
int main() {
  cout << setw(6) << 1 << endl;
}' > test.C

echo '
#include <iostream>
class Nope {
  friend ostream& operator << ( ostream &os, const Nope & );
public:
};
ostream& operator << ( ostream &os, const Nope & ) {
  return os << "";
}' > libNope.C


g++-2.95-gnu -v -g -fPIC -G -o libNope.so libNope.C
g++-2.95-gnu -g -fPIC test.C -o bug -L. -lNope -Wl,-R`pwd`
g++-2.95-gnu -g -fPIC test.C -o nobug 

echo '==============='
echo 'output of bug'
./bug
echo 'output of nobug'
./nobug

----------------------------------- 

On solaris 2.6 I see:

Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.95/specs
gcc version 2.95 19990728 (release)
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.95/cpp -lang-c++ -v -D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=95 -D__cplusplus -Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 -D__sparc__ -D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -D__sparc -D__sun -D__unix -Asystem(unix) -Asystem(svr4) -D__EXCEPTIONS -g -D__GCC_NEW_VARARGS__ -Acpu(sparc) -Amachine(sparc) libNope.C /tmp/cccLMRIV.ii
GNU CPP version 2.95 19990728 (release) (sparc)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.95/../../../../include/g++-3
 /usr/local/include
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.95/../../../../sparc-sun-solaris2.6/include
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.95/include
 /usr/include
End of search list.
The following default directories have been omitted from the search path:
End of omitted list.
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.95/cc1plus /tmp/cccLMRIV.ii -quiet -dumpbase libNope.cc -g -version -fPIC -o /tmp/ccaAx7uR.s
GNU C++ version 2.95 19990728 (release) (sparc-sun-solaris2.6) compiled by GNU C version 2.95 19990728 (release).
 /usr/local/bin/g291025-as -V -Qy -s -K PIC -o /tmp/cc9lzYF0.o /tmp/ccaAx7uR.s
GNU assembler version 2.9.1 (sparc-sun-solaris2.6), using BFD version 2.9.1.0.25
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.95/collect2 -V -G -Y P,/usr/ccs/lib:/usr/lib -Qy -o libNope.so /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.95/crt1.o /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.95/crti.o /usr/ccs/lib/values-Xa.o /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.95/crtbegin.o -L/usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.95 -L/usr/local/sparc-sun-solaris2.6/lib -L/usr/ccs/bin -L/usr/ccs/lib -L/usr/local/lib /tmp/cc9lzYF0.o -lstdc++ -lm -lgcc -lc -lgcc /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.95/crtend.o /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.95/crtn.o
GNU ld version 2.9.1 (with BFD 2.9.1.0.25)
  Supported emulations:
   elf32_sparc
===============
output of bug
91
output of nobug
     1


     If I can be helpful to nail this down further - please let me know.

                  Wolfgang


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