c++ - 交叉编译Qt to Raspberry Pi 3B+ addressbook (Protocol Buffer) - error symbol lookup error

标签 c++ qt raspberry-pi protocol-buffers

我正在从 Qt (Ubuntu 19.10 - 5.12.3) 交叉编译到 Raspberry Pi 3B+ (stetch)。我已经成功做到了,我能够运行从 Qt 到 Raspberry 的应用程序。

现在我想使用通过 protoc( Protocol Buffer )获得的 .h 和 .cc 文件部署和执行应用程序。

所以首先我在我的笔记本电脑上安装了 Protocol Buffer 3.10.1...我创建了 .h 和 .cc 文件然后在 Qt 中我将它们添加到我的项目中( untitled.pro).

在我用这个配置重复操作之后:

./configure --host=arm-linux CC=/home/belfix/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gcc CXX=/home/belfix/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-g++

通过这种方式,我获得了树莓派所需的 libprotobuf.a... 在 Qt untitled.pro 中,我添加了以下行:

unix:!macx: LIBS += -L$$PWD/../../../usr/local/lib/ -lprotobuf

INCLUDEPATH += $$PWD/../../../usr/local/include
DEPENDPATH += $$PWD/../../../usr/local/include

unix:!macx: PRE_TARGETDEPS += $$PWD/../../../usr/local/lib/libprotobuf.a

程序构建和部署但是......当我按运行时我遇到了这个错误

/home/pi/untitled/bin/untitled: symbol lookup error:/home/pi/untitled/bin/untitled: undefined symbol: _ZN6google8protobuf8internal26fixed_address_empty_stringE

我该如何解决?

在 Raspberry 中我试过:ldd -d -r untitled

linux-vdso.so.1 (0x7ef7d000)
/usr/lib/arm-linux-gnueabihf/libarmmem.so (0x76ee8000)
libprotobuf.so.21 => /usr/local/lib/libprotobuf.so.21 (0x76c9d000)
libQt5Widgets.so.5 => /usr/local/qt5pi/lib/libQt5Widgets.so.5 (0x76770000)
libQt5Gui.so.5 => /usr/local/qt5pi/lib/libQt5Gui.so.5 (0x762b8000)
libQt5Mqtt.so.5 => /usr/local/qt5pi/lib/libQt5Mqtt.so.5 (0x76288000)
libQt5Network.so.5 => /usr/local/qt5pi/lib/libQt5Network.so.5 (0x7610b000)
libQt5Core.so.5 => /usr/local/qt5pi/lib/libQt5Core.so.5 (0x75ba1000)
libGLESv2.so.2 => /usr/lib/arm-linux-gnueabihf/libGLESv2.so.2 (0x75b7c000)
libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0x75b53000)
libstdc++.so.6 => /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 (0x75a0b000)
libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x7598c000)
libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0x7595f000)
libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x75820000)
libz.so.1 => /lib/arm-linux-gnueabihf/libz.so.1 (0x757f9000)
/lib/ld-linux-armhf.so.3 (0x76efe000)
libpng16.so.16 => /usr/lib/arm-linux-gnueabihf/libpng16.so.16 (0x757bf000)
libdouble-conversion.so.1 => /usr/lib/arm-linux-gnueabihf/libdouble-conversion.so.1 (0x7579d000)
libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0x7578a000)
libgthread-2.0.so.0 => /usr/lib/arm-linux-gnueabihf/libgthread-2.0.so.0 (0x75778000)
libglib-2.0.so.0 => /lib/arm-linux-gnueabihf/libglib-2.0.so.0 (0x75670000)
libbrcmEGL.so => /opt/vc/lib/libbrcmEGL.so (0x75637000)
libbcm_host.so => /opt/vc/lib/libbcm_host.so (0x7560e000)
libvchiq_arm.so => /opt/vc/lib/libvchiq_arm.so (0x755f8000)
libvcos.so => /opt/vc/lib/libvcos.so (0x755df000)
librt.so.1 => /lib/arm-linux-gnueabihf/librt.so.1 (0x755c8000)
libpcre.so.3 => /lib/arm-linux-gnueabihf/libpcre.so.3 (0x7554f000)
undefined symbol: _ZN6google8protobuf8internal26fixed_address_empty_stringE (./untitled)
undefined symbol: _ZNK6google8protobuf7Message25InitializationErrorStringEv (./untitled)
undefined symbol: _ZNK6google8protobuf7Message11GetTypeNameEv   (./untitled)
undefined symbol: _ZN6google8protobuf8internal24InlineGreedyStringParserEPSsPKcPNS1_12ParseContextE (./untitled)
undefined symbol: _ZN6google8protobuf2io19EpsCopyOutputStream30WriteStringMaybeAliasedOutlineEjRKSsPh   (./untitled)

最佳答案

尝试将其添加到您的 .pro 文件中。

DEFINES += PROTOBUF_USE_DLLS

实际上您正在链接到动态构建的 PB 库。因此,您需要添加此预处理器定义。如果可以的话,您也可以静态构建 PB。

您可能还想注意 this :

Note for cross-compiling

The makefiles normally invoke the protoc executable that they just built in order to build tests. When cross-compiling, the protoc executable may not be executable on the host machine. In this case, you must build a copy of protoc for the host machine first, then use the --with-protoc option to tell configure to use it instead. For example:

./configure --with-protoc=protoc

This will use the installed protoc (found in your $PATH) instead of trying to execute the one built during the build process. You can also use an executable that hasn't been installed. For example, if you built the protobuf package for your host machine in ../host, you might do:

./configure --with-protoc=../host/src/protoc

Either way, you must make sure that the protoc executable you use has the same version as the protobuf source code you are trying to use it with.

关于c++ - 交叉编译Qt to Raspberry Pi 3B+ addressbook (Protocol Buffer) - error symbol lookup error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58680056/

相关文章:

c++ - 是否有 C++ 方法允许在不创建临时变量的情况下多次使用函数指针?

java - 创建 JAR 文件并在 Raspberry PI 上运行

python - 定义 NDEF 消息

c++ - 如何解决 operator>> 重载错误(不匹配 'operator>>' )

c++ - 使用 .depends 指定 SUBDIRS 项目之间的依赖关系不起作用

c++ - 打印出存储在 vector 中的字符串

c++ - Qt 中的自动排他工具按钮

swift - 我如何从 Raspbian 的源代码编译我自己的 Swift 副本

c++ - 20多种变体的Boost Spirit如何使用?

python - 提升 Python,将 C++ 回调传播到导致段错误的 Python