G4OpenGLXViewer problem with macOS Catalina

Dear Experts,

I’m working with Geant4 10.6 on mac OS Catalina 15.10.5 with XQuartz 2.7.11 and I’m looking at /examples/extended/runAndEvent/RE03/

When I run: ./RE03 vis.mac I obtain the error you can find in [1] at the end of this email.

What is my mistake?
How can I fix it?

Thanks in advance.

Best Regards,
Sergio Lo Meo

G4OpenGLXViewer::G4OpenGLXViewer: unable to get a single buffer visual.
G4OpenGLXViewer::G4OpenGLXViewer: unable to get a double buffer visual.
G4OpenGLXViewer::G4OpenGLXViewer: unable to get required visuals.
G4OpenGLStoredX::CreateViewer: error flagged by negative view id in G4OpenGLStoredXViewer creation.
Destroying view and returning null pointer.
ERROR in G4VisManager::CreateViewer: null pointer during OpenGLStoredX viewer creation.
No action taken.
WARNING: No viewer created.
WARNING: G4VisCommandSceneAddVolume::SetNewValue:
Parallel worlds requested but none exist.
Just adding material world.
ERROR: G4VisCommandsViewerSet::SetNewValue: no current viewer.
ERROR: G4VisCommandsViewerZoom::SetNewValue: no current viewer.

I once was told the definition of an “expert”: “x” = “unknown”, and “spurt” is “a drip under pressure”. Let us put aside British humour…the fact is that we are all learning new things.

Like you I am on MacOS 10.15.5 (I think you meant 10.15.5), and on XQuartz 2.7.11 (xorg-server 1.18.4). RE03 works fine for me.

All I can do is recommend re-installing/re-starting XQuartz. Perhaps a reboot too?

Let us know how it goes.

John

Hi John,

All I can do is recommend re-installing/re-starting XQuartz. Perhaps a reboot too?

I performed all your suggestions… but it doesn’t work…

Any ideas?
Thanks again

Sergio

Mmm. We had some trouble with Mac and XQuartz 3 years ago - but it went away. A workaround then was to open an xterm window and type

xstdcmap -all

Let me know if it helps.

Hi John,

xstdcmap -all

I did it, but the problem still remains…

Before writing in the forum, I had the problem explained in Problem with Geoviewer 3.0.7 on Mac OS High Sierra - Installation - FLUKA User Forum
I fiexd this and now I have what I asked yesterday…

Cheers,

Sergio

Hi. With XQuartz 2.7.11, you have to activate OpenGL (which is not done by default now) by typing in a terminal something as :
macOS> defaults write org.macosforge.xquartz.X11 enable_iglx -bool true
and then restart XQuartz. At least this is needed if doing remote X11 and it may help here…
Cheers. Guy

Hi Guy,

it fails again… I don’t know…

tks again
Cheers,

Sergio

Another thought…

Did you get XQuartz from macports. Try getting it directly from https://www.xquartz.org as a dmg.

Another thought…

At one time, as a result of using macports, I had two versions of X11, which caused chaos. The dmg puts X11 in /opt/ and there are links in /usr/:

~$ ll /usr/X*
lrwxr-xr-x 1 root wheel 25 May 29 00:07 /usr/X11@ → …/private/var/select/X11
lrwxr-xr-x 1 root wheel 25 May 29 00:07 /usr/X11R6@ → …/private/var/select/X11
~$ ll /private/var/select/X11
lrwxr-xr-x 1 root wheel 8 Dec 9 2019 /private/var/select/X11@ → /opt/X11

Hi John,

I got XQuartz from www.quartz.org.

Here “ls /usr/X*”:

/usr/X11:
bin etc include lib libexec share var

/usr/X11R6:
bin etc include lib libexec share var

Here “ls /opt/X11”:
+++
bin etc include lib libexec share var
+++

What’s wrong?
Cheers,

Sergio

Hi Sergio, John

I can reproduce, and yes for me the problem comes clearly from a mix up of the usage of the libX11.dylib taken from /opt/local/lib (then coming from a MacPorts installation) and the usage of the libGL.dylib taken from /opt/X11 (then coming from the XQuartz installation). (And for which there is a symlink from /usr/X11R6; are really nasty point) (and which is installed under /opt, which is confusing relative to MacPorts that installs under /opt/local).

If in the build of your example, you do a “export VERBOSE=1” (or “setenv VERBOSE 1”, if under a csh), and then do “make” again (by rooming the RE03 binary), you will probably see that in the (long) link command, you too mix both.

If I use the Geant4 dylib, in fact I have a crash with something as :
assertion failed: (pthreadret == 0), function _xcb_in_wake_up_next_reader, file xcb_in.c, line 926

and if I use the Geant4 .a static libs, I have the same problem that you describe. I think that “it passed” at the time of Morave because the two lib sets where not so much different, but now there is clearly a big gap, at least concerning the dates and sizes from the libs coming with MacPorts and the ones of XQuartz.

THEN, what is bad, is that for me the cmake on the build of Geant4 clearly says :
– Found X11: /opt/local/include
– Looking for XOpenDisplay in /opt/local/lib/libX11.dylib;/opt/local/lib/libXext.dylib
– Looking for XOpenDisplay in /opt/local/lib/libX11.dylib;/opt/local/lib/libXext.dylib - found
and for OpenGL :
– Found XQuartzGL: /opt/X11/include

then the cmake mixed both libs. What I did for the moment is just tweak the :

cmake/Modules/FindXQuartzGL.cmake

to use the GL found under /opt/local/include and /opt/local/lib. It is easy to do, just replace the PATHS
in this file to use only these. And then coffee + rebuild…

Note that you may not have the libGL in your MacPorts area, if not, you can have have them with:

sudo port install mesa (or glxinfo, or better libGLU to have also libGLU)

Then when building your example, cross check the link command and run… It should pass… (with G4 dylibs or .a). (Then you should see in the link command : /opt/local/lib/libX11.dylib and /opt/local/lib/libGL.dylib).

In my things, I use MacPorts for all my X11 things, and I changed them to enforce the usage of libGL coming from that. I think that we must definitely forget the libs of XQuartz when building and run “X11 clients”. One critical point is that for example Motif (I still use it, and is still usable with Geant4), does not come with XQuartz, but can be installed with MacPorts in a consistent way with the rest. (I cross checked, and all my Motif apps doing GL is ok on Catalina if being “all MacPorts”).

If someone install things with Brew, it should be the same, someone must use all X11, GL, (Motif) coming with it. (I don’t like Brew, it touches things under /usr, which does not do MacPorts. With MacPorts all is under /opt/local (I think) (I hope)).

Then try by “arranging” to use “consistent” libX11 and libGL…

Well, if you do not want to use anything from MacPorts or Brew, you will have to find a way to enforce the usage of the XQuartz X11 in the G4 cmake, but I don’t know how to do that.

And (for the vis group), it is clearly needed to revisit the G4 cmake logic to be sure to be consistent with X11 and GL (and Motif) (both should be taken from the same source; or XQuartz, or MacPorts, or Brew).

Cheers. Let us know… Guy

(And next year we are going to have “Big Sur” with another architecture. More fun is going to come… :slight_smile: )

Hi Guy,

thank you very much for the information.

  1. I perfomed “sudo port install libGLU”

  2. after “export VERBOSE=1” in the build directory of RE03 I made the “cmake” and you can find the output in [**].

I have seen the lines related to “XOpenDisplay”

You wrote:

What I did for the moment is just tweak the : cmake/Modules/FindXQuartzGL.cmake

but I didn’t find the FindXQuartzGL.cmake file…

where is my mistake?
Cheers,

Sergio

[**]
(base) MacAirLoMeo:RE03-build sergiolomeo$ cmake -DGeant4_DIR=/Users/sergiolomeo/g4.10.06/geant4.10.06-install/lib/Geant4-10.6.0/ /Users/sergiolomeo/myWork/RE03
Re-run cmake no build system arguments
– The C compiler identification is AppleClang 11.0.3.11030032
– The CXX compiler identification is AppleClang 11.0.3.11030032
– Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
– Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - works
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Detecting C compile features
– Detecting C compile features - done
– Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
– Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - works
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Detecting CXX compile features
– Detecting CXX compile features - done
– Found EXPAT: /opt/local/lib/libexpat.dylib (found suitable version “2.2.9”, minimum required is “2.2.9”)
– Found XercesC: /opt/local/lib/libxerces-c.dylib (found suitable version “3.2.2”, minimum required is “3.2.2”)
– Found X11: /opt/local/include
– Looking for XOpenDisplay in /opt/local/lib/libX11.dylib;/opt/local/lib/libXext.dylib
– Looking for XOpenDisplay in /opt/local/lib/libX11.dylib;/opt/local/lib/libXext.dylib - found
– Looking for gethostbyname
– Looking for gethostbyname - found
– Looking for connect
– Looking for connect - found
– Looking for remove
– Looking for remove - found
– Looking for shmat
– Looking for shmat - found
– Looking for IceConnectionNumber in ICE
– Looking for IceConnectionNumber in ICE - found
– Found OpenGL: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/OpenGL.framework
– Found XQuartzGL: /opt/X11/include
– Configuring done
– Generating done
– Build files have been written to: /Users/sergiolomeo/myWork/RE03-build

Hi Sergio

– Found X11: /opt/local/include
– Found XQuartzGL: /opt/X11/include

This is clearly the problem. X11 is taken in one place, and OpenGL in another one.

I don’t like to see the line :

– Found OpenGL: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/OpenGL.framework

which induces that the Apple OpenGL is going to be around… (It should not if building “pure GNU/X11 mesa OpenGL”). But well, let us forget this for the moment.

Then first check that you have in the MacPorts area :

/opt/local/include/X11/Xlib.h, etc .... 
/opt/local/include/GL/gl.h, etc... 
/opt/local/include/GLU/glu.h

and the libs :

/opt/local/lib/libX11.dylib
/opt/local/lib/libGL.dylib
/opt/local/lib/libGLU.dylib

If so, then you have the .h and .dylib needed to build the default “X11 and OpenGL” G4 driver.

Then, concerning Geant4, I worked on the source code of the last 10.0.6.p02 taken from Geant4 site.
In it I have the file :

./geant4.10.06.p02/cmake/Modules/FindXQuartzGL.cmake

It is this one that I tweaked to enforce in the PATHS found here : /opt/local/include and /opt/local/lib.
If this file is not here for you then you have a G4 version where this cmake logic is not here. If you don’t want to go to 10.06.p02, well, we will need the help of John to see how to enforce MacPorts GL on your version…

But assuming that you find the file and tweak it , then you have to rebuild now your all G4… And in the cmake log, you should have now :

– Found X11: /opt/local/include
– Found XQuartzGL: /opt/local/include

then proceed to fully rebuild G4 and your example…

(I still have the line about the Apple OpenGL, and some “framework OpenGL.tdb” appears in my link command. If I arrange to remove it, it links and runs anyway, then I think that this is not needed if using the “GNU X11 mesa OpenGL” way. This has to be fixed too (I think)).

Then have another try :slight_smile:

Cheers. Guy

Note that you can customise any of the X11 paths through your CMake configuration, just editing them through ccmake (toggle the advanced mode) or cmake-gui, without having to tweak any of the builtin scripts.

Cheers, Gabriele

Hi Gabriele

Right, having in my cmake command line options :

-DXQuartzGL_INCLUDE_DIR=/opt/local/include -DXQuartzGL_gl_LIBRARY=/opt/local/lib -DXQuartzGL_gluchec_LIBRARY=/opt/local/lib

does the job.

I still have the line :

– Found OpenGL: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/OpenGL.framework

What would be the clean way to have a try without this ?

Cheers. Guy

Oups, I had a typo in my previous post, it should be :

-DXQuartzGL_glu_LIBRARY=/opt/local/lib

and not “gluchec”…

But anyway, I speak to fast, it does not build for me, then it does not seem to be the right cmake options to enforce cleanly the X11 and OpenGL paths… :frowning:

Back again. Then “obviously” it should be :

-DXQuartzGL_INCLUDE_DIR=/opt/local/include -DXQuartzGL_gl_LIBRARY=/opt/local/lib/libGL.dylib -DXQuartzGL_glu_LIBRARY=/opt/local/lib/libGLU.dylib

I just finished a full G4 (then 10.06.p02) rebuild + build and run of RE03 and it is ok for me. Then we have at least one “not tweaked” solution.

Guy

(But I still have the Apple OpenGL things in my link command, that, I think, should not be here).

Hi Guy,

I just finished a full G4 (then 10.06.p02) rebuild

do you mean that it is necessary to rebuild all G4 with the cmake options you suggested?

Cheers,
Sergio

Strictly speaking, it is only needed to rebuild the G4 visualisation and interfaces parts related to X11 and OpenGL, but as I don’t know how to specify “only” that with cmake, I prefer to rebuild everything.

Cheers. Guy