github下载不了glog可以上gitcode或者gitee
https://blog.csdn.net/hhaijiuwo/article/details/119876307

https://blog.csdn.net/console_log/article/details/122839173?spm=1001.2101.3001.6650.5&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EOPENSEARCH%7ERate-5-122839173-blog-120749148.pc_relevant_multi_platform_featuressortv2dupreplace&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EOPENSEARCH%7ERate-5-122839173-blog-120749148.pc_relevant_multi_platform_featuressortv2dupreplace&utm_relevant_index=6

https://blog.csdn.net/feitingfj/article/details/120749148?spm=1001.2101.3001.6650.16&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EESQUERY%7ERate-16-120749148-blog-119876307.pc_relevant_multi_platform_whitelistv6&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EESQUERY%7ERate-16-120749148-blog-119876307.pc_relevant_multi_platform_whitelistv6&utm_relevant_index=19

NDK交叉编译glog

  • CMakeLists.txt修改

1.注释set (CMAKE_DEBUG_POSTFIX d)
2.注释logging_unittest.cc相关的编译,否则报错


#  add_executable (logging_unittest
#    src/logging_unittest.cc
#  )

#  target_link_libraries (logging_unittest PRIVATE ${_GLOG_TEST_LIBS})

#  add_test (NAME logging COMMAND logging_unittest)

#  set_tests_properties (logging PROPERTIES TIMEOUT 30)
#  # MacOS diff is not deterministic: use the output to determine whether the
#  # test passed.
#  set_tests_properties (logging PROPERTIES PASS_REGULAR_EXPRESSION ".*\nPASS\n.*")
#
#  # FIXME: Skip flaky test
#  set_tests_properties (logging PROPERTIES SKIP_REGULAR_EXPRESSION
#    "Check failed: time_ns within LogTimes::LOG_PERIOD_TOL_NS of LogTimes::LOG_PERIOD_NS")
#
#  if (APPLE)
#    # FIXME: Skip flaky test
#    set_property (TEST logging APPEND PROPERTY SKIP_REGULAR_EXPRESSION
#      "unexpected new.*PASS\nTest with golden file failed. We'll try to show the diff:")
#  endif (APPLE)
  • 利用NDK制作编译脚本
mkdir -p build

cd build

rm -rf *

export CMAKE_BUILD_TYPE=Debug

cmake .. \
-DCMAKE_TOOLCHAIN_FILE=/etc/opt/pkg/android-ndk-r25c/build/cmake/android.toolchain.cmake \
-DANDROID_ABI="arm64-v8a" \
-DANDROID_NATIVE_API_LEVEL=android-24 \

make -j4
  • 引用libglog的项目要引用andorid的log库
    target_link_libraries(lxc_socket_server log)

否则报错:(注意到glog里也有引用,但是没有用。)

但是如果打静态链接可执行文件包,CMakeLists.txt里设置SET(CMAKE_EXE_LINKER_FLAGS "-static")之后编译又会报错:


0 条评论

发表回复

您的电子邮箱地址不会被公开。