链接错误:在PlatformIO中找不到-lrdkafka预编译的动态库

时间:2022-09-18 12:34:39

I'm trying to get Kafka working on an Esp32 using PlatformIO.

我正在尝试使用PlatformIO让Kafka在Esp32上工作。

I tried to link a C library to a project built in PlatformIO using build flags expressed in my platformio.ini file. I am using the librdkafka library. The location of the librdkafka.so file is in /usr/local/lib but whenever I build my project with the linked library in plaformio I get the following error:

我尝试使用我的platformio.ini文件中表示的构建标记将C库链接到PlatformIO中构建的项目。我正在使用librdkafka库。 librdkafka.so文件的位置在/ usr / local / lib中,但每当我在plaformio中使用链接库构建项目时,我都会收到以下错误:

platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa-esp32-elf/5.2.0
/../../../../xtensa-esp32-elf/bin/ld: cannot find -lrdkafka

platformio.ini file:

platformio.ini文件:

[env:featheresp32]
platform = espressif32
board = featheresp32
framework = espidf
build_flags =
   -L/usr/local/lib
   -I/usr/local/include/librdkafka
   -lrdkafka

Outside of PlatformIO, I successfully linked librdkafka to the main.c project file using the following command: gcc main.c -L/usr/local/lib -l:librdkafka.so -lz -lpthread -lrt -I/usr/local/include/librdkafka

在PlatformIO之外,我使用以下命令成功地将librdkafka链接到main.c项目文件:gcc main.c -L / usr / local / lib -l:librdkafka.so -lz -lpthread -lrt -I / usr / local /有/ librdkafka

1 个解决方案

#1


1  

You're trying to link the Kafka library that's built for your system with your ESP32 program.

您正在尝试将为您的系统构建的Kafka库与您的ESP32程序相关联。

There's absolutely no way this can work. They're two different architectures. Your system that you're running platformio is most likely an Intel processor, so anything in /usr/local/lib is built for that, not for an ESP32.

这绝对没有办法。它们是两种不同的架构。您运行platformio的系统很可能是Intel处理器,因此/ usr / local / lib中的任何内容都是为此而构建的,而不是ESP32。

You're probably running on Linux, so that Kafka library is built for Linux. The ESP32 doesn't run Linux. So there's no way that Kafka library could possibly run on the ESP32, even if it were compiled for it, which it's not.

您可能正在Linux上运行,因此Kafka库是为Linux构建的。 ESP32不运行Linux。因此,Kafka库无法在ESP32上运行,即使它是为它编译的,但事实并非如此。

Kafka is not designed to run on an ESP32. If you want your ESP32 to interact with a Kafka system you'll need to find a client that's compatible with Kafka that's designed to run on an ESP32. librdkafka is not in any way ESP32-compatible.

Kafka不适合在ESP32上运行。如果您希望ESP32与Kafka系统进行交互,您需要找到一个与Kafka兼容的客户端,该客户端可以在ESP32上运行。 librdkafka与ESP32不兼容。

#1


1  

You're trying to link the Kafka library that's built for your system with your ESP32 program.

您正在尝试将为您的系统构建的Kafka库与您的ESP32程序相关联。

There's absolutely no way this can work. They're two different architectures. Your system that you're running platformio is most likely an Intel processor, so anything in /usr/local/lib is built for that, not for an ESP32.

这绝对没有办法。它们是两种不同的架构。您运行platformio的系统很可能是Intel处理器,因此/ usr / local / lib中的任何内容都是为此而构建的,而不是ESP32。

You're probably running on Linux, so that Kafka library is built for Linux. The ESP32 doesn't run Linux. So there's no way that Kafka library could possibly run on the ESP32, even if it were compiled for it, which it's not.

您可能正在Linux上运行,因此Kafka库是为Linux构建的。 ESP32不运行Linux。因此,Kafka库无法在ESP32上运行,即使它是为它编译的,但事实并非如此。

Kafka is not designed to run on an ESP32. If you want your ESP32 to interact with a Kafka system you'll need to find a client that's compatible with Kafka that's designed to run on an ESP32. librdkafka is not in any way ESP32-compatible.

Kafka不适合在ESP32上运行。如果您希望ESP32与Kafka系统进行交互,您需要找到一个与Kafka兼容的客户端,该客户端可以在ESP32上运行。 librdkafka与ESP32不兼容。