05-04-2020 06:10 AM
I have a (Arduino Clone) Mega 2560 Board with Seed Grove BME680 Sensor.
I use Arduino CC version 1.8.12
I am running into Linker issues when compiling my sketch(es) using various libraries:
1/. Using Seed Studios Library for the sensor, I find it works OK, but lacks functionality, namely unable to push the sensor to recalibrate, cant set Altitude to get Sea Level compensation for pressure readings, (etc).
2/. Using DFROBOT Library, I find it has the functionality I require, however I run into linker problems :
The linker cannot find bsec_update_subscription and other key functions. These are (only) defined in libalgobsec.a, which appears to be supplied by BSEC in precompiled for to suit various Boards. However DFRobot do not supply (any of) these files. What I find is that the example ino sketches they provide work fine, but when I copy their code into my own sketch, the linker can not. find the function code.
3/. Using the BSEC Library I am unable to compile and link the supplied example sketches.
It finds the Library base : ResolveLibrary(bsec.h)
-> candidates: [BSEC_Software_Library@1.5.1474]
But does not do anything when its time to comp.iole the code:
Compiling libraries...
Compiling library "BSEC_Software_Library"
<should be stuff in here>
Compiling library "Wire"
So, when the linker tries to do its job, there are all sorts of undefined references :
C:\Users\Bryn\AppData\Local\Temp\cclcFARp.ltrans0.ltrans.o: In function `global constructors keyed to 65535_0_basic.ino.cpp.o.2322':
<artificial>:(.text.startup+0x74): undefined reference to `Bsec::Bsec()'
C:\Users\Bryn\AppData\Local\Temp\cclcFARp.ltrans0.ltrans.o: In function `main':
<artificial>:(.text.startup+0x242): undefined reference to `Bsec::delay_ms(unsigned long)'
<artificial>:(.text.startup+0x244): undefined reference to `Bsec::delay_ms(unsigned long)'
<artificial>:(.text.startup+0x250): undefined reference to `Bsec::begin(unsigned char, TwoWire&, void (*)(unsigned long))'
<artificial>:(.text.startup+0x2fa): undefined reference to `Bsec::updateSubscription(bsec_virtual_sensor_t*, unsigned char, float)'
<artificial>:(.text.startup+0x336): undefined reference to `Bsec::run(long long)'
My best guess as to the cause is that the compiler and linker do not like the folder layout supplied in the library.
Can you suggest ways in which I might change the layout and have it compile and link without error ??
Solved! Go to Solution.
05-06-2020 11:13 AM
OK, I have done some further research. I reinstalled the DFRobot Library that I had previously modified, back to the original downloaded from github.
The DFRobot Library includes BME680.h and BME680.c files from BSEC version * @date 30 Oct 2017 * @version 3.5.3
(They are old and that is why I had replaced them with latest BME680 Library files.).
I tried out 2 of the 4 example sketches. There is a basic sketch and a more elaborate sketch that reads IAQ.
The basic sketch compiled OK, but the IAQ sketch did not. Same symptoms as noted previously (linker complaining about missing function code).
I then look through several readme.md files within the folder structure of the library.
Buried in Examnples was a folder 'docs for iaq'. Anyway within that folder a subfolder 'esp8266' and the attached BST pdf file, which is an (old ?) BSEC Imntegration guide dated 2017 for the BME680. I have attached this file. In that PDF, page 14 and 15 refer to the file libgobsec.a and tell the reader how it should be installed to allow the linker to find it.
Now the ESP8266 is just one of many Arduino type processors in the market place. At the time the PDF file was written, (I guess) BSEC chose that processor as the one and only it supported, or maybe they just chose it as an example case in point. Whatever...
It seems that since that time, BSEC have expanded the range of supported processors (as indicated in the current library documentation and library structure). However the current version of the integration guide dated 2019-06-28 I checked and found the exact same text. The text has not been updated to handle the expanded range of processors, and the latest versions of Arduino CC.
The file libgobsec.a is currently not found by the arduino cc compiler/linker within the folder atmega2560 as might be indicated. Maybe the compiler/linker is not working as documented. I'm just guessing. I am not the only one having this trouble, I found other people compaining of the exact same issue over on the Arduino forum.
Whatever the case, I would like you please to share with me instructions pertaining to the atmega2560 allowing me to manually modify the default bsec library and arduino CC installation to put the library in the correct location and modify appropriate files in similar manner to the esp8266 instructions given in the integration guide. I suggest you might also like to trigger an internal review within BSEC of the integration guide and have someone bring it up to date.
05-06-2020 12:26 PM - edited 05-06-2020 01:27 PM
These instructions provide generic guidelines that need to be applied to your specific platform. For the Mega 2560, I just managed to successfully compile the BSEC library's built-in "basic" example in Arduino 1.8.10. The verbose output can help you find the toolchain used, for me the Mega 2560 used the AVR toolchain in Arduino's default installation path. Therefore I added the "compiler.libraries.ldflags" to the platform.txt file I found under "C:\Program Files (x86)\Arduino\hardware\arduino\avr\platform.txt" in my setup.
[...]
# These can be overridden in platform.local.txt
compiler.c.extra_flags=
compiler.c.elf.extra_flags=
compiler.S.extra_flags=
compiler.cpp.extra_flags=
compiler.ar.extra_flags=
compiler.objcopy.eep.extra_flags=
compiler.elf2hex.extra_flags=
compiler.libraries.ldflags=
[...]
## Combine gc-sections, archives, and objects
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mmcu={build.mcu} {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" {compiler.libraries.ldflags} "-L{build.path}" -lm
[...]
05-08-2020 03:38 AM