Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 
    SOLVED

    Linking BSEC library to ESP-IDF for BME680

    Linking BSEC library to ESP-IDF for BME680

    Apurva
    Member

    I am using the BME680 with the ESP32-PoE and I want to use the BSEC library to get the IAQ. I have been stuck at the last step of linking the pre-built libalgobsec.a library. This is what my CMakeLists file in my BSEC components folder looks like:

    set(COMPONENT_SRCS "bme680.c"
    "bsec_integration.c")

    set(COMPONENT_ADD_INCLUDEDIRS "include")

    register_component()

    add_library(algobsec STATIC IMPORTED)
    set_property(TARGET algobsec PROPERTY IMPORTED_LOCATION ../lib/libalgobsec.a)

    I have not done the 3 steps for linking as stated in the Integration Guide as I do not know where to find the files to which I need to make changes. I am currently getting this error when I build the project:

    clipboard_image_0.png

    I would really appreciate any help to get the library running. Thank you!

     

    8 REPLIES 8

    handytech
    Community Moderator
    Community Moderator

    Would you be able to share a bit more history from your logs and/or enable verbose logging? This type of error could typically be caused by a missing file or wrong file location, a missing/wrong library path in the linker argument, incorrect argument orders, etc.

    I have uploaded a file containing the logs that are observed when I run build after a fullclean. I think the warnings occur most probably because the the variables are being used in the functions that have undefined reference. I need help with the proper linking of the .a file because I have not been able to find any help online for the ESP32 microcontroller with ESP-IDF.

    handytech
    Community Moderator
    Community Moderator

    Thank-you for sharing the output.

    In your original post, I see that you are including the bsec library to your project:


    @Apurva wrote:
    add_library(algobsec STATIC IMPORTED)
    set_property(TARGET algobsec PROPERTY IMPORTED_LOCATION ../lib/libalgobsec.a)

    But in your build_output.pdf, I cannot find any reference to libalgobsec.a. Is this the expected behavior? Please make sure that the relative path used is correct. I am not familiar with ESP-IDF envrionment, could target_link_libraries([...]) possibly help as well?

    I have tried several variations of commands in that CMakeLists file and for all of them, the build output does not reference libalgobsec.a. I have also tried with target_link_libraries:

    add_library(algobsec STATIC IMPORTED)
    set_property(TARGET algobsec PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/lib/libalgobsec.a)
    target_link_libraries(${CMAKE_CURRENT_SOURCE_DIR}/src PUBLIC algobsec)

     The error that I get is "Cannot specify link libraries for target (component path) which is not built by this project."

    I tried:

    add_library(algobsec STATIC IMPORTED)
    set_property(TARGET algobsec PROPERTY IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/components/BSEC/lib/libalgobsec.a)
    target_link_libraries(${COMPONENT_TARGET} PUBLIC algobsec)

     This gave me an error - FAILED: bme680_test_with_bsec.elf. The CMakeError.log file gives this output:

    Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
    Compiler: C:/Users/Apurva/.espressif/tools/xtensa-esp32-elf/1.22.0-80-g6c4433a5-5.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-g++.exe 
    Build flags: -mlongcalls
    Id flags:  

    The output was:
    1
    c:/users/apurva/.espressif/tools/xtensa-esp32-elf/1.22.0-80-g6c4433a5-5.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: cannot find crt1-sim.o: No such file or directory
    c:/users/apurva/.espressif/tools/xtensa-esp32-elf/1.22.0-80-g6c4433a5-5.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: cannot find _vectors.o: No such file or directory
    c:/users/apurva/.espressif/tools/xtensa-esp32-elf/1.22.0-80-g6c4433a5-5.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: cannot find -lsim
    c:/users/apurva/.espressif/tools/xtensa-esp32-elf/1.22.0-80-g6c4433a5-5.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: cannot find -lhandlers-sim
    c:/users/apurva/.espressif/tools/xtensa-esp32-elf/1.22.0-80-g6c4433a5-5.2.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: cannot find -lhal
    collect2.exeerror: ld returned 1 exit status
    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist