segfault when creating graphic3d_graphicdevice on 64-bit (solution)

This was really bugging me. I compared my code to that in qtocc and couldn't find a significant difference. The environment variable $CSF_GraphicShr pointed to libTKOpenGl.so as it should. Changing the display string had no effect unless I tried something long like localhost:0.0 - in that case I got an Assert error rather than a segfault.

I added the following to my .pro file and recompiled. Now I don't get the segfault.
DEFINES += _OCC64
QMAKE_CXXFLAGS += -m64

Here's part of GDB's output, in case someone tries searching the forum for that in the future:
Program received signal SIGSEGV, Segmentation fault.
in Handle_Standard_Transient::EndScope ()
from libTKernel.so.0
(gdb) bt
in Handle_Standard_Transient::EndScope ()
from libTKernel.so.0
in Handle_Standard_Transient::Assign ()
from libTKernel.so.0
in Handle_Graphic3d_GraphicDevice::operator= (this= ,
anItem= ) at Handle_Graphic3d_GraphicDevice.hxx:61
(...)

P Dolbey's picture

The pro file for "qtgeom" in the qtocc svn trunk contains the following qmake directives that use the uname command to detect 64 bit hosts.
.
.
unix:!macx {
message ("Building for Linux")
DEFINES += LIN LININTEL HAVE_CONFIG_H HAVE_IOSTREAM HAVE_FSTREAM HAVE_LIMITS_H
QMAKE_CXXFLAGS += -ffriend-injection

HARDWARE_PLATFORM = $$system(uname -m)
contains( HARDWARE_PLATFORM, x86_64 ) {
# 64-bit Linux
message ("Adding Linux 64 bits compile flags and definitions")
DEFINES += _OCC64
QMAKE_CXXFLAGS += -m64

} else {
# 32-bit Linux
}
}
.
.
The SVN contains more useful code than the, now aging, zip files.

Pete

Mark's picture

Pete, your snippet would be much more versatile. Right now I'm just trying to get it working for myself :).

Now the app runs but the view doesn't actually show up, even if I resize. That region of the window is the background color. Nothing jumps out at me if I compare it to qtocc or my older qt3 stuff. Suggestions?

Mark