BSEC 库 Arduino 的问题

Issues with BSEC Library Arduino

我只想让库在 Arduino IDE 1.8.13 中工作。但是,它总是无法编译。 我已经调整了 platform.txt,但是它没有做任何事情。我已经从 github (https://github.com/BoschSensortec/BSEC-Arduino-library) 下载了库。 用 ESP32 开发板编译时总是返回同样的错误。 我的错误在哪里?

调试代码如下:

libraries/BSEC_Software_Library/BSEC_Software_Library.a(bsec.cpp.o):(.literal._ZN4Bsec11beginCommonEv+0x4): undefined reference to `bsec_init'
libraries/BSEC_Software_Library/BSEC_Software_Library.a(bsec.cpp.o):(.literal._ZN4Bsec11beginCommonEv+0x8): undefined reference to `bsec_get_version'
libraries/BSEC_Software_Library/BSEC_Software_Library.a(bsec.cpp.o):(.literal._ZN4Bsec18updateSubscriptionEP21bsec_virtual_sensor_thf+0x0): undefined reference to `bsec_update_subscription'
libraries/BSEC_Software_Library/BSEC_Software_Library.a(bsec.cpp.o):(.literal._ZN4Bsec8setStateEPh+0x10): undefined reference to `bsec_set_state'
libraries/BSEC_Software_Library/BSEC_Software_Library.a(bsec.cpp.o):(.literal._ZN4Bsec15readProcessDataEx19bsec_bme_settings_t+0x14): undefined reference to `bsec_do_steps'
libraries/BSEC_Software_Library/BSEC_Software_Library.a(bsec.cpp.o):(.literal._ZN4Bsec3runEx+0x0): undefined reference to `bsec_sensor_control'
libraries/BSEC_Software_Library/BSEC_Software_Library.a(bsec.cpp.o):(.literal._ZN4Bsec3runEx+0x4): undefined reference to `bsec_get_state'
libraries/BSEC_Software_Library/BSEC_Software_Library.a(bsec.cpp.o): In function `Bsec::beginCommon()':
/Users/Service/Documents/Arduino/libraries/BSEC_Software_Library/src/bsec.cpp:476: undefined reference to `bsec_init'
libraries/BSEC_Software_Library/BSEC_Software_Library.a(bsec.cpp.o): In function `Bsec::getVersion()':
/Users/Service/Documents/Arduino/libraries/BSEC_Software_Library/src/bsec.cpp:476: undefined reference to `bsec_get_version'
libraries/BSEC_Software_Library/BSEC_Software_Library.a(bsec.cpp.o): In function `Bsec::updateSubscription(bsec_virtual_sensor_t*, unsigned char, float)':
/Users/Service/Documents/Arduino/libraries/BSEC_Software_Library/src/bsec.cpp:476: undefined reference to `bsec_update_subscription'
libraries/BSEC_Software_Library/BSEC_Software_Library.a(bsec.cpp.o): In function `Bsec::setState(unsigned char*)':
/Users/Service/Documents/Arduino/libraries/BSEC_Software_Library/src/bsec.cpp:476: undefined reference to `bsec_set_state'
libraries/BSEC_Software_Library/BSEC_Software_Library.a(bsec.cpp.o): In function `Bsec::readProcessData(long long, bsec_bme_settings_t)':
/Users/Service/Documents/Arduino/libraries/BSEC_Software_Library/src/bsec.cpp:385: undefined reference to `bsec_do_steps'
libraries/BSEC_Software_Library/BSEC_Software_Library.a(bsec.cpp.o): In function `Bsec::run(long long)':
/Users/Service/Documents/Arduino/libraries/BSEC_Software_Library/src/bsec.cpp:200: undefined reference to `bsec_init'
/Users/Service/Documents/Arduino/libraries/BSEC_Software_Library/src/bsec.cpp:210: undefined reference to `bsec_update_subscription'
/Users/Service/Documents/Arduino/libraries/BSEC_Software_Library/src/bsec.cpp:210: undefined reference to `bsec_sensor_control'
/Users/Service/Documents/Arduino/libraries/BSEC_Software_Library/src/bsec.cpp:246: undefined reference to `bsec_get_state'
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board DOIT ESP32 DEVKIT V1.

谢谢

如果您对 platform.txt 文件进行正确修改,Arduino IDE 1.8.13 将找到该库。我的文件位于此处:

C:\Users\(username)\AppData\Local\Arduino15\packages\esp32\hardware\esp32.0.6\platform.txt

首先确保您的 platform.txt 文件中有一般更改。也就是说,您定义了 compiler.libraries.ldflags。我的 platform.txt 已经将其定义为空,compiler.libraries.ldflags=。如果您的尚未定义,请将该行添加到 platform.txt 文件中的某处。

接下来,你要引用它。您可以按照 ESP8266 的说明进行操作。更改以下内容:

recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} {compiler.libraries.ldflags} -Wl,--start-group {object_files} "{archive_file_path}" {compiler.c.elf.libs} {build.extra_libs} -Wl,--end-group -Wl,-EL -o "{build.path}/{build.project_name}.elf"

为此:

recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} {compiler.libraries.ldflags} -Wl,--start-group {object_files} "{archive_file_path}" {compiler.c.elf.libs} {compiler.libraries.ldflags} {build.extra_libs} -Wl,--end-group -Wl,-EL -o "{build.path}/{build.project_name}.elf"

注意最后一次出现 compiler.libraries.ldflags。我上面显示的文本与 github 文档中显示的文本不完全匹配。我只是在 --start-group 指令之后添加了 compiler.libraries.ldflags,这就是 github 文档显示的内容。

一旦我这样做,保存文件,并重新启动 Arduino,它全部编译和链接成功。