安卓移植paho.mqtt.c的那些坑
编译:mkdir build_androidcd build_androidcmake .. -DCMAKE_INSTALL_PREFIX=$PWD/out_android -DPAHO_BUILD_STATIC=TRUE -DCMAKE_C_COMPILER=arm-linux-androideabi-gccmake -j16报错:1、ld: error: cannot find -lpthre
·
编译:
mkdir build_android
cd build_android
cmake .. -DCMAKE_INSTALL_PREFIX=$PWD/out_android -DPAHO_BUILD_STATIC=TRUE -DCMAKE_C_COMPILER=arm-linux-androideabi-gcc -DPAHO_BUILD_SAMPLES=TRUE -DPAHO_WITH_SSL=TRUE -DOPENSSL_ROOT_DIR=/home/liuwei/work/intercom/opensource/openssl/openssl-1.0.2q/out_android -DPAHO_BUILD_DOCUMENTATION=TRUE
make -j16
报错:
1、ld: error: cannot find -lpthread
解决方法:将所有-lpthread替换为-pthread,最好直接将整个工程添加到vscode或其他工具中全部替换,因为要替换的地方很多
2、ld: error: cannot find -lrt
解决方法:安卓4.8的工具链中居然没有librt这个库,从安卓SDK中找到这个库粘贴到交叉编译工具链对应目录即可;
3、WebSocket.c:function WebSocket_receiveFrame: error: undefined reference to 'be64toh'
解决方法:除了这个be64toh找不到,be16toh、be32toh,全部都找不到,去找到交叉编译工具链里面的endian.h中发现,安卓的交叉编译工具链中这个几个宏分别被定义成:betoh16、betoh32、betoh64,将源码中用到be16toh、be32toh、be64toh的地方替换成之前的即可;
更多推荐
所有评论(0)