Linking problem with IRIX 6.5 and OpenGL

Philip Dunstan dunstan@ee.uwa.edu.au
Wed Apr 7 21:11:00 GMT 1999


Hi,

I'm trying to use egcs 1.1.2  to compile some OpenGL programs under IRIX 6.5
The code compiles okay (albeit with some preempt type messages), but then 
gives a segmentation fault on execution.


Here is an example piece:

example.C:
----
#include <iostream>
#include <GL/glut.h>

void draw (void) {
}

int main (int argc, char **argv) {
  glutInit (&argc, argv);
  glutInitDisplayMode (GLUT_RGBA);
  glutCreateWindow("hello");
  glutDisplayFunc(draw);

  cout << "hello" << endl << flush;
  glutMainLoop ();
}
----


compiled with:
g++ -Wall example.C -lglut -lGL -lGLU -lXmu -lXext -lX11


gives this warning:
ld32: WARNING 85: definition of __throw in
/usr/local/lib/gcc-lib/mips-sgi-irix6.5/egcs-2.91.66/libgcc.a(_eh.o)
preempts that definition in /usr/lib32/libC.so.2.
ld32: WARNING 85: definition of __dynamic_cast in
/usr/local/lib/gcc-lib/mips-sgi-irix6.5/egcs-2.91.66/libgcc.a(tinfo2.o)
preempts that definition in /usr/lib32/libC.so.2.
ld32: WARNING 85: definition of cin in
/usr/local/lib/libstdc++.a(stdstreams.o) preempts that definition in
/usr/lib32/libC.so.2.
ld32: WARNING 85: definition of cout in
/usr/local/lib/libstdc++.a(stdstreams.o) preempts that definition in
/usr/lib32/libC.so.2.
ld32: WARNING 85: definition of cerr in
/usr/local/lib/libstdc++.a(stdstreams.o) preempts that definition in
/usr/lib32/libC.so.2.
ld32: WARNING 85: definition of clog in
/usr/local/lib/libstdc++.a(stdstreams.o) preempts that definition in
/usr/lib32/libC.so.2.


and then segmentation faults when i run it.
Process 10193 (a.out) stopped on signal SIGSEGV: Segmentation violation
(default) at [ios::init(streambuf*):43 ,0xac915dc]
         Source (of
/lv7/mtibuild/v721/workarea/v7.2+/libC/iostreams/stream.cxx) not
available for Process 10193
(dbx) >  0 ios::init(streambuf*)(0x0, 0x10042098, 0x10042098,
0x10042098, 0xffffffff, 0x0, 0x3, 0xacd328c)
["/lv7/mtibuild/v721/workarea/v7.2+/libC/iostreams/stream.cxx":43,
0xac915dc]
   1 ostream_withassign::operator=(streambuf*)(0x10040b88, 0x10042098,
0x10042098, 0x10042098, 0xffffffff, 0x0, 0x3, 0xacd328c)
["/lv7/mtibuild/v721/workarea/v7.2+/libC/iostreams/stream.cxx":290,
0xac92b24]
   2 Iostream_init::Iostream_init(void)(0x1, 0x10042098, 0x10042098,
0x10042098, 0xffffffff, 0x0, 0x3, 0xacd328c)
["/lv7/mtibuild/v721/workarea/v7.2+/libC/iostreams/cstreams.cxx":63,
0xac852b8]
   3 ::_main(0x0, 0x10042098, 0x10042098, 0x10042098, 0xffffffff, 0x0,
0x3, 0xacd328c)
["/lv7/mtibuild/v721/workarea/v7.2+/libC/lang_support/c++init.cxx":77,
0xac7f974]
   4 init_bridge(0x0, 0x0, 0x10042098, 0x10042098, 0xffffffff, 0x0, 0x3,
0xacd328c)
["/comp2/mtibuild/v7212m/workarea/v7.2.1.2m/rld/rld_bridge.s":257,
0xfb6045c]
   5 call_init(0xfbe6150, 0x10042098, 0x10042098, 0x10042098,
0xffffffff, 0x0, 0x3, 0xacd328c)
["/comp2/mtibuild/v7212m/workarea/v7.2.1.2m/rld/rld.c":3689, 0xfb66d84]
   6 run_init_code(0xfbe6150, 0x10042098, 0x10042098, 0x10042098,
0xffffffff, 0x0, 0x3, 0xacd328c)
["/comp2/mtibuild/v7212m/workarea/v7.2.1.2m/rld/rld.c":3756, 0xfb66dd4]
   7 forall_previous_objs(0xfbdc418, 0xfbe8190, 0x10042098, 0x10042098,
0xffffffff, 0x0, 0x3, 0xacd328c)
["/comp2/mtibuild/v7212m/workarea/v7.2.1.2m/rld/list.c":263, 0xfb61544]
   8 execute_all_init_sections(0x0, 0x10042098, 0x10042098, 0x10042098,
0xffffffff, 0x0, 0x3, 0xacd328c)
["/comp2/mtibuild/v7212m/workarea/v7.2.1.2m/rld/rld.c":3805, 0xfb66f30]
   9 do_initial_resolutions_and_run_inits(0x0, 0x10042098, 0x10042098,
0x10042098, 0xffffffff, 0x0, 0x3, 0xacd328c)
["/comp2/mtibuild/v7212m/workarea/v7.2.1.2m/rld/rld_startup.c":1137,
0xfb6fd34]
   10 sgi_main(0x0, 0x1, 0x7fff2f14, 0x10042098, 0xffffffff, 0x0, 0x3,
0xacd328c)
["/comp2/mtibuild/v7212m/workarea/v7.2.1.2m/rld/rld_startup.c":1517,
0xfb702dc]
   11 newmain()
["/comp2/mtibuild/v7212m/workarea/v7.2.1.2m/rld/rld_newmain.s":68,
0xfb60184]



If I remove the cout line and #include <iostream> I only get this error
on linking:
ld32: WARNING 84: /usr/local/lib/libstdc++.a is not used for resolving
any symbol.
and it runs okay.


It seems that it is linking in the system libC.so instead of libstdc++
but I don't know how these things work.


Thanks,
Phil
--
Philip Dunstan               dunstan@ee.uwa.edu.au
PhD student (IT Eng)         http://ciips.ee.uwa.edu.au/~dunstan
entre for Intelligent Information Processing Systems
University of Western Australia  

"Beware of bugs in the above code; I have only proved it correct, not
tried it."
      -- Donald Knuth 




More information about the Gcc mailing list