参考:https://blog.csdn.net/wo_Niu123/article/details/80433473
特别注意:--with-protoc的配置()
如果有:rc/google/protobuf/stubs/common.cc文件,发现是找不到HAVE_PTHREAD宏定义导致找不到pthread库,本文解决办法就是在该文件加上该句宏定义(临时解决,有其他更好的方法欢迎告知探讨)#define HAVE_PTHREAD
1、x86 ./autogen.sh
2、source 交叉编译环境
3、./configure --host=arm-linux --prefix=/home/gg/Documents/protobuf-master/bin --with-protoc=protoc \
CC=/opt/fsl-imx-fb/4.1.15-2.1.0/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gcc \
CXX=/opt/fsl-imx-fb/4.1.15-2.1.0/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++
4、make
备注:
#!/bin/bash
cd $(dirname $0)
mkdir -p $TARGET_PRODUCT_OUT/build/protobuf
PWD=`pwd`
export CFLAG=$CONFIGURE_FLAGS
./autogen.sh
./configure $CONFIGURE_FLAGS\
--host=arm-linux\
--prefix=$TARGET_PRODUCT_OUT\
--with-protoc=/usr/local/bin/protoc
# --disable-protoc --with-protoc=/usr/local/bin/protoc
#--host=arm-linux --with-protoc=protoc
5、test-ok
5.1、autogen.sh
5.2、./configure --host=arm-linux --disable-shared CFLAGS="-fPIC -fvisibility=hidden" CXXFLAGS="-fPIC -fvisibility=hidden" CC=/media/ggl/fe7ba78a-6725-4cfb-8104-55950209e8272/home/ggl/opt/arm-liunx-gcc49/bin/arm-linux-gnueabi-gcc CXX=/media/ggl/fe7ba78a-6725-4cfb-8104-55950209e8272/home/ggl/opt/arm-liunx-gcc49/bin/arm-linux-gnueabi-g++ --prefix=$PWD/install
5.3 make -j4
6、
. /media/ggl/fe7ba78a-6725-4cfb-8104-55950209e8272/home/ggl/opt/arm-liunx-gcc49
cmake .. -DGFLAGS_NAMESPACE=gflags -DCMAKE_CXX_FLAGS=-fPIC -DBUILD_SHARED_LIBS=ON -DCMAKE_C_COMPILER=arm-linux-gnueabi-gcc -DCMAKE_CXX_COMPILER=arm-linux-gnueabi-g++
7、
# This is required. target system name
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_PROCESSOR arm)
# specify the cross compiler
SET(TOOLCHAIN_PATH /media/ggl/fe7ba78a-6725-4cfb-8104-55950209e8272/home/ggl/opt/arm-liunx-gcc49)
SET(CMAKE_SYSROOT ${TOOLCHAIN_PATH}/arm-linux-gnueabi)
SET(CMAKE_C_COMPILER ${TOOLCHAIN_PATH}/bin/arm-linux-gnueabi-gcc)
SET(CMAKE_CXX_COMPILER ${TOOLCHAIN_PATH}/bin/arm-linux-gnueabi-g++)
# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
网友评论