romigrou / ssim

Fast and portable SSIM implementation
zlib License
40 stars 12 forks source link

I want to build ARM64 version to use it on android, however build failed, how to fix this? #9

Open dvdface opened 5 months ago

dvdface commented 5 months ago

D:\Users\80362386\Desktop\ssim-master>GenerateSolution.cmd Which version of Visual Studio do you want to generate a solution for? 1- Visual Studio 12 (2013) 2- Visual Studio 14 (2015) 3- Visual Studio 15 (2017) 4- Visual Studio 16 (2019) 5- Visual Studio 17 (2022) 5

Which platform to you want to generate for? 1- x86 2- AMD64 3- x86 (Clang) 4- AMD64 (Clang) 5- ARM 6- ARM64 6

Calling CMake as follows: "cmake" -G "Visual Studio 17 2022" -DRMGR_SSIM_BUILD_CLI=ON -DRMGR_SSIM_BUILD_SAMPLE=ON -DRMGR_SSIM_BUILD_TESTS=ON -A ARM64 "-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY:PATH=D:\Users\80362386\Desktop\ssim-master\lib\windows-aarch64-msvc19.3-vs2022" "-DCMAKE_LIBRARY_OUTPUT_DIRECTORY:PATH=D:\Users\80362386\Desktop\ssim-master\bin\windows-aarch64-msvc19.3-vs2022" "-DCMAKE_RUNTIME_OUTPUT_DIRECTORY:PATH=D:\Users\80362386\Desktop\ssim-master\bin\windows-aarch64-msvc19.3-vs2022" "-DCMAKE_INSTALL_PREFIX:PATH=D:\Users\80362386\Desktop\ssim-master\package\windows-aarch64-msvc19.3" "-DCPACK_PACKAGE_DIRECTORY:PATH=D:\Users\80362386\Desktop\ssim-master\package" "-DCPACK_SYSTEM_NAME:STRING=windows-aarch64-msvc19.3" "D:\Users\80362386\Desktop\ssim-master"

CMake Error: Error: generator platform: ARM64 Does not match the platform used previously: Either remove the CMakeCache.txt file and CMakeFiles directory or choose a different binary directory. 请按任意键继续. . .

D:\Users\80362386\Desktop\ssim-master>GenerateSolution.cmd Which version of Visual Studio do you want to generate a solution for? 1- Visual Studio 12 (2013) 2- Visual Studio 14 (2015) 3- Visual Studio 15 (2017) 4- Visual Studio 16 (2019) 5- Visual Studio 17 (2022) 5

Which platform to you want to generate for? 1- x86 2- AMD64 3- x86 (Clang) 4- AMD64 (Clang) 5- ARM 6- ARM64 6

Calling CMake as follows: "cmake" -G "Visual Studio 17 2022" -DRMGR_SSIM_BUILD_CLI=ON -DRMGR_SSIM_BUILD_SAMPLE=ON -DRMGR_SSIM_BUILD_TESTS=ON -A ARM64 "-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY:PATH=D:\Users\80362386\Desktop\ssim-master\lib\windows-aarch64-msvc19.3-vs2022" "-DCMAKE_LIBRARY_OUTPUT_DIRECTORY:PATH=D:\Users\80362386\Desktop\ssim-master\bin\windows-aarch64-msvc19.3-vs2022" "-DCMAKE_RUNTIME_OUTPUT_DIRECTORY:PATH=D:\Users\80362386\Desktop\ssim-master\bin\windows-aarch64-msvc19.3-vs2022" "-DCMAKE_INSTALL_PREFIX:PATH=D:\Users\80362386\Desktop\ssim-master\package\windows-aarch64-msvc19.3" "-DCPACK_PACKAGE_DIRECTORY:PATH=D:\Users\80362386\Desktop\ssim-master\package" "-DCPACK_SYSTEM_NAME:STRING=windows-aarch64-msvc19.3" "D:\Users\80362386\Desktop\ssim-master"

CMake Error at CMakeLists.txt:26 (project): Failed to run MSBuild command:

C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/MSBuild/Current/Bin/amd64/MSBuild.exe

to get the value of VCTargetsPath:

适用于 .NET Framework MSBuild 版本 17.7.2+d6990bcfa
生成启动时间为 2024/5/21 19:12:07。

节点 1 上的项目“D:\Users\80362386\Desktop\ssim-master\build\windows-aarch64-msvc19.3-vs2022\CMakeFiles\3.26.4-msvc4\VCTargetsPath.vcxproj”(默认目标)。
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(832,5): error : The BaseOutputPath/OutputPath property is not set for project 'VCTargetsPath.vcxproj'.  Please check to make sure that you have specified a valid combination of Configuration and Platform for this project.  Configuration='Debug'  Platform='ARM64'.  You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn't exist for this project. [D:\Users\80362386\Desktop\ssim-master\build\windows-aarch64-msvc19.3-vs2022\CMakeFiles\3.26.4-msvc4\VCTargetsPath.vcxproj]
已完成生成项目“D:\Users\80362386\Desktop\ssim-master\build\windows-aarch64-msvc19.3-vs2022\CMakeFiles\3.26.4-msvc4\VCTargetsPath.vcxproj”(默认目标)的操作 - 失败。

生成失败。

“D:\Users\80362386\Desktop\ssim-master\build\windows-aarch64-msvc19.3-vs2022\CMakeFiles\3.26.4-msvc4\VCTargetsPath.vcxproj”(默认目标) (1) ->
(_CheckForInvalidConfigurationAndPlatform 目标) ->
  C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(832,5): error : The BaseOutputPath/OutputPath property is not set for project 'VCTargetsPath.vcxproj'.  Please check to make sure that you have specified a valid combination of Configuration and Platform for this project.  Configuration='Debug'  Platform='ARM64'.  You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn't exist for this project. [D:\Users\80362386\Desktop\ssim-master\build\windows-aarch64-msvc19.3-vs2022\CMakeFiles\3.26.4-msvc4\VCTargetsPath.vcxproj]

    0 个警告
    1 个错误

已用时间 00:00:00.11

Exit code: 1

-- Configuring incomplete, errors occurred!

dvdface commented 5 months ago

I have built this binary , the linker it used is not correct, how to fix it? OP5601:/data/local/tmp # file rmgr-ssim rmgr-ssim: ELF shared object, 64-bit LSB arm64, dynamic (/lib/ld-linux-aarch64.so.1), BuildID=61161c20e0b0fac068e2b49eca46da3e986d034a, not stripped

dvdface commented 5 months ago

Okay, After check the source code detailly, I found it's very easy to write a Android.mk to build it instead of using default CMake Configuration.

how to build for android by android-ndk

  1. create a Android.mk in project root dir, have following content
    
    LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS) LOCAL_MODULE := ssim LOCAL_C_INCLUDES := $(LOCAL_PATH)/include/ LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/src/.cpp) (wildcard $(LOCAL_PATH)/src/.h) include $(BUILD_EXECUTABLE)


2. run ndk-build command in the project root directory to build project

ndk-build APP_BUILD_SCRIPT=Android.mk NDK_PROJECT_PATH=.



3. artifacts are under following directory
```<project root>/libs/```
dvdface commented 5 months ago

I have built this binary , the linker it used is not correct, how to fix it? OP5601:/data/local/tmp # file rmgr-ssim rmgr-ssim: ELF shared object, 64-bit LSB arm64, dynamic (/lib/ld-linux-aarch64.so.1), BuildID=61161c20e0b0fac068e2b49eca46da3e986d034a, not stripped

After I fixed the linker problem, it still has problem, so I give it up.