You are not logged in.

#1 2023-06-12 17:58:23

Anakievs
Member
Registered: 2023-06-12
Posts: 19

How to fix KiCad w/ nvidia-340 driver (eglCreatePlatformWindowSurface)

The old Nvidia GPUs with nvidia-340 (and possibly nvidia-390) driver don't support EGL. When I run "eeschema" or "pcbnew" it gives this error:

20:55:09: Failed to load shared library '/usr/bin/_eeschema.kiface': /usr/lib/libwx_gtk3u_gl-3.2.so.0: undefined symbol: eglCreatePlatformWindowSurface
20:55:09: Failed to load kiface library '/usr/bin/_eeschema.kiface'.
20:55:09: Error loading editor.

To fix it you have to compile wxWidgets and KiCad without EGL:

1. Download PKGBUILD and apply the patch:

--- original	2023-06-13 17:43:30.649386490 +0300
+++ modified	2023-06-14 10:16:14.117793045 +0300
@@ -18,6 +18,7 @@
     -DCMAKE_BUILD_TYPE=None \
     -DwxBUILD_TOOLKIT=gtk3 \
     -DwxUSE_OPENGL=ON \
+    -DwxUSE_GLCANVAS_EGL=OFF \
     -DwxUSE_REGEX=sys\
     -DwxUSE_ZLIB=sys \
     -DwxUSE_EXPAT=sys \
@@ -30,25 +31,9 @@
     -DwxUSE_GTKPRINT=ON
   cmake --build build-gtk3
 
-  cmake -B build-qt5 -S wxWidgets-$pkgver \
-    -DCMAKE_INSTALL_PREFIX=/usr \
-    -DCMAKE_BUILD_TYPE=None \
-    -DwxBUILD_TOOLKIT=qt \
-    -DwxUSE_OPENGL=ON \
-    -DwxUSE_REGEX=sys \
-    -DwxUSE_ZLIB=sys \
-    -DwxUSE_EXPAT=sys \
-    -DwxUSE_LIBJPEG=sys \
-    -DwxUSE_LIBPNG=sys \
-    -DwxUSE_LIBTIFF=sys \
-    -DwxUSE_LIBLZMA=sys \
-    -DwxUSE_LIBMSPACK=ON \
-    -DwxUSE_PRIVATE_FONTS=ON
-  cmake --build build-qt5
-
 # Run configure to generate the Makefile, cmake doesn't install translations
   cd wxWidgets-$pkgver
-  ./configure --prefix=/usr
+  ./configure --disable-glcanvasegl --prefix=/usr
 }
 
 package_wxwidgets-common() {
@@ -81,18 +66,5 @@
 }
 
 package_wxwidgets-qt5() {
-  pkgdesc='Qt5 implementation of wxWidgets API for GUI'
-  depends=(qt5-base wxwidgets-common libmspack sdl2 libtiff)
-  provides=(wxwidgets)
-
-  DESTDIR="$pkgdir" cmake --install build-qt5
-  rm -r "$pkgdir"/usr/{include,lib/libwx_base*,bin/wxrc*}
-  mv "$pkgdir"/usr/bin/wx-config{,-qt} # Conflicts with wx-gtk3
-# Rename cmake files for coinstallability
-  mv "$pkgdir"/usr/lib/cmake/wxWidgets{,Qt}
-  for _f in "$pkgdir"/usr/lib/cmake/wxWidgetsQt/*; do
-    mv $_f $(dirname $_f)/$(basename $_f | sed -e 's/wxWidgets/wxWidgetsQt/')
-  done
-
-  install -Dm644 wxWidgets-$pkgver/docs/licence.txt "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
+  true
 }

2. Build the source code and install the new packages wxwidgets-common and wxwidgets-gtk3.

3. Download PKGBUILD and the patches. Remove this line from PKGBUILD:

-D KICAD_USE_EGL=ON \

4. Build the source code and install "kicad".

5. Start "pcbnew" if you see this error go to the next step (if not you are done):

Could not use OpenGL, falling back to software rendering
Could not find shader uniform: SMAA_RT_METRICS

6. Delete this folder "$HOME/.config/kicad" (backup if you have something for backup).

7. Start "KiCad" navigate to "Preferences-> Preferences...-> Common-> Antialiasing-> Accelerated Graphics:" and change "Fast Antialiasing" to "No Antialiasing". For me it also works with "High Quality Antialiasing".

If step 7 doesn't work you can read for other possible solutions here.

Notes:
- if you use wxWidgets for something else it will probably brake
- wxwidgets-qt5 is never used so I've removed it for faster compilation
- KiCad compilation is slow and you have to recompile it on update (for old hardware might take more than 5 hours). I've used a different PC with 12 threads at 4.3 GHz and it took 25 minutes.
- you don't have to rebuild "kicad-library" and "kicad-library-3d". Install them from the official repository.

Changelog:
14.06.2023: prevent the patch from failing when "pkgver" or "pkgrel" change

Credits goes to here, here and Lone_Wolf.

More nvidia-340 fixes here:
How to fix vdpau in mpv with the nvidia-340 driver

Last edited by Anakievs (2023-06-14 11:11:07)

Offline

#2 2023-06-13 09:06:21

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 12,945

Re: How to fix KiCad w/ nvidia-340 driver (eglCreatePlatformWindowSurface)

build() {
  cmake -B build-gtk3 -S wxWidgets-$pkgver \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_BUILD_TYPE=None \
    -DwxBUILD_TOOLKIT=gtk3 \
    -DwxUSE_OPENGL=ON \
    -DwxUSE_REGEX=sys\
    -DwxUSE_ZLIB=sys \
    -DwxUSE_EXPAT=sys \
    -DwxUSE_LIBJPEG=sys \
    -DwxUSE_LIBPNG=sys \
    -DwxUSE_LIBTIFF=sys \
    -DwxUSE_LIBLZMA=sys \
    -DwxUSE_LIBMSPACK=ON \
    -DwxUSE_PRIVATE_FONTS=ON \
    -DwxUSE_GTKPRINT=ON
  cmake --build build-gtk3

  cmake -B build-qt5 -S wxWidgets-$pkgver \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_BUILD_TYPE=None \
    -DwxBUILD_TOOLKIT=qt \
    -DwxUSE_OPENGL=ON \
    -DwxUSE_REGEX=sys \
    -DwxUSE_ZLIB=sys \
    -DwxUSE_EXPAT=sys \
    -DwxUSE_LIBJPEG=sys \
    -DwxUSE_LIBPNG=sys \
    -DwxUSE_LIBTIFF=sys \
    -DwxUSE_LIBLZMA=sys \
    -DwxUSE_LIBMSPACK=ON \
    -DwxUSE_PRIVATE_FONTS=ON
  cmake --build build-qt5

# Run configure to generate the Makefile, cmake doesn't install translations
  cd wxWidgets-$pkgver
  ./configure --prefix=/usr
}

It looks like cmake does the brunt of the configuration while ./configure is only used to add translations.
Try disabling GLCANVASEGL through cmake.

Welcome to archlinux forums


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#3 2023-06-13 11:15:00

Anakievs
Member
Registered: 2023-06-12
Posts: 19

Re: How to fix KiCad w/ nvidia-340 driver (eglCreatePlatformWindowSurface)

Thanks! -DwxUSE_GLCANVAS_EGL=OFF fixed the compilation.

Last edited by Anakievs (2023-06-14 11:10:48)

Offline

Board footer

Powered by FluxBB