Could not integrate component

lecndav
Posts: 2
Joined: Fri Mar 30, 2018 8:39 am

Could not integrate component

Postby lecndav » Fri Mar 30, 2018 10:23 am

Hi,

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
and

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"
and in app_main I call

Code: Select all

initialize_i2c
After 'make flash' I get this error:

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'
Then I tried to include the libmySensor.a in

Code: Select all

main/component.mk
with

Code: Select all

COMPONENT_ADD_LDFLAGS:=-L$(PROJECT_PATH)/build/mySensor/libmySensor.a
Then i get:

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'
Do I need to include something else?

Thanks!

lecndav
Posts: 2
Joined: Fri Mar 30, 2018 8:39 am

Re: Could not integrate component

Postby lecndav » Tue Apr 03, 2018 11:05 am

solved!

Problem was with a third party library which the component used.
Had to add in component.mk

Code: Select all

COMPONENT_ADD_LDFLAGS := -lmySensor -L$(COMPONENT_PATH)/lib -lsensorLib
COMPONENT_ADD_INCLUDEDIRS := .  lib
COMPONENT_SRCDIRS := . lib

Who is online

Users browsing this forum: Bing [Bot] and 129 guests