The source project of this merge request has been removed.
Fix configuring with pthread on Android 32 bit
Recent changes to both zxing-cpp and exiv2 broke the build for Android armv7.
The root cause is that both projects do not enable the C compiler.
This forces FindThreads
to work in CXX mode, where somewhere deep inside CMake a -fPIE
flag is added.
In C mode the flag is not added.
The armv7 linker is not happy with the result, complaining about missing -fPIC
.
I think that this is because pthread
is an internal library on Android, not a shared object.
Run Build Command(s):/usr/bin/make cmTC_e1103/fast && /usr/bin/make -f CMakeFiles/cmTC_e1103.dir/build.make CMakeFiles/cmTC_e1103.dir/build
make[1]: Entering directory '/home/user/build-arm/zxing-cpp/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_e1103.dir/CheckForPthreads.cxx.o
/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=armv7-none-linux-androideabi21 --gcc-toolchain=/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64 -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security -fPIE -std=c++17 -o CMakeFiles/cmTC_e1103.dir/CheckForPthreads.cxx.o -c /home/user/build-arm/zxing-cpp/CMakeFiles/FindThreads/CheckForPthreads.cxx
Linking CXX executable cmTC_e1103
/opt/cmake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_e1103.dir/link.txt --verbose=1
/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=armv7-none-linux-androideabi21 --gcc-toolchain=/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64 -fPIC -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -Wl,--build-id -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments -Wl,--gc-sections -shared -o cmTC_e1103 CMakeFiles/cmTC_e1103.dir/CheckForPthreads.cxx.o -pthread -latomic -lm
/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: CMakeFiles/cmTC_e1103.dir/CheckForPthreads.cxx.o: requires unsupported dynamic reloc R_ARM_REL32; recompile with -fPIC
/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: warning: shared library text segment is not shareable
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [CMakeFiles/cmTC_e1103.dir/build.make:106: cmTC_e1103] Error 1
Instead of trying to force -fPIC
, which could have unforeseen consequences, I just copied some code over from FindThreads
.
Because we only have to work with the NDK, it should be safe to hard-code the proper values.