2014-11-16 152 views
2

{Ubuntu 14.04 64 bits, arm-g++ compiler 4.9一個自帶的谷歌的NDK R 10c中}交叉編譯的代碼與升壓給編譯錯誤

(我做了對Android平臺-14和--sysroot點到一個獨立的工具鏈。同時標誌-march=armv7-a是傳遞到編譯)

使用手臂交叉編譯器編譯提升我得到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); 

它編譯罰款ofcourse,但我不知道這是什麼工作要做。

<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 

在該文件中。

下面是我的用戶config.jam中文件的標誌:

using gcc : android 
: 
@[email protected]/bin/arm-linux-androideabi-g++ 
: 
<archiver>@[email protected]/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>[email protected]@/include/c++/4.9 
<compileflags>-Wa,--noexecstack 
<compileflags>-DANDROID 
<compileflags>-D__ANDROID__ 
<compileflags>-DNDEBUG 
<compileflags>-O2 
<compileflags>-g 
<compileflags>[email protected]@/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 
; 

什麼是前進的方向爲這兩個錯誤 - < 1>< 2>上述?是提升(asio等)Android準備與C++ 11功能?

+0

對於'<1>',無論是否調用'call_getsockname',當第一個參數的類型爲'unsigned'時,都會傳遞一個類型爲int的數據成員指針。爲什麼這甚至是一個模板參數?它總是需要'unsigned'(或者更確切地說,'socklen_t')...或者你的意思是'socklen_t tmp_addrlen =(socklen_t)* addrlen;'而不是,這樣任何整型都可以通過? – ildjarn

+0

_your_代碼如何調用'call_getsockname()'函數? –

+0

@ildjarn'爲什麼這甚至是一個模板參數?'該函數屬於boost本身,我不知道爲什麼它會被模板化。 – ustulation

回答

0

< 1>你有不兼容的<sys/socket.h><socket_ops.ipp> - 無論出於何種原因。您建議的「修復」會編譯,但會在運行時崩潰。這裏是會爲你工作的最簡單的解決辦法:

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

在Android上,這是LP64,這樣的投是不是安全的,但在上帝的份,沒有人會使用addrlen中的超過2^32。