vrolife / mypower

GNU General Public License v3.0
58 stars 28 forks source link

大佬这个怎么编译成安卓应用啊? #3

Closed duckpc closed 7 months ago

duckpc commented 7 months ago

没有写详细的方法,linux版本的编译成功了,但是怎么编译安卓版本的啊,我在win10中通过wls搭建了Ubuntu20系统,下载了ndk。 set(NDK_PATH /mnt/d/Android/Sdk/ndk/linux24/) ##################### Android设置 ##################### set(CMAKE_SYSTEM_NAME ANDROID) # 设置目标编译平台参数 Android set(ANDROID_NDK ${NDK_PATH}) # 设置ndk路径 set(CMAKE_TOOLCHAIN_FILE ${NDK_PATH}/build/cmake/android.toolchain.cmake) ##################### Android设置这里是添加的安卓编译 其他的没有变化##################### project(mypower) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_C_STANDARD 11)

if(NOT ANDROID_PLATFORM) find_package(OpenMP) endif()

include(${CMAKE_CURRENT_LIST_DIR}/cmake/scan_test.cmake)

add_subdirectory(external) add_subdirectory(examples) add_subdirectory(src) add_subdirectory(tui)

add_subdirectory(tests)

通过cmake进行编译他报 -- ANDROID_PLATFORM not set. Defaulting to minimum supported version 19. -- Android: Targeting API '19' with architecture 'arm', ABI 'armeabi-v7a', and processor 'armv7-a' -- Android: Selected unified Clang toolchain -- The C compiler identification is unknown -- The CXX compiler identification is unknown -- Detecting C compiler ABI info -- Detecting C compiler ABI info - failed -- Check for working C compiler: /mnt/d/Android/Sdk/ndk/linux24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -- Check for working C compiler: /mnt/d/Android/Sdk/ndk/linux24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang - brokenCMake Error at /usr/share/cmake-3.22/Modules/CMakeTestCCompiler.cmake:69 (message): The C compiler

"/mnt/d/Android/Sdk/ndk/linux24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: /home/kali/qiling/mypower-master/buildA/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_e7d61/fast && /usr/bin/gmake  -f CMakeFiles/cmTC_e7d61.dir/build.make CMakeFiles/cmTC_e7d61.dir/build
gmake[1]: Entering directory '/home/kali/qiling/mypower-master/buildA/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_e7d61.dir/testCCompiler.c.o
/mnt/d/Android/Sdk/ndk/linux24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang    -o CMakeFiles/cmTC_e7d61.dir/testCCompiler.c.o -c /home/kali/qiling/mypower-master/buildA/CMakeFiles/CMakeTmp/testCCompiler.c
clang: error: no input files
gmake[1]: *** [CMakeFiles/cmTC_e7d61.dir/build.make:78: CMakeFiles/cmTC_e7d61.dir/testCCompiler.c.o] Error 1
gmake[1]: Leaving directory '/home/kali/qiling/mypower-master/buildA/CMakeFiles/CMakeTmp'
gmake: *** [Makefile:127: cmTC_e7d61/fast] Error 2
这个错误。通过Windows下的clion编译 无法运行configure 这个命令。大佬救命啊
vrolife commented 7 months ago

先设置环境变量ANDROID_NDK_HOME, 然后用CMakePresets.json里的dev-arm64来编译.

duckpc commented 7 months ago

大佬ndk用的那个版本的我下载的ndk不能用啊 Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_7805e/fast && /usr/bin/gmake -f CMakeFiles/cmTC_7805e.dir/build.make CMakeFiles/cmTC_7805e.dir/build gmake[1]: Entering directory '/mnt/d/qiling/mytest/mypower/cmake-build-dev-arm64/CMakeFiles/CMakeTmp' Building C object CMakeFiles/cmTC_7805e.dir/testCCompiler.c.o /mnt/d/Android/Sdk/ndk/linux24/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -o CMakeFiles/cmTC_7805e.dir/testCCompiler.c.o -c /mnt/d/qiling/mytest/mypower/cmake-build-dev-arm64/CMakeFiles/CMakeTmp/testCCompiler.c clang: error: no input files gmake[1]: [CMakeFiles/cmTC_7805e.dir/build.make:78: CMakeFiles/cmTC_7805e.dir/testCCompiler.c.o] Error 1 gmake[1]: Leaving directory '/mnt/d/qiling/mytest/mypower/cmake-build-dev-arm64/CMakeFiles/CMakeTmp' gmake: [Makefile:127: cmTC_7805e/fast] Error 2 这个是我的报错

vrolife commented 7 months ago

我的NDK是25.1.8937393 构建过程还要依赖一个python模块playlang, 在这里https://github.com/vrolife/playlang cmake -S . -B out/x --preset dev-arm64 cmake --build out/x -j

vrolife commented 7 months ago

我的系统是debian 12

duckpc commented 7 months ago

ndkVersion "25.2.9519653" 我用的是window的wsl Ubuntu20系统。 cmake -S . -B out/x --preset dev-arm64 老是报 clang: error: no input files ndk24-26的版本都报clang错误。playlang这个模块也安装了没有问题。ndk官网没有找到25.1的版本啊。

duckpc commented 7 months ago

卧槽 就是ndk版本的问题我下来一个20的版本就能用,考用了我3天时间。。疯了

vrolife commented 7 months ago

我换过ndk版本, 都没问题,可能还是环境的问题, 或者cmake版本问题. 这程序是在debian12 + kde下开发的, 倒是没试过别的环境.