简体   繁体   English

谷歌协议缓冲区。 当 protobuf 构建为交叉臂时,“make install”不会生成 so 文件

[英]Google protocol buffers. 'make install' does not generate so files when protobuf building to cross-arm

When I build a protobuff for arm and then install it, I don't see *.so files in the lib/ directory, only *.a and *.la .当我为 arm 构建一个 protobuff 然后安装它时,我在 lib/ 目录中看不到*.so文件,只有*.a*.la If I build it for x86, then everything is fine.如果我为 x86 构建它,那么一切都很好。

The sequence of commands is as follows:命令顺序如下:

sudo ./configure --host=amd64 --build=arm-linux-gnueabihf --target=arm-linux-gnueabihf --enable-shared --prefix=/home/rivand/install/tmp CC=/usr/bin/arm-linux-gnueabihf-gcc CXX=/usr/bin/arm-linux-gnueabihf-g++ 
sudo make -j4
sudo make install

Protobuf: protobuf-cpp-3.14.0 protobuf: protobuf-cpp-3.14.0

OS: Ubuntu 20.04操作系统:Ubuntu 20.04

make and GCC from apt install .apt install makeGCC

You are mixing up --host , --build , and --target .您正在混淆--host--build--target The --host option designates the machine type on which the artifacts you are building will run. --host选项指定您正在构建的工件将在其上运行的机器类型。 The --build option designates the machine type on which you are performing the build, and you do not ordinarily need to specify it, because the build system can guess. --build选项指定您正在执行构建的机器类型,您通常不需要指定它,因为构建系统可以猜测。 In fact, that's the whole purpose of the auxilliary script config.guess , which should be included in the protobuf distribution.事实上,这就是辅助脚本config.guess的全部目的,它应该包含在 protobuf 发行版中。 The --target option applies only when the thing you are building is itself a cross tool; --target选项仅适用于您正在构建的东西本身就是一个交叉工具时; it designates the machine type for binaries that the built tool itself works with.它为构建工具本身使用的二进制文件指定机器类型。

Having set those correctly, you probably do not need to explicitly specify the C and C++ compilers -- configure should figure them out from the host triplet.正确设置这些后,您可能不需要显式指定 C 和 C++ 编译器—— configure应该从主机三元组中找出它们。 (The appearance of the host triplet in the cross tools' names is not a coincidence.) (交叉工具名称中主机三元组的出现并非巧合。)

Additionally, it would be more semantically correct to use DESTDIR at installation time than to use a --prefix at configure time.此外,在安装时使用DESTDIR比在configure时使用--prefix在语义上更正确。 It may make a genuine difference, too, because the specified prefix is sometimes compiled into the built binaries.它也可能产生真正的区别,因为指定的前缀有时会编译到构建的二进制文件中。

Also, as a side note, use sudo only at the install step, not the configuration and build steps.此外,作为旁注,仅在安装步骤使用sudo ,而不是配置和构建步骤。 It's safer that way, and it doesn't leave root-owned debris behind in the build directory.这样更安全,并且不会在构建目录中留下根拥有的碎片。 But you don't need it even then if you're installing into a directory on which you have write privileges, as you appear to be doing in your example commands.但是,即使您要安装到具有写入权限的目录中,您也不需要它,就像您在示例命令中所做的那样。

Thus:因此:

./configure --host=arm-linux-gnueabihf --enable-shared
make -j4
make install DESTDIR=/home/rivand/install/tmp

You will probably get some warnings from libtool at the installation step, recommending additional libtool commands to run when you eventually put the results in place in their true installation location.您可能会在安装步骤从 libtool 收到一些警告,建议您在最终将结果放置在其真实安装位置时运行其他 libtool 命令。 It is usually safe to ignore those on Linux.忽略 Linux 上的那些通常是安全的。

I'm not entirely confident that this will get you shared libraries, because that's in part a function of the project you're building, and in part also a function of the capabilities of your cross toolchain.我不完全相信这会让您共享库,因为这部分是您正在构建的项目的 function,部分也是您的跨工具链功能的 function。 But it will get you properly built tools, and it has a good chance of producing the wanted shared libraries.但它会为您提供正确构建的工具,并且很有可能生成所需的共享库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM