Error running example B1: qt.qpa.xcb: could not connect to display

Hi, all.
I am new to Geant4 and Ubuntu. I attempted to install and compile Geant4-v11.1.2 on Ubuntu 20.04.3 installed under WSL1 of Windows 10. The installation and compiling went well but error occured when running example B1. Part of the output is as follows:

loaded library "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so"
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: dxcb, eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.

Aborted (core dumped)

Specific steps in my installation are listed as follows, referring to a tutorial on the Internet.
First, I downloaded the Geant4 package and moved it to the geant4 directory.

cp $HOME/Downloads/geant4-v11.1.2.tar.gz $HOME/geant4
tar -xzvf geant4-v11.1.2.tar.gz

Then, preparation for installing Geant4 is performed by following codes under $HOME/geant4/.

mkdir geant4-build && cd geant4-build
sudo apt-get install qt4* cmake libx11-dev libxext-dev libxtst-dev libxrender-dev libxmu-dev  libxmuu-dev libhdf5-serial-dev hdf5-tools
sudo apt-get install -y libexpat1 libexpat1-dev
sudo apt install qt5*

Then I created geant4-install directory under $HOME/geant4, and then executed following codes under $HOME/geant4/geant4-build/.

sudo cmake  -DCMAKE_INSTALL_PREFIX=$HOME/geant4/geant4-install  -DGEANT4_USE_OPENGL_X11=ON -DGEANT4_USE_RAYTRACER_X11=ON -DGEANT4_USE_QT=ON GEANT4_BUILD_MULTITHREADED=ON $HOME/geant4/geant4-v11.1.2
sudo make -j8
sudo make install -j8
cd $HOME/geant4/geant4-install/bin
source geant4.sh

I downloaded all 12 data packages on Windows and moved them to $HOME/geant4/geant4-install/share/Geant4/data, then unziped them and deleted the zip packages.

sudo cp *.tar.gz $HOME/geant4/geant4-install/share/Geant4/data
cd $HOME/geant4/geant4-install/share/Geant4/data
sudo ls *.tar.gz | sudo xargs -n1 tar xzvf
sudo rm *.tar.gz

Then I added the path of Geant4 to .bashrc file.

source  ~/geant4/geant4-install/bin/geant4.sh
source  ~/geant4/geant4-install/share/Geant4/geant4make/geant4make.sh
source  ~/.bashrc

Example B1 is performed with the following codes. The error occured after executing command “./exampleB1”.

cd $HOME/geant4/geant4.v11.1.2/examples/basic/B1
mkdir build&&cd  build
source ~/.bashrc
cmake ../
make -j8
./exampleB1

Post the error message again.

loaded library "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so"
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: dxcb, eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.

Aborted (core dumped)

I really need your help. Considering I am brand new to both Geant4 and Linux Command, some direct guidance on operating would be useful for me. If any additional information is required, I will provide it as soon as I see it. Any help will be appriciated.

Sincerely yours,
Luca

_Geant4 Version:_v11.1.2
_Operating System:_Ubuntu 20.04.3 on Windows 10
_CMake Version:_3.16.3


Dear @luca29q ,

this is by no means THE answer to your question but it very much looks similar to the error I found when setting up a Geant4 Apptainer container (formerly singularity).

The way to fix the container is to tweak the Qt library. MIND YOU THAT YOU WILL BE ALTERING THE FULL WSL ENVIRONMENT.

[ -f /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 ] && strip --remove-section=.note.ABI-tag /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
# if your case maybe you need to "sudo"

explnanation: If you find the file, fix it :wink:
Note that I wrecklessly use that because it is altering a container and not my system. Please use this at your own risk.

Cheers,

/Pico

Thank you very much @pico , I tried to fix the file as you suggested but failed. The output is as follows. I used “sudo” to execute the code.

strip: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: could not create temporary file to hold stripped copy: cause of error unknown

I did a search on the Internet and only found a post with an error on CentOS describing the same as mine, but no reply under his post. And I thought I had enough disk space, like this:

:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
rootfs          276G  171G  105G  63% /
none            276G  171G  105G  63% /dev
none            276G  171G  105G  63% /run
none            276G  171G  105G  63% /run/lock
none            276G  171G  105G  63% /run/shm
none            276G  171G  105G  63% /run/user
tmpfs           276G  171G  105G  63% /sys/fs/cgroup
C:\             276G  171G  105G  63% /mnt/c
D:\             201G  105G   97G  52% /mnt/d

Now I am really confused. I really need your further guidance on the solution of my problem. Thank you again for your time :pray:

Sorry @luca29q , that was my only shot at it. I am an ArchLinux user and my limited experience with Ubuntu is using containers… maybe someone else in the forum has a better thing for you to try

/Pico

It’s okay @pico , your suggestion is a good attempt at solving my problem, and I really appreciate it. Thank you for your time :smiling_face_with_three_hearts: I will continue to wait for suggestions in the forum.

Hi, all,

I reinstalled qt5 and Geant4 in order, but the same error still occurs when I execute the command ’ ./exampleB1’. My only choice is to reinstall the WSL, trying to fix my problem. Do you have any suggestions? Please let me know. Thanks a lot.

I have installed Geant4 on windows using the ubuntu bash before, and I had to add a line to my .bashrc file. Before running example B1, try typing

DISPLAY=:0

in your bash and then running example B1

Hi, @loydms ,

Thanks a lot. I tried as you suggested but example B1 still cannot connect to display. The first line of the error message is a little different from before, as follows:

qt.qpa.xcb: could not connect to display :0

Never used WSL, but do you have an X server installed on the windows machine?

How to install Geant4 on Windows subsystem for Linux < Mattia Lopresti

Hi @loydms ,

Thanks again. Based on your suggestion and some posts on the Internet, I added the following code to my .bashrc file,

export DISPLAY=192.168.1.102:0.0
export DISPLAY=[HOST]:[DISPLAY NUMBER] # The rule of setting DISPLAY

where the [HOST] is the IPV4 address of my PC, and the [DISPLAY NUMBER] is obtained by hovering over the Xming icon like this:
Xming

Then when executing example B1, the previous problem disappears and a new error occurs:

This plugin does not support propagateSizeHints()
 Changing export format to "jpg"

All output after executing ‘./exampleB1’ is copied to the output.txt file below.
output.txt (71.4 KB)

Hi @php1ic ,

Thank you for your suggestion and sorry for my late reply. I think I have installed X server on windows. I installed Xming if it counts as an X server.

I took a rough look at the website you posted and installed the dependencies and packages listed there. I then recompiled example B1 but executing ‘./exampleB1’ produced the same error as follows:

This plugin does not support propagateSizeHints()
 Changing export format to "jpg"

All output is included in output.txt (71.4 KB). Can you give me further suggestions? Thanks in advance.

My next question would be if you have Xming installed, so I’m glad you have it now.

I think the new error you are getting is due to using Qt. I believe when I ran on Ubuntu on windows I used OpenGl.

In your vis.mac file in the B1 folder, which /vis/open statement is active?

Thank you again @loydms . I take your “active” to mean a statement that is not commented out. The /vis/open statement that is not commented out in the vis.mac file is:

/vis/open OGL 600x600-0+0

The full file is here: vis_mac.txt (4.2 KB)

Were the other dependencies already installed? If you installed additional dependencies, you may need to rebuild geant4 and not just exampleB1.

As suggested on the site, do other Qt based apps launch as expected? e.g. gedit or firefox.

Hi @php1ic ,

Thank you first. I do have installed the Vienna Ab-initio Simulation Package (VASP) and VASPKIT on the WSL1, but I have reinstalled and rebuilt Geant4 a few times and the error remains the same. To use VASPKIT, I added the following line to the ./bashrc file.

export PATH=/mnt/d/VASP_install/Vasp/vaspkit.1.3.0/bin/:$PATH

Does that have anything to do with this issue?

As for other Qt based apps, I have installed gedit. But I cannot use gedit to open a file which can be opened with vim. My command and output look like this:

$ gedit 1.txt
Unable to init server: Could not connect: Connection refused

(gedit:216): Gtk-WARNING **: 14:35:47.932: cannot open display: 192.168.1.102:0.0

Sorry missed that you had responded.

I don’t think that export command is the issue, you are just prepending the VASP directory to the existing PATH variable.

Do you have a static IP address? If not and it has changed, your DISPLAY variable will not be correct. Can you try setting the DISPLAY variable like this:

export DISPLAY=localhost:0.0

Hi @php1ic ,

Thank you first and sorry for my late reply. My IP address does change sometimes so I gave it a try as you suggested. Before this, I have added the following statements to the .bashrc file but they didn’t work.

export QT_DEBUG_PLUGINS=1
export QT_QPA_PLATFORM='offscreen'
export XDG_RUNTIME_DIR=/tmp

Then I added export DISPLAY=localhost:0.0 to the .bashrc file, but the plugin error occured when executing exampleB1 after recompiling.

Considering that I might need to reinstall Geant4 after adding that statement to the .bashrc file, I did so. However, the plugin error occured again even after reinstalling. Thank you as always.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.