How to include static librarys into esp-idf with eclipse?
Posted: Thu Feb 22, 2018 10:11 pm
Hello,
i have an external library as an .a file that i want to include into my eclipse project. I followed this guide to use esp-idf with eclipse:
https://esp-idf.readthedocs.io/en/v2.0/ ... setup.html
My project structure look like this:
As you can see I have created a separate folder "src" for the external files. Besides my .a file i have also a .h file and a .c file. I have included the directory in the project settings as shown in the figure below:
When I try to build the project, I get the following error message:
Looks like the directory wasn't correctly included. If I put the files in the main folder instead and specify the main folder as an include path, then the files will be linked:
Why does it only work with the main folder? If I compile now, I get the following error messages:
It looks like my .c and .h files have now been linked. But some functions cannot be called because the reference to the .a file is missing. First i try to include the .a file with eclipse. As far as I know this can be done via the project properties:
Properties --> C/C++ Build --> Settings
But here there is no possibility to include files or directories, as you can see in the picture below:
In Properties --> C/C++ build I check "Generate Makefiles Automatically".
After this i went back to Properties --> C/C++ Build --> Settings. Now i can include the .a file:
When I compile now, I get the following error message:
I uncheck "Generate Makefiles Automatically" and tried to find another solution. Next I tried to use the file component. mk in the main folder to include the a. file. I added the following line:
If I compile now, I get a new error message:
I wonder why there are error messages in the libesp32.a file, which is not related to my libalgobsec.a file.
I really have no idea how to correctly integrate the external library. Maybe my understanding of the build process in Eclipse and esp-idf is too poor to solve this problem.
I hope I could explain my problem clearly. Can anyone tell me how to integrate an external library?
i have an external library as an .a file that i want to include into my eclipse project. I followed this guide to use esp-idf with eclipse:
https://esp-idf.readthedocs.io/en/v2.0/ ... setup.html
My project structure look like this:
As you can see I have created a separate folder "src" for the external files. Besides my .a file i have also a .h file and a .c file. I have included the directory in the project settings as shown in the figure below:
When I try to build the project, I get the following error message:
Code: Select all
re
21:13:42 **** Build of configuration Default for project BME680BESEC ****
make flash
CC build/main/main.o
/home/UserName/esp/workspace/BME680BESEC/main/./main.c:21:20: fatal error: bme680.h: No such file or directory
compilation terminated.
/home/UserName/esp/esp-idf/make/component_wrapper.mk:273: die Regel für Ziel „main.o“ scheiterte
/home/UserName/esp/esp-idf/make/project.mk:449: die Regel für Ziel „component-main-build“ scheiterte
make[1]: *** [main.o] Fehler 1
make: *** [component-main-build] Fehler 2
21:13:44 Build Finished (took 1s.473ms)
Why does it only work with the main folder? If I compile now, I get the following error messages:
Code: Select all
21:31:31 **** Build of configuration Default for project BME680BESEC ****
make flash
LD build/app-template.elf
/home/UserName/esp/workspace/BME680BESEC/build/main/libmain.a(bsec_integration.o):(.literal.bme680_bsec_update_subscription+0x0): undefined reference to `bsec_update_subscription'
/home/UserName/esp/workspace/BME680BESEC/build/main/libmain.a(bsec_integration.o):(.literal.bme680_bsec_process_data+0x4): undefined reference to `bsec_do_steps'
/home/UserName/esp/workspace/BME680BESEC/build/main/libmain.a(bsec_integration.o):(.literal.bsec_iot_init+0x0): undefined reference to `bsec_init'
/home/UserName/esp/workspace/BME680BESEC/build/main/libmain.a(bsec_integration.o):(.literal.bsec_iot_init+0x4): undefined reference to `bsec_set_configuration'
/home/UserName/esp/workspace/BME680BESEC/build/main/libmain.a(bsec_integration.o):(.literal.bsec_iot_init+0x8): undefined reference to `bsec_set_state'
/home/UserName/esp/workspace/BME680BESEC/build/main/libmain.a(bsec_integration.o):(.literal.bsec_iot_loop+0x4): undefined reference to `bsec_sensor_control'
/home/UserName/esp/workspace/BME680BESEC/build/main/libmain.a(bsec_integration.o):(.literal.bsec_iot_loop+0x8): undefined reference to `bsec_get_state'
/home/UserName/esp/workspace/BME680BESEC/build/main/libmain.a(bsec_integration.o): In function `bme680_bsec_update_subscription':
/home/UserName/esp/workspace/BME680BESEC/main/./bsec_integration.c:138: undefined reference to `bsec_update_subscription'
/home/UserName/esp/workspace/BME680BESEC/build/main/libmain.a(bsec_integration.o): In function `bme680_bsec_process_data':
/home/UserName/esp/workspace/BME680BESEC/main/./bsec_integration.c:397: undefined reference to `bsec_do_steps'
/home/UserName/esp/workspace/BME680BESEC/build/main/libmain.a(bsec_integration.o): In function `bsec_iot_init':
/home/UserName/esp/workspace/BME680BESEC/main/./bsec_integration.c:180: undefined reference to `bsec_init'
/home/UserName/esp/workspace/BME680BESEC/main/./bsec_integration.c:194: undefined reference to `bsec_set_configuration'
/home/UserName/esp/workspace/BME680BESEC/main/./bsec_integration.c:205: undefined reference to `bsec_set_state'
/home/UserName/esp/workspace/BME680BESEC/build/main/libmain.a(bsec_integration.o): In function `bsec_iot_loop':
/home/UserName/esp/workspace/BME680BESEC/main/./bsec_integration.c:481: undefined reference to `bsec_sensor_control'
/home/UserName/esp/workspace/BME680BESEC/main/./bsec_integration.c:499: undefined reference to `bsec_get_state'
/home/UserName/esp/esp-idf/make/project.mk:387: die Regel für Ziel „/home/UserName/esp/workspace/BME680BESEC/build/app-template.elf“ scheiterte
collect2: error: ld returned 1 exit status
make: *** [/home/UserName/esp/workspace/BME680BESEC/build/app-template.elf] Fehler 1
21:31:36 Build Finished (took 4s.935ms)
Properties --> C/C++ Build --> Settings
But here there is no possibility to include files or directories, as you can see in the picture below:
In Properties --> C/C++ build I check "Generate Makefiles Automatically".
After this i went back to Properties --> C/C++ Build --> Settings. Now i can include the .a file:
When I compile now, I get the following error message:
Code: Select all
21:58:39 **** Build of configuration Default for project BME680BESEC ****
make flash
make: *** No rule to create "flash". End.
Code: Select all
COMPONENT_ADD_LDFLAGS=/home/UserName/esp/workspace/ProjectName/main/libalgobsec.a
Code: Select all
22:03:29 **** Build of configuration Default for project BME680BESEC ****
make flash
CC build/main/bme680.o
CC build/main/bsec_integration.o
/home/UserName/esp/workspace/BME680BESEC/main/./bsec_integration.c: In function 'bsec_iot_init':
/home/UserName/esp/workspace/BME680BESEC/main/./bsec_integration.c:161:27: warning: unused variable 'bsec_status' [-Wunused-variable]
bsec_library_return_t bsec_status = BSEC_OK;
^
/home/UserName/esp/workspace/BME680BESEC/main/./bsec_integration.c: In function 'bme680_bsec_trigger_measurement':
/home/UserName/esp/workspace/BME680BESEC/main/./bsec_integration.c:237:12: warning: variable 'bme680_status' set but not used [-Wunused-but-set-variable]
int8_t bme680_status = BME680_OK;
^
/home/UserName/esp/workspace/BME680BESEC/main/./bsec_integration.c: In function 'bme680_bsec_read_data':
/home/UserName/esp/workspace/BME680BESEC/main/./bsec_integration.c:297:12: warning: variable 'bme680_status' set but not used [-Wunused-but-set-variable]
int8_t bme680_status = BME680_OK;
^
CC build/main/main.o
AR build/main/libmain.a
LD build/app-template.elf
/home/UserName/esp/workspace/BME680BESEC/build/esp32/libesp32.a(cpu_start.o):(.literal.main_task+0x18): undefined reference to `app_main'
/home/UserName/esp/workspace/BME680BESEC/build/esp32/libesp32.a(cpu_start.o): In function `main_task':
/home/UserName/esp/esp-idf/components/esp32/./cpu_start.c:445: undefined reference to `app_main'
/home/UserName/esp/esp-idf/make/project.mk:387: die Regel für Ziel „/home/UserName/esp/workspace/BME680BESEC/build/app-template.elf“ scheiterte
collect2: error: ld returned 1 exit status
make: *** [/home/UserName/esp/workspace/BME680BESEC/build/app-template.elf] Fehler 1
22:03:33 Build Finished (took 3s.862ms)
I really have no idea how to correctly integrate the external library. Maybe my understanding of the build process in Eclipse and esp-idf is too poor to solve this problem.
I hope I could explain my problem clearly. Can anyone tell me how to integrate an external library?