From: Brad K. <bra...@ki...> - 2002-01-15 20:57:57
|
Fred, I just installed gcc 3.0.2 (second from most recent version) on a Sun at Kitware. The example below cannot duplicate your problem. I suggest you try installing gcc 3.0.3 in your home directory and do the build with that. Make sure that your LD_LIBRARY_PATH is set correctly to find the gcc-3.0.3 version of the standard C++ library when you run the executable. -Brad > ############################################################################ > > cd /tmp > > # LIBRARY FILE 1 > > cat<<EOF >| file1.cxx > // dropping this include fixes the problem > #include <iostream> > EOF > > c++ -fPIC -c file1.cxx -o file1.o > > # LIBRARY FILE 2 > > cat<<EOF >| file2.cxx > #include <vector.h> > // dropping this expression fixes the problem > namespace { > void tic(int nargs) { > vector<bool> done_once(nargs, false); > } > } > EOF > > # dropping -O2 here fixes problem > c++ -O2 -fPIC -c file2.cxx -o file2.o > > # MAIN > > cat<<EOF >| foo.cxx > int main() { return 0; } > EOF > > c++ -c foo.cxx -o foo.o > > # BUILD LIBRARY > > # with this option there is no bus error > OPT="-Wl,-G" > # with this option there is no bus error > OPT="-shared" > # with this option the exec will produce a bus error > OPT="-shared -nostdlib" > > # build library with only two objects > # dropping either object fixes the problem > c++ $OPT -O2 -fPIC -o /tmp/libbar.so file1.o file2.o > > # LINK > > c++ foo.o -L/tmp -lbar -Wl,-R,/tmp: -o foo > > # RUN > > # bus error will occur here if "-shared -nostdlib" was used > ./foo > > ############################################################################ |