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

时间:2019-03-13 21:35:57

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

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

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

如果我使用不依赖于OpenSSL的Poco库构建项目,则可以正常构建。如果我添加Poco的NetSSL,则会遇到一些与math.h相关的问题:

createItemWithAttachments(data:any)
{    
   this.itemService.insert(data.item).subscribe((newItem:Item)=>{       
        //attachment type 1s 
        if(data.attachmentType1.length > 0){    
         this.attachmentService.upload(data.attachmentType1, 
            "type1", newItem.id).subscribe(newAttachment=>{

         });    
    }    

    //attachment type 2s 
    if(data.attachmentType2.length > 0){    
         this.attachmentService.upload(data.attachmentType2, 
             "type2", newItem.id).subscribe(newAttachment=>{    

         });    
    }    
    });    
}

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

实际上,我正在尝试找到一种解决方案,以在使用柯南依赖关系和构建要求时构建和链接无法为Android正确构建的Poco库(由于一些与OpenSSL依赖关系的构建问题),而android-ndk / r18 @ theodelrieu / testing或Ubuntu 18.04上的android_ndk_installer / r19b @ bincrafters / stable。因此,我试图在不使用Conan软件包的情况下构建Poco库并对其进行OpenSSL。

在此先感谢您的提示或想法!

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

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))

和根CMakeLists.txt

# --------------------------------------------------------------------------------------------------------------------
# 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

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

1 个答案:

答案 0 :(得分:0)

虽然上述方法尚未解决此问题,但我发现通过以下组合可将其与柯南软件包一起使用:

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