QT IED 开发 and protobuf 编译

12 篇文章 0 订阅
11 篇文章 0 订阅

QT5.10.0

sudo apt-get install libgl1-mesa-dev
sudo apt-get install libffi-dev
sudo apt-get install autoconf automake libtool curl make g++ unzip
protobuf 3.6.1
curl 7.53.0
openssl 1.1.0g
sudo apt install openssl
sudo apt install libssh2-1-dev
sudo apt install libssl-dev

protobuf

$ sudo apt-get install autoconf automake libtool curl make g++ unzip
下载 protobuf3.6.1 release
$ cd protobuf
$ git submodule update --init --recursive
$ ./autogen.sh

$ ./configure
$ make
$ sudo make install
$ sudo ldconfig # refresh shared library cache.

交叉编译树梅派
./configure --host=arm-linux-gnueabihf CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ --prefix=/home/konyun/raspberrypi/protobuf

在Linux上编译google protobuff时,configure 默认选项是生成动态库,即libprotobuf.so文件。如果同时在多个动态库(动态库以dlopen方式动态加载)中使用同一buff结构,则运行时会报错误:

ibprotobuf ERROR google/protobuf/descriptor_database.cc:57] File already exists in database: foo/foo.proto libprotobuf FATAL google/protobuf/descriptor.cc:862] CHECK failed: generated_database_->Add(encoded_file_descriptor, size): terminate called after throwing an instance of ‘google::protobuf::FatalException’ what(): CHECK failed: generated_database_->Add(encoded_file_descriptor, size):

为了解决这个问题,google protobuff,则不能以动态库的形式调用,改用静态库的形式在编译时加载。
编译google protobuff时,在configure 时加上选项:

configrue --disable-shared

即可编译成静态库:libprotobuf.a 但是默认的configure文件中,在编译时未加-fPIC ,导致在引用静态库的工程中编译链接时报错误:

libs/assert.o: relocation R_X86_64_32 against `a local symbol’ can not be used when making a shared object; recompile with -fPIC .libs/assert.o: could not read symbols: Bad value

解决该问题,需要重新编译google protobuff库,并添加编译选项:-fPIC

以文本形式打开google buff代码目录下的configure文件,在把第2575至2578行修改为如下:

if test “x a c c v e n v C F L A G S s e t " = " x " ; t h e n : C F L A G S = " − f P I C " f i i f t e s t " x {ac_cv_env_CFLAGS_set}" = "x"; then : CFLAGS="-fPIC" fi if test "x accvenvCFLAGSset"="x";then:CFLAGS="fPIC"fiiftest"x{ac_cv_env_CXXFLAGS_set}” = “x”; then : CXXFLAGS="-fPIC"

curl 7.53.0
$ make
$ sudo make install
$ sudo ldconfig # refresh shared library cache.

交叉编译树梅派
./configure --host=arm-linux-gnueabihf CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ --with-ssl --enable-shared --enable-static --disable-dict --disable-ftp --disable-imap --disable-ldap --disable-ldaps --disable-pop3 --disable-proxy --disable-rtsp --disable-smtp --disable-telnet --disable-tftp --disable-zlib --without-ca-bundle --without-gnutls --without-libidn --without-librtmp --without-libssh2 --without-nss --without-zlib

zlib的命令安装就三条,依次输入执行,简单粗暴:

sudo apt-get install ruby
sudo apt-get install zlib1g
sudo apt-get install zlib1g.dev

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值