8000 build for android failed due to error: undefined symbol: __android_log_write · Issue #543 · log4cplus/log4cplus · GitHub
[go: up one dir, main page]

Skip to content

build for android failed due to error: undefined symbol: __android_log_write #543

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
leleliu008 opened this issue Dec 27, 2021 · 6 comments
Assignees

Comments

@leleliu008
Copy link
Contributor
cmake -DLOG4CPLUS_BUILD_TESTING=OFF -DWITH_UNIT_TESTS=ON

https://downloads.sourceforge.net/project/log4cplus/log4cplus-stable/2.0.7/log4cplus-2.0.7.tar.xz

@wilx wilx self-assigned this Dec 27, 2021
@wilx wilx added the bug label Dec 27, 2021
@wilx
Copy link
Contributor
wilx commented Dec 27, 2021

Please test the following patch:

diff --git a/tests/unit_tests/CMakeLists.txt b/tests/unit_tests/CMakeLists.txt
index 01a3f6e0..90fd76c8 100644
--- a/tests/unit_tests/CMakeLists.txt
+++ b/tests/unit_tests/CMakeLists.txt
@@ -1,5 +1,9 @@
 add_executable (unit_tests unit_tests.cxx)
 target_link_libraries (unit_tests ${log4cplus})
+if (ANDROID)
+  find_library (log-lib log)
+  target_link_libraries (unit_tests ${log-lib})
+endif (ANDROID)
 add_test(NAME unit_tests
   WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
   COMMAND unit_tests)

@leleliu008
Copy link
Contributor Author

thanks for your effort. but this patch not work for me.

wilx added a commit to wilx/log4cplus that referenced this issue Dec 27, 2021
Look for Android's log library.

Fixes log4cplus#543.
@wilx
Copy link
Contributor
wilx commented Dec 27, 2021

I think the change I just committed should fix this. Please test.

@leleliu008
Copy link
Contributor Author

can't work, error logs:

FAILED: src/liblog4cplus.so
: && /home/fpliu/.ndk-pkg/android-ndk-r23b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=armv7-none-linux-androideabi21 --sysroot=/home/fpliu/.ndk-pkg/android-ndk-r23b/toolchains/llvm/prebuilt/linux-x86_64/sysroot -fPIC --sysroot /home/fpliu/.ndk-pkg/android-ndk-r23b/toolchains/llvm/prebuilt/linux-x86_64/sysroot -Qunused-arguments -fpic -Wl,--dynamic-linker=/system/bin/linker -Wl,--strip-debug -Os -DNDEBUG --sysroot /home/fpliu/.ndk-pkg/android-ndk-r23b/toolchains/llvm/prebuilt/linux-x86_64/sysroot -Qunused-arguments -I/home/fpliu/.ndk-pkg/android-ndk-r23b/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/arm-linux-androideabi -include /tmp/tmp.mXzOj70DxX/1640817647/include.h --sysroot /home/fpliu/.ndk-pkg/android-ndk-r23b/toolchains/llvm/prebuilt/linux-x86_64/sysroot -L/tmp/tmp.mXzOj70DxX/1640817647 -L/home/fpliu/.ndk-pkg/android-ndk-r23b/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/arm-linux-androideabi/21 -Wl,--dynamic-linker=/system/bin/linker -Wl,--strip-debug -O3 -DNDEBUG  -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Qunused-arguments -Wl,--no-undefined --sysroot /home/fpliu/.ndk-pkg/android-ndk-r23b/toolchains/llvm/prebuilt/linux-x86_64/sysroot -L/tmp/tmp.mXzOj70DxX/1640817647 -L/home/fpliu/.ndk-pkg/android-ndk-r23b/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/arm-linux-androideabi/21 -Wl,--dynamic-linker=/system/bin/linker -Wl,--strip-debug -shared -Wl,-soname,liblog4cplus.so -o src/liblog4cplus.so src/CMakeFiles/log4cplus.dir/appenderattachableimpl.cxx.o src/CMakeFiles/log4cplus.dir/appender.cxx.o src/CMakeFiles/log4cplus.dir/asyncappender.cxx.o src/CMakeFiles/log4cplus.dir/callbackappender.cxx.o src/CMakeFiles/log4cplus.dir/clogger.cxx.o src/CMakeFiles/log4cplus.dir/configurator.cxx.o src/CMakeFiles/log4cplus.dir/connectorthread.cxx.o src/CMakeFiles/log4cplus.dir/consoleappender.cxx.o src/CMakeFiles/log4cplus.dir/cygwin-win32.cxx.o src/CMakeFiles/log4cplus.dir/env.cxx.o src/CMakeFiles/log4cplus.dir/factory.cxx.o src/CMakeFiles/log4cplus.dir/fileappender.cxx.o src/CMakeFiles/log4cplus.dir/fileinfo.cxx.o src/CMakeFiles/log4cplus.dir/filter.cxx.o src/CMakeFiles/log4cplus.dir/global-init.cxx.o src/CMakeFiles/log4cplus.dir/hierarchy.cxx.o src/CMakeFiles/log4cplus.dir/hierarchylocker.cxx.o src/CMakeFiles/log4cplus.dir/layout.cxx.o src/CMakeFiles/log4cplus.dir/log4judpappender.cxx.o src/CMakeFiles/log4cplus.dir/lockfile.cxx.o src/CMakeFiles/log4cplus.dir/logger.cxx.o src/CMakeFiles/log4cplus.dir/loggerimpl.cxx.o src/CMakeFiles/log4cplus.dir/loggingevent.cxx.o src/CMakeFiles/log4cplus.dir/loggingmacros.cxx.o src/CMakeFiles/log4cplus.dir/loglevel.cxx.o src/CMakeFiles/log4cplus.dir/loglog.cxx.o src/CMakeFiles/log4cplus.dir/mdc.cxx.o src/CMakeFiles/log4cplus.dir/ndc.cxx.o src/CMakeFiles/log4cplus.dir/nullappender.cxx.o src/CMakeFiles/log4cplus.dir/objectregistry.cxx.o src/CMakeFiles/log4cplus.dir/patternlayout.cxx.o src/CMakeFiles/log4cplus.dir/pointer.cxx.o src/CMakeFiles/log4cplus.dir/property.cxx.o src/CMakeFiles/log4cplus.dir/queue.cxx.o src/CMakeFiles/log4cplus.dir/rootlogger.cxx.o src/CMakeFiles/log4cplus.dir/snprintf.cxx.o src/CMakeFiles/log4cplus.dir/socketappender.cxx.o src/CMakeFiles/log4cplus.dir/socketbuffer.cxx.o src/CMakeFiles/log4cplus.dir/socket.cxx.o src/CMakeFiles/log4cplus.dir/stringhelper.cxx.o src/CMakeFiles/log4cplus.dir/stringhelper-clocale.cxx.o src/CMakeFiles/log4cplus.dir/stringhelper-cxxlocale.cxx.o src/CMakeFiles/log4cplus.dir/stringhelper-iconv.cxx.o src/CMakeFiles/log4cplus.dir/syncprims.cxx.o src/CMakeFiles/log4cplus.dir/syslogappender.cxx.o src/CMakeFiles/log4cplus.dir/threads.cxx.o src/CMakeFiles/log4cplus.dir/timehelper.cxx.o src/CMakeFiles/log4cplus.dir/tls.cxx.o src/CMakeFiles/log4cplus.dir/version.cxx.o src/CMakeFiles/log4cplus.dir/socket-unix.cxx.o  -lpthread   -static-libstdc++ -latomic -lm && :
ld: error: undefined symbol: __android_log_write
>>> referenced by global-init.cxx
>>>               src/CMakeFiles/log4cplus.dir/global-init.cxx.o:(Catch::writeToDebugConsole(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1
8000
::allocator<char> > const&))
>>> referenced by global-init.cxx
>>>               src/CMakeFiles/log4cplus.dir/global-init.cxx.o:(Catch::Detail::(anonymous namespace)::StreamBufImpl<Catch::Detail::(anonymous namespace)::OutputDebugWriter, 256u>::sync())
>>> referenced by global-init.cxx
>>>               src/CMakeFiles/log4cplus.dir/global-init.cxx.o:(Catch::Detail::(anonymous namespace)::StreamBufImpl<Catch::Detail::(anonymous namespace)::OutputDebugWriter, 256u>::overflow(int))
clang-12: error: linker command failed with exit code 1 (use -v to see invocation)

@wilx
Copy link
Contributor
wilx commented Dec 29, 2021

It did work for me. I configured from subdirecotry of the sources:

cmake -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=android-23 -DANDROID_NDK=$HOME/Android/Sdk/ndk/23.1.7779620 -DCMAKE_TOOLCHAIN_FILE=$HOME/Android/Sdk/ndk/23.1.7779620/build/cmake/android.toolchain.cmake -G Ninja $PWD/..

@leleliu008
Copy link
Contributor Author

I find that your fix has been merged into 2.0.x branch, it works indeed.

@wilx wilx closed this as completed Dec 30, 2021
wilx added a commit to wilx/log4cplus that referenced this issue Dec 30, 2021
Look for Android's log library.

Fixes log4cplus#543.

(cherry picked from commit 2de9a22)
@wilx wilx added the v2.0.8 label Feb 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
0