标签 arm 下的文章

“”

下载交叉编译工具链

wget https://releases.linaro.org/archive/13.04/components/toolchain/binaries/gcc-linaro-arm-linux-gnueabihf-4.7-2013.04-20130415_linux.tar.xz
tar xvf gcc-linaro-arm-linux-gnueabihf-4.7-2013.04-20130415_linux.tar.xz
mv gcc-linaro-arm-linux-gnueabihf-4.7-2013.04-20130415_linux /opt/arm4.7
export PATH=$PATH:/opt/arm4.7/bin
arm-linux-gnueabihf-gcc -v

下载编译ntp源码

curl -O http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-4.2.8p15.tar.gz
tar xvf ntp-4.2.8p15.tar.gz
cd ntp-4.2.8p15/
./configure --prefix=$(pwd)/install --enable-shared --disable-static --with-yielding-select=manual --disable-main --host=arm-linux-gnueabihf
make -j8 && make install
cd install/bin
tree
├── calc_tickadj
├── ntpd
├── ntpdate
├── ntpdc
├── ntp-keygen
├── ntpq
├── ntptime
├── ntptrace
├── ntp-wait
├── sntp
├── tickadj
└── update-leap
file ntpdate 
ntpdate: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 2.6.31, BuildID[sha1]=9328736beb4fb0486437079703193de9cd35042b, with debug_info, not stripped

将ntpdate复制到目标设备上面,运行即可。

./ntpdate time.apple.com

protobuf 交叉编译 for arm

github 地址:https://github.com/protocolbuffers/protobuf

下载最新版3.17.3

wget https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.17.3.zip
mv v3.17.3.zip protobuf-v3.17.3.zip
unzip protobuf-v3.17.3.zip
cd protobuf-3.17.3/
./autogen.sh 
CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ ./configure --prefix=$(pwd)/install --host=arm-linux

会提示没有googletest,可以不用理他。

make && make install

受不了太慢

make -j8 && make install

cd install/lib
tree

.
├── libprotobuf.a
├── libprotobuf.la
├── libprotobuf-lite.a
├── libprotobuf-lite.la
├── libprotobuf-lite.so -> libprotobuf-lite.so.28.0.3
├── libprotobuf-lite.so.28 -> libprotobuf-lite.so.28.0.3
├── libprotobuf-lite.so.28.0.3
├── libprotobuf.so -> libprotobuf.so.28.0.3
├── libprotobuf.so.28 -> libprotobuf.so.28.0.3
├── libprotobuf.so.28.0.3
├── libprotoc.a
├── libprotoc.la
├── libprotoc.so -> libprotoc.so.28.0.3
├── libprotoc.so.28 -> libprotoc.so.28.0.3
├── libprotoc.so.28.0.3
└── pkgconfig

├── protobuf-lite.pc
└── protobuf.pc

1 directory, 17 files

file libprotobuf.so.28.0.3 

libprotobuf.so.28.0.3: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=3dc132b70a58e7012b755b18f076ff625359ef59, with debug_info, not stripped

编译好的头文件与lib文件下载包
protobuf-3.17.3-arm.tar.xz

编译结果

./protoc --version

libprotoc 3.17.3

git clone https://github.com/protocolbuffers/protobuf.git
cd protobuf
git submodule update --init --recursive
mkdir x64
cd x64
../configure --prefix=$(pwd)/install
make
make install

运行编译好的程序

./install/bin/protoc --version

libprotoc 3.17.3
查看所有库文件

tree install/lib/

install/lib/
├── libprotobuf.a
├── libprotobuf.la
├── libprotobuf-lite.a
├── libprotobuf-lite.la
├── libprotobuf-lite.so -> libprotobuf-lite.so.28.0.3
├── libprotobuf-lite.so.28 -> libprotobuf-lite.so.28.0.3
├── libprotobuf-lite.so.28.0.3
├── libprotobuf.so -> libprotobuf.so.28.0.3
├── libprotobuf.so.28 -> libprotobuf.so.28.0.3
├── libprotobuf.so.28.0.3
├── libprotoc.a
├── libprotoc.la
├── libprotoc.so -> libprotoc.so.28.0.3
├── libprotoc.so.28 -> libprotoc.so.28.0.3
├── libprotoc.so.28.0.3
└── pkgconfig

├── protobuf-lite.pc
└── protobuf.pc

编译arm版本protobuf库

cd ../
mkdir arm
cd arm/
CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ ../configure --prefix=$(pwd)/install --host=arm-linux
make -j8
make install
file ./install/bin/protoc 

./install/bin/protoc: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 2.6.32, BuildID[sha1]=cea786b94a0b64b866983c8b4541df34e9cc7c1d, with debug_info, not stripped

protobuf/arm$ tree ./install/lib/

./install/lib/
├── libprotobuf.a
├── libprotobuf.la
├── libprotobuf-lite.a
├── libprotobuf-lite.la
├── libprotobuf-lite.so -> libprotobuf-lite.so.28.0.3
├── libprotobuf-lite.so.28 -> libprotobuf-lite.so.28.0.3
├── libprotobuf-lite.so.28.0.3
├── libprotobuf.so -> libprotobuf.so.28.0.3
├── libprotobuf.so.28 -> libprotobuf.so.28.0.3
├── libprotobuf.so.28.0.3
├── libprotoc.a
├── libprotoc.la
├── libprotoc.so -> libprotoc.so.28.0.3
├── libprotoc.so.28 -> libprotoc.so.28.0.3
├── libprotoc.so.28.0.3
└── pkgconfig

├── protobuf-lite.pc
└── protobuf.pc

使用git 直接git clone github的库,不会报googletest 相关的警告,自动下载好了。如果自己在github.com protobuf release哪儿下载的放在,编译时候会报一个没有googletest的警告。好烦。。

configure: WARNING: no configuration information is in third_party/googletest