使用适用于Android的Conan配置文件构建Poco C ++库

问题描述 投票:0回答:1

我正在尝试在项目中使用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 beeing包含在前面的路径中作为libc ++ math.h。有谁知道如何解决这个问题?

实际上我正在尝试找到一个解决方案来构建和链接Poco库,这些库不能正确构建Android(由于OpenSSL依赖的一些构建问题),当使用Conan依赖项和构建要求android-ndk / r18 @ theodelrieu / testing或android_ndk_installer / r19b @ bincrafters / stable on Ubuntu 18.04。因此,我试图在不使用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个回答
0
投票

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

Conan file.朋友:

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

〜/ .conan /型材/安卓

# ------------------------------------------------------------------------------
# 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
© www.soinside.com 2019 - 2024. All rights reserved.