编译静态google 语言助手(assistant-sdk-cpp)

1、首先编译静态openssl 、alsa-lib和zlib 静态库

编译静态openssl

$./config no-dso no-shared CFLAGS=-static CXXFLAGS=-static LDFLAGS=-static

$make

$sudo make install

 

编译静态zlib

$./configure --static

$make

$sudo make install

 

编译静态alsa-lib

$./configure --enable-static=yes --enable-shared=no --with-libdl=no

$ make

$ make install

        

2、修改assistant-sdk-cpp 下的Makefile 文件

 

Note:

warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

solution:

compile glibc with config --enable-static-nss

and link program with compiled glibc (-L path/to/build/glic)

https://stackoverflow.com/questions/3430400/linux-static-linking-is-dead

‘--enable-static-nss’

Compile static versions of the NSS (Name Service Switch) libraries. This is not recommended because it defeats the purpose of NSS; a program linked statically with the NSS libraries cannot be dynamically reconfigured to use a different name database.

 

https://sourceware.org/glibc/wiki/FAQ

Even statically linked programs need some shared libraries which is not acceptable for me. What can I do?

NSS (for details just type `info libc "Name Service Switch"') won't work properly without shared libraries. NSS allows using different services (e.g. NIS, files, db, hesiod) by just changing one configuration file (/etc/nsswitch.conf) without relinking any programs. The only disadvantage is that now static libraries need to access shared libraries. This is handled transparently by the GNU C library.

A solution is to configure glibc with --enable-static-nss. In this case you can create a static binary that will use only the services dns and files (change /etc/nsswitch.conf for this). You need to link explicitly against all these services. For example:

 

  gcc -static test-netdb.c -o test-netdb \
    -Wl,--start-group -lc -lnss_files -lnss_dns -lresolv -Wl,--end-group

The problem with this approach is that you've got to link every static program that uses NSS routines with all those libraries.

In fact, one cannot say anymore that a libc compiled with this option is using NSS. There is no switch anymore. Therefore it is highly recommended not to use --enable-static-nss since this makes the behaviour of the programs on the system inconsistent

 

使用不同版本的gRPC 编译语言助手的步骤:

1、删除安装的gRPC 

$sudo rm /usr/local/bin/protoc
$sudo rm -fr /usr/local/lib/

删除protocbuf 相关的文件,这样便于grpc时会自动重新编译protocbuf.

$sudo rm -fr /usr/local/lib/pkgconfig/protobuf*

 

2、重新编译安装gRPC 和 protoc

3、重新编译googleapis

(参考 assistant-sdk-cpp 下的README.md)

$git clone https://github.com/googleapis/googleapis.git
$git checkout 980cdfa

)

$cd googleapis
$make LANGUAGE=cpp

4、重新编译assistant-sdk-cpp


 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值