I'm using an ESP32 and a sensor which is connected via I2C. For a better code structure, I wrote a component "mySensor" which handles the I2C stuff and implements the logic. Some methods are
Code: Select all
initialize_i2c
Code: Select all
start_reading
The project structure looks like this:
-Project
--components
---mySensor
----mySensor.c
----mySensor.h
----component.mk
--main
---main.c
---component.mk
In main.c I included the component with
Code: Select all
#include "../components/mySensor/mySensor.h"
Code: Select all
initialize_i2c
Code: Select all
LD build/sensorboard.elf
C:/workspace/Project/build/main\libmain.a(main.o):(.literal.app_main+0x28): undefined reference to `initialize_i2c'
C:/workspace/Project/build/main\libmain.a(main.o):(.literal.app_main+0x2c): undefined reference to `start_reading'
C:/workspace/Project/build/main\libmain.a(main.o): In function `app_main':
C:/workspace/Project/main/main.c:68: undefined reference to `initialize_i2c'
C:/workspace/Project/main/main.c:69: undefined reference to `start_reading'
Code: Select all
main/component.mk
Code: Select all
COMPONENT_ADD_LDFLAGS:=-L$(PROJECT_PATH)/build/mySensor/libmySensor.a
Code: Select all
LD build/sensorboard.elf
C:/workspace/Project/build/esp32\libesp32.a(cpu_start.o):(.literal.main_task+0x20): undefined reference to `app_main'
C:/workspace/Project/build/esp32\libesp32.a(cpu_start.o): In function `main_task':
C:/msys32/home/esp/esp-idf/components/esp32/cpu_start.c:463: undefined reference to `app_main'
Thanks!