IceCold
IceCold

Reputation: 21194

Android NDK - ld.exe: cannot find shlwapi.dll

I get this error when I try to compile for Android:

Error E2597 CatalogRepository\AndroidNDK-21-22.0.48361.3236\android-ndk-r21\toolchains\aarch64-linux-android-4.9\prebuilt\windows-x86_64\aarch64-linux-android\bin\ld.exe: cannot find shlwapi.dll: No such file or directory

c:\Delphi\Delphi 11\CatalogRepository\AndroidNDK-21-22.0.7026061\android-ndk-r21\toolchains\aarch64-linux-android-4.9\prebuilt\windows-x86_64\aarch64-linux-android\bin\ld.exe: cannot find -ldl

[DCC Fatal Error] F2588 Linker error code: 1 ($00000001)

enter image description here In the list (Module, bottom-left) ShlWApi appears in 4 places:


It worked yesterday.

What I have changed since then, was to install a USB driver from my phone's manufacturer (OnePlus Nord): OnePlus_USB_Drivers_Setup.exe. It installed C:\Android\adb.exe and more in C:\Program Files\. Uninstalling the program will not delete the C:\Android\ folder.

Seems to be a problem related to paths.


Tests:

Upvotes: 0

Views: 67

Answers (1)

Martin Zeitler
Martin Zeitler

Reputation: 76799

When C:\Windows\System32\SHLWAPI.dll would be really missing, winlogon.exe would fail.
https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/bb776779(v=vs.85)


For comparison:

& "C:\Program Files\Git\git-bash.exe"

ldd ld.exe should look about like this:

.../ndk/21.3.6528147/toolchains/aarch64-linux-android-4.9/prebuilt/windows-x86_64/aarch64-linux-android/bin
$ ldd ld.exe
        ntdll.dll => /c/WINDOWS/SYSTEM32/ntdll.dll (0x7ffc72810000)
        KERNEL32.DLL => /c/WINDOWS/System32/KERNEL32.DLL (0x7ffc71af0000)
        KERNELBASE.dll => /c/WINDOWS/System32/KERNELBASE.dll (0x7ffc70110000)
        apphelp.dll => /c/WINDOWS/SYSTEM32/apphelp.dll (0x7ffc6cee0000)
        ucrtbase.dll => /c/WINDOWS/System32/ucrtbase.dll (0x7ffc70560000)
        USER32.dll => /c/WINDOWS/System32/USER32.dll (0x7ffc70840000)
        win32u.dll => /c/WINDOWS/System32/win32u.dll (0x7ffc70020000)
        GDI32.dll => /c/WINDOWS/System32/GDI32.dll (0x7ffc71ac0000)
        gdi32full.dll => /c/WINDOWS/System32/gdi32full.dll (0x7ffc6feb0000)
        msvcp_win.dll => /c/WINDOWS/System32/msvcp_win.dll (0x7ffc70410000)

SHLWAPI.dll is not even directly linked, but likely through msvcp_win.dll.
Reinstalling the Universal Visual C++ Runtime might fix these mappings.
It might not be the registry, but eg. different versions of msvcp_win.dll.

That OnePlus driver might well have brought it's own Visual C++ Runtime. One can investigate further with ldd msvcp_win.dll, which shows it's linked to msvcrt.dll. Welcome to DLL hell, because this might have been "DLL stomping". Maybe search in C:\Windows\System32 for *.dll, check the timestamps and try to revert an "earlier" (likely newer) version? ldd should also show what doesn't link. Also system-restore images would contain the matching versions of these DLL.

Upvotes: 1

Related Questions