【问题标题】:Building Poco C++ libraries with Conan profiles for Android使用适用于 Android 的柯南配置文件构建 Poco C++ 库
【发布时间】:2019-03-13 21:35:56
【问题描述】:

我尝试在项目中使用 Poco C++ 库,但在为 Android 构建时遇到了一些问题。

我使用 Conan C++ 包管理器作为基础,但我将 Poco 源包含到项目中,并将其子目录包含到项目的顶级 CMakeLists.txt 中,以使过程更加透明。

如果我使用不依赖于 OpenSSL 的 Poco 库构建项目,它构建得很好。如果我添加 Poco 的 NetSSL,那么我会遇到一些与 math.h 相关的问题:

In file included from /home/uname/storage/projects/-some-project-/thirdparty/poco/Crypto/src/Cipher.cpp:15:
In file included from /home/uname/storage/projects/-some-project-/thirdparty/poco/Crypto/include/Poco/Crypto/Cipher.h:22:
In file included from /home/uname/storage/projects/-some-project-/thirdparty/poco/Foundation/include/Poco/RefCountedObject.h:22:
In file included from /home/uname/storage/projects/-some-project-/thirdparty/poco/Foundation/include/Poco/MemoryPool.h:24:
In file included from /home/uname/storage/projects/-some-project-/thirdparty/poco/Foundation/include/Poco/NestedDiagnosticContext.h:24:
In file included from /home/uname/storage/projects/-some-project-/thirdparty/poco/Foundation/include/Poco/OrderedMap.h:28:
In file included from /home/uname/storage/projects/-some-project-/thirdparty/poco/Foundation/include/Poco/ordered_hash.h:31:
/home/uname/.conan/data/android-ndk/r18/theodelrieu/testing/package/2296cbf988942dec6e0ebdfef682b5c678acade8/sources/cxx-stl/llvm-libc++/include/cmath:313:9: error: no member named 'signbit' in the global
      namespace; did you mean '__signbit'?
using ::signbit;
      ~~^
/usr/include/bits/mathcalls-helper-functions.h:25:20: note: '__signbit' declared here
__MATHDECL_1 (int, __signbit,, (_Mdouble_ __value))

据我所知,这是由于路径中早先包含的仅限 C 语言的 math.h 为 libc++ math.h 。有谁知道如何解决这个问题?

实际上,我正在尝试找到一种解决方案来构建和链接在使用柯南依赖项和构建要求时无法为 Android 正确构建的 Poco 库(由于 OpenSSL 依赖项的一些构建问题)或 Ubuntu 18.04 上的 android_ndk_installer/r19b@bincrafters/stable。因此,我尝试在不使用 Conan 包的情况下构建 Poco 库和 OpenSSL。

提前感谢您的任何提示或想法!

这是我的 Android 版柯南个人资料:

# --------------------------------------------------------------------------------------------------------------------
# PARAMETERS

    #standalone_toolchain=/home/uname/Android/ndk/android-ndk-r19b/toolchains/llvm/prebuilt/linux-x86_64

    target_host=armv7a-linux-androideabi
    ar_host=arm-linux-androideabi

    api_level=21
    cc_compiler=clang
    cxx_compiler=clang++

# --------------------------------------------------------------------------------------------------------------------

[settings]

    os_build=Linux
    arch_build=x86_64

    compiler=clang
    compiler.version=7.0
    compiler.libcxx=libc++
    os=Android
    os.api_level=$api_level
    arch=armv7

    #Debug/Release
    build_type=Debug

# --------------------------------------------------------------------------------------------------------------------

[build_requires]

    android-ndk/r18@theodelrieu/testing
    #android_ndk_installer/r19b@bincrafters/stable

# --------------------------------------------------------------------------------------------------------------------

[options]

    *:shared=False
    #Poco:no_asm=True

# --------------------------------------------------------------------------------------------------------------------

[env]

    CONAN_CMAKE_FIND_ROOT_PATH=$standalone_toolchain/sysroot
    PATH=[$standalone_toolchain/bin]
    CHOST=$target_host

    # Flags can be also appended after the path to the compiler
    CC=$target_host$api_level-$cc_compiler
    CXX=$target_host$api_level-$cxx_compiler

    CMAKE_C_COMPILER=$CC
    CMAKE_CXX_COMPILER=$CXX

    AR=$ar_host-ar
    AS=$ar_host-as

    RANLIB=$target_host-ranlib
    LD=$target_host-ld
    STRIP=$target_host-strip
    CFLAGS= -fPIE -fPIC -I$standalone_toolchain/include/c++/4.9.x
    CXXFLAGS= -fPIE -fPIC -I$standalone_toolchain/include/c++/4.9.x
    LDFLAGS= -pie

    export ANDROID_API=$api_level

    OpenSSL:compiler=clang
    OpenSSL:options.no_zlib=True

和根 CMakeLists.txt

cmake_minimum_required(VERSION 3.10)

project(-some-project-)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

## Experimental POCO

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/openssl/include) # Path whererever the openssl-dev headers are present

# When compiling the POCO C++ Libraries for a Android target, as well as when including POCO C++ Libraries headers in a project for a Android target, the preprocessor macro POCO_ANDROID must be defined. This is because the Android NDK GCC compiler does not provide a predefined macro that allows for reliable detection of an Android target.
IF(ANDROID)
SET(POCO_ANDROID)
ENDIF()

SET(ENABLE_ENCODINGS OFF)
SET(ENABLE_ENCODINGS_COMPILER OFF)
SET(ENABLE_XML OFF)
SET(ENABLE_JSON ON)
SET(ENABLE_MONGODB OFF)
SET(ENABLE_REDIS OFF)
SET(ENABLE_PDF OFF)
SET(ENABLE_UTIL OFF)
SET(ENABLE_NET ON)
SET(ENABLE_NETSSL ON)
SET(ENABLE_NETSSL_WIN OFF)
SET(ENABLE_CRYPTO OFF)
SET(ENABLE_DATA OFF)
SET(ENABLE_DATA_SQLITE OFF)
SET(ENABLE_DATA_MYSQL OFF)
SET(ENABLE_DATA_ODBC OFF)
SET(ENABLE_SEVENZIP OFF)
SET(ENABLE_ZIP OFF)
SET(ENABLE_APACHECONNECTOR OFF)
SET(ENABLE_CPPPARSER OFF)
SET(ENABLE_POCODOC OFF)
SET(ENABLE_PAGECOMPILER OFF)
SET(ENABLE_PAGECOMPILER_FILE2PAGE OFF)

SET(FORCE_OPENSSL OFF)      # Force usage of OpenSSL even under windows
SET(ENABLE_TESTS OFF)       # Set to OFF|ON (default is OFF) to control build of POCO tests & samples
SET(POCO_STATIC ON)         # Set to OFF|ON (default is OFF) to control build of POCO as STATIC library
SET(POCO_UNBUNDLED OFF)     # Set to OFF|ON (default is OFF) to control linking dependencies as external

SET(POCO_BUILD_TYPE "Release")

add_subdirectory(thirdparty/poco)

#SET(OPENSSL_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/openssl")

## \Experimental POCO

add_subdirectory(src)

IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_subdirectory(test)
ENDIF()

PS:我是否使用了正确的方法,还是应该尝试以不同的方式包含和构建 Poco 库和 OpenSSL for Android?主要目标是 Android 和 iOS 设备以及用于开发和测试的本地 macOS 或 Linux。

【问题讨论】:

    标签: android c++ cmake poco-libraries conan


    【解决方案1】:

    虽然这个问题还没有通过上面公开的方式解决,但我发现它可以通过以下组合与柯南包一起使用:

    conanfile.py:

    requires = "OpenSSL/1.0.2r@conan/stable", "Poco/1.9.0@pocoproject/stable"
    

    ~/.conan/profiles/android

    # ------------------------------------------------------------------------------
    # PARAMETERS
    
        target_host=armv7a-linux-androideabi
        ar_host=arm-linux-androideabi
    
        api_level=21
        cc_compiler=clang
        cxx_compiler=clang++
    
    # ------------------------------------------------------------------------------
    
    [settings]
    
        os_build=Linux
        arch_build=x86_64
    
        compiler=clang
        compiler.version=8
        compiler.libcxx=libc++
        os=Android
        os.api_level=$api_level
        arch=armv7
    
        build_type=Release
    
    # ------------------------------------------------------------------------------
    
    [build_requires]
    
        android_ndk_installer/r19b@bincrafters/stable
    
    # ------------------------------------------------------------------------------
    
    [options]
    
        OpenSSL:shared=False
    
        OpenSSL:no_threads=False
        OpenSSL:no_zlib=False
        OpenSSL:no_asm=True
        OpenSSL:386=False
        OpenSSL:no_sse2=False
        OpenSSL:no_bf=False
        OpenSSL:no_cast=False
        OpenSSL:no_des=False
        OpenSSL:no_dh=False
        OpenSSL:no_cast=False
        OpenSSL:no_dsa=False
        OpenSSL:no_hmac=False
        OpenSSL:no_md2=False
        OpenSSL:no_md5=False
        OpenSSL:no_rc2=False
        OpenSSL:no_rc4=False
        OpenSSL:no_rc5=False
        OpenSSL:no_rsa=False
        OpenSSL:no_sha=False
    
        Poco:shared=False
    
        Poco:enable_tests=False
        Poco:cxx_14=True
        Poco:force_openssl=True
    
        Poco:enable_xml=True
        Poco:enable_json=True
        Poco:enable_mongodb=False
        Poco:enable_pdf=False
        Poco:enable_util=True
        Poco:enable_net=True
        Poco:enable_netssl=True
        Poco:enable_netssl_win=False
        Poco:enable_crypto=True
        Poco:enable_data=False
        Poco:enable_data_sqlite=False
        Poco:enable_data_mysql=False
        Poco:enable_data_odbc=False
        Poco:enable_sevenzip=False
        Poco:enable_zip=True
        Poco:enable_sevenzip=True
        Poco:enable_apacheconnector=False
        Poco:enable_cppparser=True
        Poco:enable_pocodoc=False
        Poco:enable_pagecompiler=False
        Poco:enable_pagecompiler_file2page=False
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多