After installing FMX and using it for a while I started getting a weird “ld.exe cannot find shlwapi.dll” message. There was nothing like this to be found on the internet! I posted a question of StackOverflow but people started to point in (as later turned out to be) totally wrong directions.
The complete error msg is shown below and happens only when I 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)
In the list (Module, bottom-left) ShlWApi appears in 4 places:
- API-MS-WIN-CORE-SHLWAPI-LEGACY-L1-1-0.DLL
- API-MS-WIN-CORE-SHLWAPI-OBSOLETE-L1-1-0.DLL
- API-MS-WIN-SHLWAPI-IE-L1-1-0.DLL
- API-MS-WIN-SHLWAPI-WINRT-STORAGE-L1-1-1.DLL
- EXT-MS-WIN-SHELL-SHLWAPI-L1-1-0.DLL
Tests:
- My device can connect to the PC (transfer files) and it is seen by my IDE.
- The Java path is ok.
- I reinstalled the SDK and also the NDK.
shlwapi.dll
is found inC:\Windows\System32\
andC:\Windows\SysWOW64\
.
Investigation
Update 1:
After reinstalling the whole SDK/DNK and Delphi, it turned out to be a package that was required by my application. If I remove that package, the program compiles fine.
I guess: welcome to the cryptic world of Linux/Android/C++.
The problem is still there in that package. I haven’t figured out what it is. But at least I know it is not in the main program.
Update 2:
I am investigating to see if this is related to the SDK or the Delphi compiler is buggy. At this point the experiments show that the compilation works until I add one of my files (LightSaber\ccCore.pas) to the project. I see the error as soon as I add that file. If I delete all routines from that file, it compiles. So the compiler does not like one of the routines. I dedicated one article on my website to this investigation.
Update 3:
Fixed! The error was in a file called by the DPR project. The error msg was one of those “Error somewhere” errors you encounter in the C/++ world. Could have been fixed in seconds with a proper error message from the DSK framework. Obviously C++/Android is not as good as Delphi at generating error messages.
That file contained a call to a MS API function:
function StrCmpLogicalW(psz1, psz2: PWideChar): Integer; stdcall; external 'shlwapi.dll';
What is strange is that compiling that file ALONE works. Only when you add it to your project you encounter the problem (when the linker actually tries to link it you the exe file).