xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
10.15k stars 783 forks source link

android-ndk-26b文件目录变动导致编译结果有误 #4614

Closed WooZoo86 closed 10 months ago

WooZoo86 commented 10 months ago

Xmake 版本

2.8.6

操作系统版本和架构

win11 x64

描述问题

set_config("ndk_cxxstl","c++_static")该设置编译结果还是要依赖libc++_shared.so,xmake -vD输出没有-lc++_static 和-static-libstdc++编译项。 对ndk的stdC++编译设置无效,应该是脚本判断ndk的\sources\cxx-stl文件夹失效,该文件夹在android-ndk-26b有变动,libc++更新。

期待的结果

期待静态链接libc++,实际是动态链接。

工程配置

set_config("ndk_cxxstl","c++_static") set_config("ndk_sdkver","22")

附加信息和错误日志

PS E:\Work\CVFramework> xmake f -p android -a armeabi-v7a -m release --ndk=D:\SDK\android-ndk-r22 --ndk_cxxstl=c++_static checking for Android SDK directory ... no checking for NDK directory ... D:\SDK\android-ndk-r22 checking for SDK version of NDK ... 22 PS E:\Work\CVFramework> xmake -vD checking for the shared library linker (sh) ... clang++ checking for the linker (ld) ... clang++ checking for clang++ ... D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ checking for the c++ compiler (cxx) ... clang++ checking for the c++ compiler (cxx) ... clang++ checking for the c++ compiler (cxx) ... clang++ checking for the c++ compiler (cxx) ... clang++ checking for the c++ compiler (cxx) ... clang++ checking for D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ ... ok checking for flags (-fPIC) ... ok

clang++ "-fPIC" "--sysroot=D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot" "-isystem" "D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi" "-nostdinc++" "-Qunused-arguments" "-target" "armv7-none-linux-androideabi22" "-gcc-toolchain" "D:\SDK\android-ndk-r22\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64" "-mthumb" checking for flags (-fvisibility-inlines-hidden) ... ok clang++ "-fvisibility-inlines-hidden" "--sysroot=D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot" "-isystem" "D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi" "-nostdinc++" "-Qunused-arguments" "-target" "armv7-none-linux-androideabi22" "-gcc-toolchain" "D:\SDK\android-ndk-r22\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64" "-mthumb"
checking for flags (-Oz) ... ok clang++ "-Oz" "--sysroot=D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot" "-isystem" "D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi" "-nostdinc++" "-Qunused-arguments" "-target" "armv7-none-linux-androideabi22" "-gcc-toolchain" "D:\SDK\android-ndk-r22\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64" "-mthumb" checking for flags (-Oz) ... ok clang++ "-Oz" "--sysroot=D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot" "-isystem" "D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi" "-nostdinc++" "-Qunused-arguments" "-target" "armv7-none-linux-androideabi22" "-gcc-toolchain" "D:\SDK\android-ndk-r22\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64" "-mthumb" checking for flags (-std=c++20) ... ok clang++ "-std=c++20" "--sysroot=D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot" "-isystem" "D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi" "-nostdinc++" "-Qunused-arguments" "-target" "armv7-none-linux-androideabi22" "-gcc-toolchain" "D:\SDK\android-ndk-r22\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64" "-mthumb" checking for flags (-std=c++20) ... ok clang++ "-std=c++20" "--sysroot=D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot" "-isystem" "D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi" "-nostdinc++" "-Qunused-arguments" "-target" "armv7-none-linux-androideabi22" "-gcc-toolchain" "D:\SDK\android-ndk-r22\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64" "-mthumb" checking for flags (-fvisibility=hidden) ... ok clang++ "-fvisibility=hidden" "--sysroot=D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot" "-isystem" "D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi" "-nostdinc++" "-Qunused-arguments" "-target" "armv7-none-linux-androideabi22" "-gcc-toolchain" "D:\SDK\android-ndk-r22\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64" "-mthumb" checking for flags (-DNDEBUG) ... ok clang++ "-DNDEBUG" "--sysroot=D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot" "-isystem" "D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi" "-nostdinc++" "-Qunused-arguments" "-target" "armv7-none-linux-androideabi22" "-gcc-toolchain" "D:\SDK\android-ndk-r22\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64" "-mthumb" [ 21%]: cache compiling.release src\Application\src\Application.cpp D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ -c --sysroot=D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot -isystem D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi -nostdinc++ -Qunused-arguments -target armv7-none-linux-androideabi22 -gcc-toolchain D:\SDK\android-ndk-r22\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64 -mthumb -fPIC -Wall -Werror -Oz -std=c++20 -IE:\Work\CVFramework -DCV_COMPILED_LIB -DCV_SHARED_LIB -DLOG_ON -isystem D:\SDK\android-ndk-r22\sources\cxx-stl\llvm-libc++\include -isystem D:\SDK\android-ndk-r22\sources\cxx-stl\llvm-libc++\libs\armeabi-v7a\include -isystem D:\SDK\android-ndk-r22\sources\cxx-stl\llvm-libc++abi\include -fvisibility=hidden -DNDEBUG -o build.objs\Application\android\armeabi-v7a\release\src\Application\src\Application.cpp.o src\Application\src\Application.cpp checking for flags (-MMD -MF) ... ok clang++ "-MMD" "-MF" "C:\Users\castw\AppData\Local\Temp.xmake\240115_F1768BB4A47542108C9252CF7F6DB820" "--sysroot=D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot" "-isystem" "D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi" "-nostdinc++" "-Qunused-arguments" "-target" "armv7-none-linux-androideabi22" "-gcc-toolchain" "D:\SDK\android-ndk-r22\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64" "-mthumb" [ 21%]: cache compiling.release test\src\AppTest.cpp D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ -c --sysroot=D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot -isystem D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi -nostdinc++ -Qunused-arguments -target armv7-none-linux-androideabi22 -gcc-toolchain D:\SDK\android-ndk-r22\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64 -mthumb -fPIE -pie -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Werror -Oz -std=c++20 -IE:\Work\CVFramework -DCV_COMPILED_LIB -DCV_SHARED_LIB -DLOG_ON -isystem C:\Users\castw\AppData\Local.xmake\packages\g\gtest\v1.14.0\7484f84bfb1043c199a1c192fdde8434\include -isystem D:\SDK\android-ndk-r22\sources\cxx-stl\llvm-libc++\include -isystem D:\SDK\android-ndk-r22\sources\cxx-stl\llvm-libc++\libs\armeabi-v7a\include -isystem D:\SDK\android-ndk-r22\sources\cxx-stl\llvm-libc++abi\include -fvisibility=hidden -DNDEBUG -o build.objs\Test\android\armeabi-v7a\release\test\src\AppTest.cpp.o test\src\AppTest.cpp [ 21%]: cache compiling.release src\Log\src\Log.cpp D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ -c --sysroot=D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot -isystem D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi -nostdinc++ -Qunused-arguments -target armv7-none-linux-androideabi22 -gcc-toolchain D:\SDK\android-ndk-r22\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64 -mthumb -fPIC -Wall -Werror -Oz -std=c++20 -IE:\Work\CVFramework -DCV_COMPILED_LIB -DCV_SHARED_LIB -DLOG_ON -DANDROID -isystem C:\Users\castw\AppData\Local.xmake\packages\s\spdlog\v1.12.0\d35f06e46ef042c0aa73ff35c9bfbeaa\include -isystem D:\SDK\android-ndk-r22\sources\cxx-stl\llvm-libc++\include -isystem D:\SDK\android-ndk-r22\sources\cxx-stl\llvm-libc++\libs\armeabi-v7a\include -isystem D:\SDK\android-ndk-r22\sources\cxx-stl\llvm-libc++abi\include -fvisibility=hidden -DNDEBUG -o build.objs\CVLog\android\armeabi-v7a\release\src\Log\src\Log.cpp.o src\Log\src\Log.cpp [ 21%]: cache compiling.release test\src\LogTest.cpp D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ -c --sysroot=D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot -isystem D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi -nostdinc++ -Qunused-arguments -target armv7-none-linux-androideabi22 -gcc-toolchain D:\SDK\android-ndk-r22\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64 -mthumb -fPIE -pie -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Werror -Oz -std=c++20 -IE:\Work\CVFramework -DCV_COMPILED_LIB -DCV_SHARED_LIB -DLOG_ON -isystem C:\Users\castw\AppData\Local.xmake\packages\g\gtest\v1.14.0\7484f84bfb1043c199a1c192fdde8434\include -isystem D:\SDK\android-ndk-r22\sources\cxx-stl\llvm-libc++\include -isystem D:\SDK\android-ndk-r22\sources\cxx-stl\llvm-libc++\libs\armeabi-v7a\include -isystem D:\SDK\android-ndk-r22\sources\cxx-stl\llvm-libc++abi\include -fvisibility=hidden -DNDEBUG -o build.objs\Test\android\armeabi-v7a\release\test\src\LogTest.cpp.o test\src\LogTest.cpp checking for flags (-fvisibility=hidden) ... ok clang++ "-fvisibility=hidden" "--sysroot=D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot" "-isystem" "D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi" "-nostdinc++" "-Qunused-arguments" "-target" "armv7-none-linux-androideabi22" "-gcc-toolchain" "D:\SDK\android-ndk-r22\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64" "-mthumb" [ 21%]: cache compiling.release test\src\main.cpp D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ -c --sysroot=D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot -isystem D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi -nostdinc++ -Qunused-arguments -target armv7-none-linux-androideabi22 -gcc-toolchain D:\SDK\android-ndk-r22\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64 -mthumb -fPIE -pie -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Werror -Oz -std=c++20 -IE:\Work\CVFramework -DCV_COMPILED_LIB -DCV_SHARED_LIB -DLOG_ON -isystem C:\Users\castw\AppData\Local.xmake\packages\g\gtest\v1.14.0\7484f84bfb1043c199a1c192fdde8434\include -isystem D:\SDK\android-ndk-r22\sources\cxx-stl\llvm-libc++\include -isystem D:\SDK\android-ndk-r22\sources\cxx-stl\llvm-libc++\libs\armeabi-v7a\include -isystem D:\SDK\android-ndk-r22\sources\cxx-stl\llvm-libc++abi\include -fvisibility=hidden -DNDEBUG -o build.objs\Test\android\armeabi-v7a\release\test\src\main.cpp.o test\src\main.cpp checking for flags (-fdiagnostics-color=always) ... ok clang++ "-fdiagnostics-color=always" "--sysroot=D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot" "-isystem" "D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi" "-nostdinc++" "-Qunused-arguments" "-target" "armv7-none-linux-androideabi22" "-gcc-toolchain" "D:\SDK\android-ndk-r22\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64" "-mthumb"
checking for flags (-fdiagnostics-color=always) ... ok clang++ "-fdiagnostics-color=always" "--sysroot=D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot" "-isystem" "D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi" "-nostdinc++" "-Qunused-arguments" "-target" "armv7-none-linux-androideabi22" "-gcc-toolchain" "D:\SDK\android-ndk-r22\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64" "-mthumb"
checking for flags (-fPIC) ... ok clang++ "-fPIC" "-shared" "-llog" "-target" "armv7-none-linux-androideabi22" "-gcc-toolchain" "D:\SDK\android-ndk-r22\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64" "-nostdlib++" "-mthumb" "-llog" "-target" "armv7-none-linux-androideabi22" "-gcc-toolchain" "D:\SDK\android-ndk-r22\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64" "-nostdlib++" "-mthumb" [ 57%]: linking.release libCVLog.so D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ -o build\android\armeabi-v7a\release\libCVLog.so build.objs\CVLog\android\armeabi-v7a\release\src\Log\src\Log.cpp.o -shared -target armv7-none-linux-androideabi22 -gcc-toolchain D:\SDK\android-ndk-r22\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64 -nostdlib++ -mthumb -fPIC -s -LD:\SDK\android-ndk-r22\sources\cxx-stl\llvm-libc++\libs\armeabi-v7a -llog -lc++_static -lc++abi -lunwind -latomic [ 71%]: linking.release libApplication.so D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ -o build\android\armeabi-v7a\release\libApplication.so build.objs\Application\android\armeabi-v7a\release\src\Application\src\Application.cpp.o -shared -target armv7-none-linux-androideabi22 -gcc-toolchain D:\SDK\android-ndk-r22\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64 -nostdlib++ -mthumb -fPIC -Lbuild\android\armeabi-v7a\release -s -LD:\SDK\android-ndk-r22\sources\cxx-stl\llvm-libc++\libs\armeabi-v7a -lCVLog -llog -lc++_static -lc++abi -lunwind -latomic checking for flags (-fPIC) ... ok clang++ "-fPIC" "-llog" "-target" "armv7-none-linux-androideabi22" "-gcc-toolchain" "D:\SDK\android-ndk-r22\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64" "-fPIE" "-pie" "-nostdlib++" "-mthumb" "-llog" "-target" "armv7-none-linux-androideabi22" "-gcc-toolchain" "D:\SDK\android-ndk-r22\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64" "-fPIE" "-pie" "-nostdlib++" "-mthumb" checking for flags (-Wl,-rpath=@loader_path) ... ok clang++ "-Wl,-rpath=@loader_path" "-llog" "-target" "armv7-none-linux-androideabi22" "-gcc-toolchain" "D:\SDK\android-ndk-r22\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64" "-fPIE" "-pie" "-nostdlib++" "-mthumb" "-llog" "-target" "armv7-none-linux-androideabi22" "-gcc-toolchain" "D:\SDK\android-ndk-r22\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64" "-fPIE" "-pie" "-nostdlib++" "-mthumb" checking for flags (-static-libstdc++) ... ok clang++ "-static-libstdc++" "-llog" "-target" "armv7-none-linux-androideabi22" "-gcc-toolchain" "D:\SDK\android-ndk-r22\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64" "-fPIE" "-pie" "-nostdlib++" "-mthumb" "-llog" "-target" "armv7-none-linux-androideabi22" "-gcc-toolchain" "D:\SDK\android-ndk-r22\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64" "-fPIE" "-pie" "-nostdlib++" "-mthumb" [ 85%]: linking.release Test D:\SDK\android-ndk-r22\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ -o build\android\armeabi-v7a\release\Test build.objs\Test\android\armeabi-v7a\release\test\src\AppTest.cpp.o build.objs\Test\android\armeabi-v7a\release\test\src\LogTest.cpp.o build.objs\Test\android\armeabi-v7a\release\test\src\main.cpp.o -target armv7-none-linux-androideabi22 -gcc-toolchain D:\SDK\android-ndk-r22\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64 -fPIE -pie -nostdlib++ -mthumb -LC:\Users\castw\AppData\Local.xmake\packages\g\gtest\v1.14.0\7484f84bfb1043c199a1c192fdde8434\lib -Lbuild\android\armeabi-v7a\release -Wl,-rpath=$ORIGIN -s -LD:\SDK\android-ndk-r22\sources\cxx-stl\llvm-libc++\libs\armeabi-v7a -lgmock -lgtest -lApplication -lCVLog -llog -lc++_static -lc++abi -lunwind -latomic -static-libstdc++ clang++: warning: argument unused during compilation: '-static-libstdc++' [-Wunused-command-line-argument]

build cache stats: cache directory: build.build_cache cache hit rate: 0% cache hit: 0 cache miss: 5 new cached files: 5 remote cache hit: 0 remote new cached files: 0 preprocess failed: 0 compile fallback count: 0

[100%]: build ok, spent 10.437s

Issues-translate-bot commented 10 months ago

Bot detected the issue body's language is not English, translate it automatically.


Title: android-ndk-26b file directory changes lead to incorrect compilation results

waruqi commented 10 months ago

https://github.com/xmake-io/xmake/pull/4616

试试,xmake update -s dev

Issues-translate-bot commented 10 months ago

Bot detected the issue body's language is not English, translate it automatically.


https://github.com/xmake-io/xmake/pull/4616

Try, xmake update -s dev

WooZoo86 commented 10 months ago

一、xmake版本 PS E:\Work\CVFramework> xmake --version xmake v2.8.6+dev.c68263277, A cross-platform build utility based on Lua Copyright (C) 2015-present Ruki Wang, tboox.org, xmake.io

二、xmake配置,只有ndk不一样,以下是编译运行测试程序 (1)低版本ndk:--ndk=D:\SDK\android-ndk-r25c 1|i50:/data/local/tmp $ chmod 777 ./Test && ./Test [==========] Running 3 tests from 2 test suites. [----------] Global test environment set-up. [----------] 1 test from AppBuilderTest [ RUN ] AppBuilderTest.Instance [ OK ] AppBuilderTest.Instance (0 ms) [----------] 1 test from AppBuilderTest (0 ms total)

[----------] 2 tests from LogTest [ RUN ] LogTest.Instance [ OK ] LogTest.Instance (5000 ms) [ RUN ] LogTest.Macro [ OK ] LogTest.Macro (5000 ms) [----------] 2 tests from LogTest (10001 ms total)

[----------] Global test environment tear-down [==========] 3 tests from 2 test suites ran. (10002 ms total) [ PASSED ] 3 tests. 结论:静态链接libc++没有问题

(2)最新ndk:--ndk=D:\SDK\android-ndk-r26b i50:/data/local/tmp $ chmod 777 ./Test && ./Test CANNOT LINK EXECUTABLE "./Test": library "libc++_shared.so" not found 结论:设置了静态链接没有起到作用。

三、总结:load.lua可能还没有准确的判断ndk的变更。

waruqi commented 10 months ago

贴下详细命令 和 -vD logs

Issues-translate-bot commented 10 months ago

Bot detected the issue body's language is not English, translate it automatically.


Post detailed commands and -vD logs

WooZoo86 commented 10 months ago

PS E:\Work\CVFramework> xmake f -p android -a armeabi-v7a -m release --ndk=D:\SDK\android-ndk-r26b checking for Android SDK directory ... no checking for NDK directory ... D:\SDK\android-ndk-r26b checking for SDK version of NDK ... 22 PS E:\Work\CVFramework> xmake -vD checking for the shared library linker (sh) ... clang++ checking for the linker (ld) ... clang++ checking for clang++ ... D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ checking for the c++ compiler (cxx) ... clang++ checking for the c++ compiler (cxx) ... clang++ checking for the c++ compiler (cxx) ... clang++ checking for the c++ compiler (cxx) ... clang++ checking for the c++ compiler (cxx) ... clang++ checking for D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ ... ok checking for flags (-fPIC) ... ok

clang++ "-fPIC" "--sysroot=D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot" "-isystem" "D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi" "-Qunused-arguments" "-target" "armv7-none-linux-androideabi22" "-mthumb" checking for flags (-fvisibility-inlines-hidden) ... ok clang++ "-fvisibility-inlines-hidden" "--sysroot=D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot" "-isystem" "D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi" "-Qunused-arguments" "-target" "armv7-none-linux-androideabi22" "-mthumb" checking for flags (-Oz) ... ok clang++ "-Oz" "--sysroot=D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot" "-isystem" "D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi" "-Qunused-arguments" "-target" "armv7-none-linux-androideabi22" "-mthumb" checking for flags (-Oz) ... ok clang++ "-Oz" "--sysroot=D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot" "-isystem" "D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi" "-Qunused-arguments" "-target" "armv7-none-linux-androideabi22" "-mthumb" checking for flags (-std=c++20) ... ok clang++ "-std=c++20" "--sysroot=D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot" "-isystem" "D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi" "-Qunused-arguments" "-target" "armv7-none-linux-androideabi22" "-mthumb" checking for flags (-std=c++20) ... ok clang++ "-std=c++20" "--sysroot=D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot" "-isystem" "D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi" "-Qunused-arguments" "-target" "armv7-none-linux-androideabi22" "-mthumb" checking for flags (-fvisibility=hidden) ... ok clang++ "-fvisibility=hidden" "--sysroot=D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot" "-isystem" "D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi" "-Qunused-arguments" "-target" "armv7-none-linux-androideabi22" "-mthumb" checking for flags (-DNDEBUG) ... ok clang++ "-DNDEBUG" "--sysroot=D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot" "-isystem" "D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi" "-Qunused-arguments" "-target" "armv7-none-linux-androideabi22" "-mthumb" [ 21%]: cache compiling.release src\Application\src\Application.cpp D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ -c --sysroot=D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot -isystem D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi -Qunused-arguments -target armv7-none-linux-androideabi22 -mthumb -fPIC -Wall -Werror -Oz -std=c++20 -IE:\Work\CVFramework -DCV_COMPILED_LIB -DCV_SHARED_LIB -DLOG_ON -fvisibility=hidden -DNDEBUG -o build.objs\Application\android\armeabi-v7a\release\src\Application\src\Application.cpp.o src\Application\src\Application.cpp checking for flags (-MMD -MF) ... ok clang++ "-MMD" "-MF" "C:\Users\castw\AppData\Local\Temp.xmake\240116_BA666C4A91934D308D792897E176E170" "--sysroot=D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot" "-isystem" "D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi" "-Qunused-arguments" "-target" "armv7-none-linux-androideabi22" "-mthumb" [ 21%]: cache compiling.release test\src\AppTest.cpp D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ -c --sysroot=D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot -isystem D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi -Qunused-arguments -target armv7-none-linux-androideabi22 -mthumb -fPIE -pie -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Werror -Oz -std=c++20 -IE:\Work\CVFramework -DCV_COMPILED_LIB -DCV_SHARED_LIB -DLOG_ON -isystem C:\Users\castw\AppData\Local.xmake\packages\g\gtest\v1.14.0\7484f84bfb1043c199a1c192fdde8434\include -fvisibility=hidden -DNDEBUG -o build.objs\Test\android\armeabi-v7a\release\test\src\AppTest.cpp.o test\src\AppTest.cpp [ 21%]: cache compiling.release src\Log\src\Log.cpp D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ -c --sysroot=D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot -isystem D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi -Qunused-arguments -target armv7-none-linux-androideabi22 -mthumb -fPIC -Wall -Werror -Oz -std=c++20 -IE:\Work\CVFramework -DCV_COMPILED_LIB -DCV_SHARED_LIB -DLOG_ON -DANDROID -isystem C:\Users\castw\AppData\Local.xmake\packages\s\spdlog\v1.12.0\d35f06e46ef042c0aa73ff35c9bfbeaa\include -fvisibility=hidden -DNDEBUG -o build.objs\CVLog\android\armeabi-v7a\release\src\Log\src\Log.cpp.o src\Log\src\Log.cpp [ 21%]: cache compiling.release test\src\LogTest.cpp D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ -c --sysroot=D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot -isystem D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi -Qunused-arguments -target armv7-none-linux-androideabi22 -mthumb -fPIE -pie -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Werror -Oz -std=c++20 -IE:\Work\CVFramework -DCV_COMPILED_LIB -DCV_SHARED_LIB -DLOG_ON -isystem C:\Users\castw\AppData\Local.xmake\packages\g\gtest\v1.14.0\7484f84bfb1043c199a1c192fdde8434\include -fvisibility=hidden -DNDEBUG -o build.objs\Test\android\armeabi-v7a\release\test\src\LogTest.cpp.o test\src\LogTest.cpp checking for flags (-fvisibility=hidden) ... ok clang++ "-fvisibility=hidden" "--sysroot=D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot" "-isystem" "D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi" "-Qunused-arguments" "-target" "armv7-none-linux-androideabi22" "-mthumb" [ 21%]: cache compiling.release test\src\main.cpp D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ -c --sysroot=D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot -isystem D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi -Qunused-arguments -target armv7-none-linux-androideabi22 -mthumb -fPIE -pie -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Werror -Oz -std=c++20 -IE:\Work\CVFramework -DCV_COMPILED_LIB -DCV_SHARED_LIB -DLOG_ON -isystem C:\Users\castw\AppData\Local.xmake\packages\g\gtest\v1.14.0\7484f84bfb1043c199a1c192fdde8434\include -fvisibility=hidden -DNDEBUG -o build.objs\Test\android\armeabi-v7a\release\test\src\main.cpp.o test\src\main.cpp checking for flags (-fdiagnostics-color=always) ... ok clang++ "-fdiagnostics-color=always" "--sysroot=D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot" "-isystem" "D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi" "-Qunused-arguments" "-target" "armv7-none-linux-androideabi22" "-mthumb" checking for flags (-fdiagnostics-color=always) ... ok clang++ "-fdiagnostics-color=always" "--sysroot=D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot" "-isystem" "D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi" "-Qunused-arguments" "-target" "armv7-none-linux-androideabi22" "-mthumb" checking for flags (-fPIC) ... ok clang++ "-fPIC" "-shared" "-llog" "-target" "armv7-none-linux-androideabi22" "-mthumb" "-llog" "-target" "armv7-none-linux-androideabi22" "-mthumb" [ 57%]: linking.release libCVLog.so D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ -o build\android\armeabi-v7a\release\libCVLog.so build.objs\CVLog\android\armeabi-v7a\release\src\Log\src\Log.cpp.o -shared -target armv7-none-linux-androideabi22 -mthumb -fPIC -s -llog -lc++_static -lunwind -latomic [ 71%]: linking.release libApplication.so D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ -o build\android\armeabi-v7a\release\libApplication.so build.objs\Application\android\armeabi-v7a\release\src\Application\src\Application.cpp.o -shared -llog -target armv7-none-linux-androideabi22 -mthumb -fPIC -Lbuild\android\armeabi-v7a\release -s -lCVLog -lc++_static -lunwind -latomic checking for flags (-fPIC) ... ok clang++ "-fPIC" "-llog" "-target" "armv7-none-linux-androideabi22" "-fPIE" "-pie" "-mthumb" "-llog" "-target" "armv7-none-linux-androideabi22" "-fPIE" "-pie" "-mthumb" checking for flags (-Wl,-rpath=@loader_path) ... ok clang++ "-Wl,-rpath=@loader_path" "-llog" "-target" "armv7-none-linux-androideabi22" "-fPIE" "-pie" "-mthumb" "-llog" "-target" "armv7-none-linux-androideabi22" "-fPIE" "-pie" "-mthumb" [ 85%]: linking.release Test D:\SDK\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ -o build\android\armeabi-v7a\release\Test build.objs\Test\android\armeabi-v7a\release\test\src\AppTest.cpp.o build.objs\Test\android\armeabi-v7a\release\test\src\LogTest.cpp.o build.objs\Test\android\armeabi-v7a\release\test\src\main.cpp.o -target armv7-none-linux-androideabi22 -fPIE -pie -mthumb -LC:\Users\castw\AppData\Local.xmake\packages\g\gtest\v1.14.0\7484f84bfb1043c199a1c192fdde8434\lib -Lbuild\android\armeabi-v7a\release -Wl,-rpath=$ORIGIN -s -lgmock -lgtest -lApplication -lCVLog -llog -lc++_static -lunwind -latomic

build cache stats: cache directory: build.build_cache cache hit rate: 0% cache hit: 0 cache hit total time: 0.000s cache miss: 5 cache miss total time: 0.030s new cached files: 5 remote cache hit: 0 remote new cached files: 0 preprocess failed: 0 compile fallback count: 0 compile total time: 7.830s

[100%]: build ok, spent 6.906s

WooZoo86 commented 10 months ago

-- set compile flags set_warnings("all", "error") set_languages("c17","cxx20") set_config("ndk_cxxstl","c++_static") set_config("ndk_sdkver","22")

waruqi commented 10 months ago

-lgmock -lgtest -lApplication -lCVLog -llog -lc++_static -lunwind -latomic

不是加进去了么。。看着没啥问题

Issues-translate-bot commented 10 months ago

Bot detected the issue body's language is not English, translate it automatically.


-lgmock -lgtest -lApplication -lCVLog -llog -lc++_static -lunwind -latomic

Wasn't it added? . Looks like there's nothing wrong with it

waruqi commented 10 months ago

再试试,应该可以了,xmake update -s dev

Issues-translate-bot commented 10 months ago

Bot detected the issue body's language is not English, translate it automatically.


Try again, it should work, xmake update -s dev

jococi commented 10 months ago

可以了吗?我怎么还不行

Issues-translate-bot commented 10 months ago

Bot detected the issue body's language is not English, translate it automatically.


Is it ok? Why can't I do it?

waruqi commented 10 months ago

这边可以

ruki-2:test ruki$ xmake f -p android --ndk=~/files/android-ndk-r26b/ -c -a arm64-v8a ; xmake -rv
checking for Android SDK directory ... ~/Library/Android/sdk
checking for Build Tools Version of Android SDK ... 33.0.1
checking for NDK directory ... /Users/ruki/files/android-ndk-r26b
checking for SDK version of NDK ... 21
checking for the shared library linker (sh) ... clang++
checking for the linker (ld) ... clang++
checking for clang++ ... /Users/ruki/files/android-ndk-r26b/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++
checking for the c++ compiler (cxx) ... clang++
checking for /Users/ruki/files/android-ndk-r26b/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ ... ok
checking for flags (-fPIC) ... ok
checking for flags (-fvisibility-inlines-hidden) ... ok
checking for flags (-Oz) ... ok
checking for flags (-DNDEBUG) ... ok
[ 25%]: cache compiling.release src/main.cpp
/Users/ruki/files/android-ndk-r26b/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ -c --sysroot=/Users/ruki/files/android-ndk-r26b/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -isystem /Users/ruki/files/android-ndk-r26b/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/aarch64-linux-android -Qunused-arguments -target aarch64-none-linux-android21 -fPIE -pie -fvisibility=hidden -fvisibility-inlines-hidden -Oz -DNDEBUG -o build/.objs/test/android/arm64-v8a/release/src/main.cpp.o src/main.cpp
checking for flags (-MMD -MF) ... ok
checking for flags (-fdiagnostics-color=always) ... ok
checking for flags (-fPIC) ... ok
[ 50%]: linking.release test
/Users/ruki/files/android-ndk-r26b/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ -o build/android/arm64-v8a/release/test build/.objs/test/android/arm64-v8a/release/src/main.cpp.o -llog -target aarch64-none-linux-android21 -fPIE -pie -static-libstdc++ -s
[100%]: build ok, spent 0.796s
ruki-2:test ruki$ adb push build/android/arm64-v8a/release/test /data/local/tmp/test; adb shell /data/local/tmp/test
build/android/arm64-v8a/release/test: 1 file pushed, 0 skipped. 104.8 MB/s (791848 bytes in 0.007s)
hello world!
jococi commented 10 months ago

你是的对的,是我另外一个动态库引起的

Issues-translate-bot commented 10 months ago

Bot detected the issue body's language is not English, translate it automatically.


You are right, it was caused by another dynamic library of mine.

ifarbod commented 9 months ago

I ran into this issue, I had to use add_links("c++_static") in my project, maybe you should give this another look @waruqi ?

Should I open a new issue?

waruqi commented 9 months ago

Did you try dev version?

ifarbod commented 9 months ago

Yeah, I also tried xmake update -s dev but I always get c++_shared.so linked in my final .so.

waruqi commented 9 months ago

Yeah, I also tried xmake update -s dev but I always get c++_shared.so linked in my final .so.

you need pass --ndk_cxxstl=c++_static to xmake config, itis not default config.

ifarbod commented 9 months ago

Can I use set_runtimes() in my xmake.lua to get the same effect?

waruqi commented 9 months ago

Can I use set_runtimes() in my xmake.lua to get the same effect?

dev version support it.

ifarbod commented 9 months ago

@waruqi Will this change land in v2.8.7?

waruqi commented 9 months ago

2.8.7 will support it, or you can use set_config https://github.com/xmake-io/xmake/issues/4614#issuecomment-1893099710