【Delphi】RAD 10.4 开发Android时如何在迁移SDK和NDK路径后解决提示 ld: cannot find -lxxx的问题
今天使用lite版本安装了RAD Delphi10.4,发现自动把Android的SDK和NDK目录安装到C盘下,由于C盘容量紧张,所以想把目录迁移到其他路径!
在之前的版本是直接移动目录,在到delphi的tools-options菜单页面中修改SDK路径即可。
但是这次修改后发现在link时仍然找不到路径,查看了delphi的编译命令行信息,发现其中 usr\lib 路径仍然是C盘的,如下:
dccaarm command line for "Project1.dpr" f:\program_files\embarcadero\studio\21.0\bin\dccaarm.exe -$O- --no-config -B -Q -TX.so -AGenerics.Collections=System.Generics.Collections; Generics.Defaults=System.Generics.Defaults -DDEBUG -E.\Android\Debug -If:\program_files\embarcadero\studio\21.0\lib\Android\debug; f:\program_files\embarcadero\studio\21.0\lib\Android\Release -LEC:\Users\Public\Documents\Embarcadero\Studio\21.0\Bpl\Android -LNC:\Users\Public\Documents\Embarcadero\Studio\21.0\Dcp\Android -NU.\Android\Debug -NSSystem;Xml;Data;Datasnap;Web;Soap; -Of:\program_files\embarcadero\studio\21.0\lib\Android\Release -Rf:\program_files\embarcadero\studio\21.0\lib\Android\Release -Uf:\program_files\embarcadero\studio\21.0\lib\Android\debug;f:\program_files\embarcadero\studio\21.0\lib\Android\Release --libpath:C:\Users\Public\Documents\Embarcadero\Studio\21.0\PlatformSDKs\android-ndk-r21\sources\cxx-stl\llvm-libc++\libs\armeabi-v7a; C:\Users\Public\Documents\Embarcadero\Studio\21.0\PlatformSDKs\android-ndk-r21\platforms\android-23\arch-arm\usr\lib --linker:F:\Program_Files\Embarcadero\Studio\21.0\PlatformSDKs\android-ndk-r21\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ld.exe -V -VN -NO.\Android\Debug Project1.dpr
再次检查sdk路径,发现并无错误,猜测可能是delphi的bug,估计是漏掉了NDK library Path,页面中仅有C++ Builder的NDK library Path设置项(难道是lite版本裁剪后导致的?)。
好在发现delphi提供了设置项的export和import功能,因此,我先使用export导出设置文件,内容如下:
<?xml version="1.0" encoding="utf-8"?> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets=""> <PropertyGroup> <Profile_platform>Android64</Profile_platform> <Profile_host>localhost</Profile_host> <Profile_port>64211</Profile_port> <Profile_sdkname>AndroidSDK25.2.5_64bit.sdk</Profile_sdkname> <Profile_displayname>Android SDK 25.2.5 64-bit</Profile_displayname> <Profile_version>25.2.5</Profile_version> <Profile_sysroot>F:\Program_Files\Embarcadero\Studio\21.0\PlatformSDKs\android-sdk-windows</Profile_sysroot> <NDKArmLinuxAndroidFile>F:\Program_Files\Embarcadero\Studio\21.0\PlatformSDKs\android-ndk-r21\toolchains\aarch64-linux-android-4.9\prebuilt\windows-x86_64\aarch64-linux-android\bin\ld.exe</NDKArmLinuxAndroidFile> <NDKArmLinuxAndroidStripFile>F:\Program_Files\Embarcadero\Studio\21.0\PlatformSDKs\android-ndk-r21\toolchains\aarch64-linux-android-4.9\prebuilt\windows-x86_64\aarch64-linux-android\bin\strip.exe</NDKArmLinuxAndroidStripFile> <NDKApiPath>F:\Program_Files\Embarcadero\Studio\21.0\PlatformSDKs\android-ndk-r21\platforms\android-23</NDKApiPath> <NDKBasePath>F:\Program_Files\Embarcadero\Studio\21.0\PlatformSDKs\android-ndk-r21</NDKBasePath> <NDKGdbServerPath>F:\Program_Files\Embarcadero\Studio\21.0\PlatformSDKs\android-ndk-r21\prebuilt\android-arm64\gdbserver\gdbserver</NDKGdbServerPath> <SDKZipAlignPath>F:\Program_Files\Embarcadero\Studio\21.0\PlatformSDKs\android-sdk-windows\build-tools\29.0.3\ZipAlign.exe</SDKZipAlignPath> <SDKAndroidPath>F:\Program_Files\Embarcadero\Studio\21.0\PlatformSDKs\android-sdk-windows\tools\Android.bat</SDKAndroidPath> <SDKAdbPath>F:\Program_Files\Embarcadero\Studio\21.0\PlatformSDKs\android-sdk-windows\platform-tools\Adb.exe</SDKAdbPath> <SDKAaptPath>F:\Program_Files\Embarcadero\Studio\21.0\PlatformSDKs\android-sdk-windows\build-tools\29.0.3\Aapt.exe</SDKAaptPath> <SDKApiLevelPath>F:\Program_Files\Embarcadero\Studio\21.0\PlatformSDKs\android-sdk-windows\platforms\android-29\android.jar</SDKApiLevelPath> <JDKPath>C:\Program Files (x86)\Java\jdk1.8.0_112</JDKPath> <JDKJarsignerPath>C:\Program Files (x86)\Java\jdk1.8.0_112\bin\JarSigner.exe</JDKJarsignerPath> <JDKKeyToolPath>C:\Program Files (x86)\Java\jdk1.8.0_112\bin\KeyTool.exe</JDKKeyToolPath> <DelphiNDKLibraryPath>C:\Users\Public\Documents\Embarcadero\Studio\21.0\PlatformSDKs\android-ndk-r21\sources\cxx-stl\llvm-libc++\libs\arm64-v8a;C:\Users\Public\Documents\Embarcadero\Studio\21.0\PlatformSDKs\android-ndk-r21\platforms\android-23\arch-arm64\usr\lib</DelphiNDKLibraryPath> <CBuilderNDKLibraryPath>F:\Program_Files\Embarcadero\Studio\21.0\PlatformSDKs\android-ndk-r21\platforms\android-23\arch-arm64\usr\lib</CBuilderNDKLibraryPath> <Profile_password>xxxxxxxx</Profile_password> </PropertyGroup> </Project>
注意其中的<DelphiNDKLibraryPath>仍然指向未迁移前的C盘路径,因此将该路径修改后,再重新使用import功能导入设置即可。