gpt4 book ai didi

Android NDK cmake 编译程序集(*.s) 文件

转载 作者:行者123 更新时间:2023-12-01 20:17:32 32 4
gpt4 key购买 nike

我正在使用带有 cmake 和 Android NDK 的 Android Studio 2.2.2。我有一个库,其中包含我为项目编译的多个 .s(汇编程序)文件。

直到 cmake,当我使用 Android.mk 文件时,我编译/链接了这些文件,没有任何问题,而在 cmake 上出现编译器错误,例如:

lib\arm_android\armfrag.s:1:2: error: unexpected token at start of statement @******************************************************************** ^ libs\arm_android\armfrag.s:2:2: error: unexpected token at start of statement @* * ^

armfrag 文件包含在顶部评论如下:

@******************************************************************** @* * @* THIS FILE IS ...................................................................................

我认为我的 cmake 无法读取这个程序集文件,但注释并不是唯一的问题,因为我删除了注释,但仍然收到错误。

我的 cmake 看起来像这样:

cmake_minimum_required(VERSION 3.4.1)

set(CMAKE_VERBOSE_MAKEFILE on)

set(can_use_assembler TRUE)
enable_language(ASM)

add_definitions(-DANDROID -DNDEBUG -DOC_ARM_ASM)

add_library(omnitus STATIC
../../../../libs/lib/arm_android/armbits.s
../../../../libs/lib/arm_android/armfrag.s
../../../../libs/lib/arm_android/armidct.s
../../../../libs/lib/arm_android/armloop.s
../../../../libs/lib/arm/armopts-gnu.s
)

target_include_directories(omnitus PUBLIC
../../../../libs/include
)

target_include_directories(omnitus PUBLIC
../../../../libs/lib/arm
)

target_include_directories(omnitus PUBLIC
../../../../libs/include
)

有人知道为什么 cmake 和旧 Android.mk 文件会失败吗?

干杯

* 已添加 *

使用详细信息,我会得到相同的错误,但除此之外:

Android clang version 3.8.256229  (based on LLVM 3.8.256229)
Target: x86_64-unknown-linux
Thread model: posix
InstalledDir: C:\Android\sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin
clang.exe: warning: argument unused during compilation: '-D ANDROID'
clang.exe: warning: argument unused during compilation: '-D ARM'
clang.exe: warning: argument unused during compilation: '-D NDEBUG'
clang.exe: warning: argument unused during compilation: '-D OC_ARM_ASM'
clang.exe: warning: argument unused during compilation: '-MD'
clang.exe: warning: argument unused during compilation: '-MT CMakeFiles/omnitus.dir/lib/arm/armopts-gnu.s.o'
clang.exe: warning: argument unused during compilation: '-MF CMakeFiles\omnitus.dir\lib\arm\armopts-gnu.s.o.d'

* 添加了修改后的 cmake 文件 *

cmake_minimum_required(VERSION 3.4.1)

set(CMAKE_VERBOSE_MAKEFILE on)

set(can_use_assembler TRUE)
enable_language(ASM)

add_definitions(-v -DANDROID -DNDEBUG -DOC_ARM_ASM)

if(CMAKE_SYSTEM_PROCESSOR STREQUAL armv7-a)
set(TEST_SOURCES ../../../../libs/lib/arm_android/armbits.s
../../../../libs/arm_android/armfrag.s
../../../../libs/arm_android/armidct.s
../../../../libs/arm_android/armloop.s
../../../../libs/lib/arm/armopts-gnu.s
)
endif()

add_library(omnitus STATIC ${TEST_SOURCES}
)

target_include_directories(omnitus PUBLIC
../../../../libs/include
)

target_include_directories(omnitus PUBLIC
../../../../libs/arm
)

target_include_directories(omnitus PUBLIC
../../../../libs/include
)

最佳答案

到目前为止,对于 ARMv7 和 ARMv8 架构,您必须以内联汇编样式在 C 源文件中编写汇编代码。

Android Studio 刚刚添加了适用于 x86 和 x86-64 架构的 YASM 汇编器。

关于Android NDK cmake 编译程序集(*.s) 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40507236/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com