Closed WooZoo86 closed 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
https://github.com/xmake-io/xmake/pull/4616
试试,xmake update -s dev
Bot detected the issue body's language is not English, translate it automatically.
Try, xmake update -s dev
一、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的变更。
贴下详细命令 和 -vD logs
Bot detected the issue body's language is not English, translate it automatically.
Post detailed commands and -vD logs
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
-- set compile flags set_warnings("all", "error") set_languages("c17","cxx20") set_config("ndk_cxxstl","c++_static") set_config("ndk_sdkver","22")
-lgmock -lgtest -lApplication -lCVLog -llog -lc++_static -lunwind -latomic
不是加进去了么。。看着没啥问题
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
再试试,应该可以了,xmake update -s dev
Bot detected the issue body's language is not English, translate it automatically.
Try again, it should work,
xmake update -s dev
可以了吗?我怎么还不行
Bot detected the issue body's language is not English, translate it automatically.
Is it ok? Why can't I do it?
这边可以
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!
你是的对的,是我另外一个动态库引起的
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.
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?
Did you try dev version?
Yeah, I also tried xmake update -s dev
but I always get c++_shared.so linked in my final .so.
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.
Can I use set_runtimes()
in my xmake.lua to get the same effect?
Can I use
set_runtimes()
in my xmake.lua to get the same effect?
dev version support it.
@waruqi Will this change land in v2.8.7?
2.8.7 will support it, or you can use set_config https://github.com/xmake-io/xmake/issues/4614#issuecomment-1893099710
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
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