Repository: flxzt/rnote (language: rust)

Issue:
Broken dynamic library link in windows
**Describe the bug**  
When I run the app on Windows using its shortcut, a pop-up titled “Entry Point Not Found” shows up, and it states the following: 

> The procedure entry point _ZN3egl10CreateSyncEP¨PvjPKx could not be located in the dynamic link library C:\Program Files\Neovim\bin\libEGL.dll.

The application opens app and functions, but I didn't work with that much to know the implications of the error.

Oddly enough, the error doesn't occur when I launch the app using PowerShell while been in the bin folder of the app.

**To Reproduce**  
Steps to reproduce the behavior:
1. Install the app
2. Open it using its shortcut
3. The error pop-up shows up

**Expected behavior**  
The app should open normally with the linking error pop-up.

**Screenshots**  

![scr](https://github.com/flxzt/rnote/assets/62522484/9564b7cc-a621-4ab3-be4a-cf69a56e1bf3)

**Desktop (please complete the following information):**  
 - OS: Windows 10 LTSC 1809
 - App Version: Rnote v0.9.0
 - Installation Source: GitHub releases 




Discussion / hints:
Cannot reproduce on Windows 10 22H2.

I have no clue how Neovim is in this error message, there is no relation between that and Rnote. I take it that you do have Neovim installed on this machine? Somehow that seems to interfere with other programs.

_Rnote itself does not even come with `libEGL.dll`, interesting that it tries to open it._
This looks like a bug in libepoxy and/or the packaging of Rnote. The dynamic library loading system in Windows is very old and has some behaviors that are often undesirable but are probably necessary for some old software. If you call `LoadLibrary` or if your code depends on a library, and that library is not part of your application or Windows, eventually the library loader will start looking places you don't want it to look, including every directory in the regular executable `PATH` variable because there is no separate library path variable.

If you install something like Neovim and want to launch `nvim` from your command line, you add it to your `PATH` variable. However, this has the side effect of adding all of Neovim's DLLs to the library path of other applications like Rnote as well.

Because Rnote depends on libEGL.dll (via libepoxy.dll), but doesn't include it, and Neovim includes something else with the same name (it's part of QT?), and libepoxy doesn't follow the [guidelines for secure DLL loading](https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-security), Rnote ends up loading whatever libEGL.dll file the user might have on their system, and this one is not compatible.

This might only affect users with certain graphics card vendors.
Thank you, that clears things up. [This](https://github.com/flxzt/rnote/blob/5058f7e7cc2fa0e91a8fa1eb57b2b185a737a1c8/build-aux/inno_build.py#L48C50-L48C50) is the line where the app dll's are collected, which does not work for `libEGL.dll`
> Because Rnote depends on libEGL.dll (via libepoxy.dll), but doesn't include it

I couldn't reproduce the problem on my Windows laptop, does that mean that somewhere on this system, by means of pure luck, there is a compatible `libEGL.dll` which is getting picked up?

Fix patch:
diff --git a/.github/workflows/release-windows.yml b/.github/workflows/release-windows.yml
index 9500f9236e..4fd0009f9d 100644
--- a/.github/workflows/release-windows.yml
+++ b/.github/workflows/release-windows.yml
@@ -27,7 +27,7 @@ jobs:
             git mingw-w64-x86_64-xz mingw-w64-x86_64-pkgconf mingw-w64-x86_64-gcc mingw-w64-x86_64-clang mingw-w64-x86_64-toolchain
             mingw-w64-x86_64-autotools mingw-w64-x86_64-make mingw-w64-x86_64-cmake mingw-w64-x86_64-meson mingw-w64-x86_64-diffutils
             mingw-w64-x86_64-desktop-file-utils mingw-w64-x86_64-appstream-glib mingw-w64-x86_64-gtk4 mingw-w64-x86_64-libadwaita
-            mingw-w64-x86_64-poppler mingw-w64-x86_64-poppler-data
+            mingw-w64-x86_64-poppler mingw-w64-x86_64-poppler-data mingw-w64-x86_64-angleproject
       - name: Remove libpthread.dll.a
         run: rm /mingw64/lib/libpthread.dll.a
         continue-on-error: true
diff --git a/build-aux/inno_build.py b/build-aux/inno_build.py
index bdb99936d5..370ffc2ac7 100644
--- a/build-aux/inno_build.py
+++ b/build-aux/inno_build.py
@@ -4,6 +4,7 @@
 import os
 import shutil
 import glob
+import itertools
 
 source_root = sys.argv[1]
 build_root = sys.argv[2]
@@ -55,6 +56,15 @@ def run_command(command, error_message):
         f"Collecting pixbuf-loader ({loader}) DLLs failed"
     )
 
+for angle_dll in itertools.chain(
+    glob.glob(f"{msys_path}/mingw64/bin/libEGL*.dll"),
+    glob.glob(f"{msys_path}/mingw64/bin/libGLES*.dll"),
+):
+    run_command(
+        f"ldd {angle_dll} | grep '\\/mingw.*\.dll' -o | xargs -i cp {{}} {dlls_dir}",
+        f"Collecting angle ({angle_dll}) DLLs failed",
+    )
+
 # Collect necessary GSchema Xml's and compile them into a `gschemas.compiled`
 print("Collecting and compiling GSchemas...", file=sys.stderr)
 gschemas_dir = os.path.join(build_root, "gschemas")
diff --git a/misc/building/rnote-windows-build.md b/misc/building/rnote-windows-build.md
index 1741f8da0f..2ae0a61003 100644
--- a/misc/building/rnote-windows-build.md
+++ b/misc/building/rnote-windows-build.md
@@ -15,7 +15,7 @@ The MSYS2 binary directories, namely `C:\msys64\mingw64\bin` and `C:\msys64\usr\
 In order to install the necessary dependencies, run the following command in a MSYS2 terminal.
 
 ```bash
-pacman -S git mingw-w64-x86_64-xz mingw-w64-x86_64-pkgconf mingw-w64-x86_64-gcc mingw-w64-x86_64-clang mingw-w64-x86_64-toolchain mingw-w64-x86_64-autotools mingw-w64-x86_64-make mingw-w64-x86_64-cmake mingw-w64-x86_64-meson mingw-w64-x86_64-diffutils mingw-w64-x86_64-desktop-file-utils mingw-w64-x86_64-appstream-glib mingw-w64-x86_64-gtk4 mingw-w64-x86_64-libadwaita mingw-w64-x86_64-poppler mingw-w64-x86_64-poppler-data
+pacman -S git mingw-w64-x86_64-xz mingw-w64-x86_64-pkgconf mingw-w64-x86_64-gcc mingw-w64-x86_64-clang mingw-w64-x86_64-toolchain mingw-w64-x86_64-autotools mingw-w64-x86_64-make mingw-w64-x86_64-cmake mingw-w64-x86_64-meson mingw-w64-x86_64-diffutils mingw-w64-x86_64-desktop-file-utils mingw-w64-x86_64-appstream-glib mingw-w64-x86_64-gtk4 mingw-w64-x86_64-libadwaita mingw-w64-x86_64-poppler mingw-w64-x86_64-poppler-data mingw-w64-x86_64-angleproject
 ```
 
 ### Configuration


Test patch: