Search code examples
ubuntuqt5windows-subsystem-for-linuxparaviewopenfoam

Unable to run paraFoam in WSL1


I am trying to install OpenFOAM and post process the results in ParaView. While OpenFOAM seems to work and I can run example cases, the paraFoam command results in the following error:

Created temporary: pitzDaily.OpenFOAM

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 initiated. Reinstalling the application may fix this problem. 

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.

I first enabled WSL on my laptop and installed Ubuntu through the Microsoft App Store. I downloaded and installed OpenFoam, as explained in https://openfoam.org/download/10-ubuntu/ I then got to the Getting Started part and tried running the example pitzDaily. Everything worked up to the command paraFoam.

At this point I was getting the following error:

paraview: error while loading shared libraries: libQt5Core.so.5: cannot open shared object file: No such file or directory

I followed the steps explained in paraview: error while loading shared libraries: libQt5Core.so.5: cannot open shared object file: No such file or directory and the error went away, only to be replaced with the error that I wrote at the start of this question.

As far as I understand, there are some issues with ParaView in WSL, but I have never used it and am new to Ubuntu, OpenFoam, etc.

I would appreciate a solution to this error, or alternatively I would be grateful for an way of keeping the temporary pitzDaily.OpenFOAM file, so that I can use that in a Windows version of ParaView. If that means getting around using paraFoam completely, I am very much fine with that.


Solution

  • From the first error message, it seems that you need to install an X server. the X server allows running graphical Linux applications (in this case: Paraview).

    • Download the VcXsrv and install it.

    • Run XLaunch that was installed by VcXsrv (type Xlaunch on the Start menu).

    • Open the "Extra settings" window and: a) Deselect (uncheck) "Native opengl"; b) Select "Disable access control".

    When a bash shell is opened, the DISPLAY environment variable needs to point to the X server that is running. To make this addition permanent, set the DISPLAY in the user's .bashrc file by the following command:

    echo "export DISPLAY=:0" >> $HOME/.bashrc
    
    • Source the .bashrc file (source the $HOME/.bashrc file only once. After that, it'll be automatically loaded each time you open a terminal):
    source $HOME/.bashrc
    
    • Run ParaFoam:
    paraFoam
    

    References: https://openfoam.org/download/windows/