Hello,
I m using the amazon-freertos v2021912 repository. There I want to link my prebuild library (libalgobsec.a ) which is in the /aws_demos/application_code/ directory.
I m using the xtensa-esp32-elf-gcc8_4_0-esp-2020r3 toolchain and esp32 dev kit,
I link the library in one of my custom repo where I m using amazon-freertos as an external library. There I know which CMake file is responsible for the build.
So, I added two lines to link the library.
# Declaring the precompiled BSEC lib as imported global so that it doesn't need to be recompiled
add_library(bme680lib STATIC IMPORTED GLOBAL)
set_target_properties(bme680lib PROPERTIES IMPORTED_LOCATION "${PROJECT_SOURCE_DIR}/components/bme680/algo/normal_version/bin/esp/esp32/libalgobsec.a")
# For some reason, math library from newlib isn't implicitly imported so that needs to be manually
# done for now. You might be able to get rid of the hack at some point
add_library(mathlib STATIC IMPORTED GLOBAL)
set_target_properties(mathlib PROPERTIES IMPORTED_LOCATION "${PROJECT_SOURCE_DIR}/amazon-freertos/vendors/espressif/esp-idf/components/newlib/lib/libm.a")
target_link_libraries(afr_workshop
PRIVATE
bme680lib
mathlib
)
Hi. I’m not following what you’re saying very well. I am aware of this repo which shows an ESP32 cmake project using amazon freertos as an external library: GitHub - shubhamkulkarni97/amazon-freertos-examples at feature/idf_v4.2 . I hope that helps. If not, perhaps you could explain which cmake files you’re modifying and what result you’re expecting.
Hello,
I m was trying to link the bosec bme680 prebuilt library( libalgobsec.a). My all programming files are in the aws_demos/application folder. I was trying to link this pre-build library with the bme680 programming file. My prebuild library directory is aws_demos/application_code/bme680/algo/normal_version/bin/esp/esp32 and I m using the esp32-devkit. So, my question is how should I link this prebuilt library here?
I tried in one of my repositories where I m using the amazon-freertos as the external library and there I m able to link this prebuilt library.
But I don’t know how to link the pre-built when I m not using the amazon-freertos as the external library.
If your application code is based of amazon freertos repository, then the target is defined in the corresponding vendor’s boards CMakeFile. For example ESP32 target is defined here:
Target name by default is aws_demos. You can link the prebuilt static library to the target using cmake function as follows:
Thanks, @ravibhagavandas for your reply.
I m using the esp32 board.
I tried as per your suggestion.
My prebuilt library is in aws_demos/aplication_code/esp32/libalgobsec.a directory.
any the files which uses the lib is in /application_code/ directory.
I changes the cmake file in /application_code/CmakeList.txt directory.
I add the following lines there
What do you mean by not being able to link the library? Do you get an error? In addition to linking the library, you must also include the directory containing the bsec headers to the target.