交叉编译代码与boost给出编译错误

时间:2014-11-16 18:22:09

标签: c++11 boost android-ndk

{Ubuntu 14.04 64 bits, arm-g++ compiler 4.9谷歌&nbspk r10c附带的一个

(我已经为平台android-14制作了一个独立的工具链,而--sysroot指向了那个。还将标志-march=armv7-a传递给编译器)

使用arm交叉编译器来编译boost我在socket_ops.ipp中得到以下错误:

对于此类型的所有函数(模板),

<1>

template <typename SockLenType>
inline int call_getsockname(SockLenType msghdr::*, 
    socket_type s, socket_addr_type* addr, std::size_t* addrlen) 
{ 
  SockLenType tmp_addrlen = (SockLenType)*addrlen; 
  int result = ::getsockname(s, addr, &tmp_addrlen); 
  *addrlen = (std::size_t)tmp_addrlen; 
  return result; 
} 

/some-path/thirdparty/boost/boost_1_55_0_Android/boost/asio/detail/impl/socket_ops.ipp:1639: error: invalid conversion from 'int*' to 'socklen_t* {aka unsigned int*}' [-fpermissive] 
   int result = ::getsockname(s, addr, &tmp_addrlen); 


                                              ^ 

将行更改为:

int result = ::getsockname(s, addr, (socklen_t*)tmp_addrlen);

它汇编了很好的课程,但我不知道这是不是要做什么。

<2>以及mapped_region.hpp

/some-path/thirdparty/boost/boost_1_55_0_Android/boost/interprocess/mapped_region.hpp:49: error: sys/shm.h: No such file or directory 
 #      include <sys/shm.h>      //System V shared memory...
                                                        ^ 

并指出:

#    if defined(BOOST_INTERPROCESS_XSI_SHARED_MEMORY_OBJECTS) 
#      include <sys/shm.h>      //System V shared memory... 
#    endif 

在该文件中。

以下是我的user-config.jam文件中的标志:

using gcc : android 
: 
@AndroidNDKSrcDir@/bin/arm-linux-androideabi-g++ 
: 
<archiver>@AndroidNDKSrcDir@/bin/arm-linux-androideabi-ar 
<compileflags>-fexceptions 
<compileflags>-frtti 
<compileflags>-fPIC 
<compileflags>-std=c++11 
<compileflags>-ffunction-sections 
<compileflags>-funwind-tables 
<compileflags>-D__ARM_ARCH_5__ 
<compileflags>-D__ARM_ARCH_5T__ 
<compileflags>-D__ARM_ARCH_5E__ 
<compileflags>-D__ARM_ARCH_5TE__ 
<compileflags>-Wno-psabi 
<compileflags>-march=armv5te 
<compileflags>-mtune=xscale 
<compileflags>-msoft-float 
<compileflags>-mthumb 
<compileflags>-Os 
<compileflags>-fomit-frame-pointer 
<compileflags>-fno-strict-aliasing 
<compileflags>-finline-limit=64 
<compileflags>-I@AndroidNDKSrcDir@/include/c++/4.9 
<compileflags>-Wa,--noexecstack 
<compileflags>-DANDROID 
<compileflags>-D__ANDROID__ 
<compileflags>-DNDEBUG 
<compileflags>-O2 
<compileflags>-g 
<compileflags>-I@AndroidNDKSrcDir@/sysroot/usr/include 
<architecture>arm 
<compileflags>-fvisibility=hidden 
<compileflags>-fvisibility-inlines-hidden 
<compileflags>-fdata-sections 
<cxxflags>-D__arm__ 
<cxxflags>-D_REENTRANT 
<cxxflags>-D_GLIBCXX__PTHREADS 
; 

这两个错误的前进方向是什么 - &lt; 1&gt; &lt; 2&gt; ?升级(asio等)Android是否已准备好使用c ++ 11功能?

1 个答案:

答案 0 :(得分:0)

&lt; 1&gt; 您有不兼容的<sys/socket.h><socket_ops.ipp> - 无论出于何种原因。您建议的“修复”将编译,但在运行时崩溃。以下是最适合您的最简单修复:

int tmp_addrlen = (int)*addrlen; 
int result = ::getsockname(s, addr, &tmp_addrlen); 

在Android上,LP64,这样的演员阵容不安全,但为了善良,没有人会使用超过2 ^ 32的addrlen。

相关问题