undefined reference

su-Koch
Posts: 11
Joined: Sat Jan 25, 2020 1:43 pm

undefined reference

Postby su-Koch » Mon Mar 30, 2020 8:24 pm

Hei Guys,
I'm a beginner in cmake as I'm working with Visual Studio normally.
I'm trying to set up a project with two components, one inherits from the other.

The Structure of the Tree is attached.
The issue is that I get an error "undefined reference" for the Component I want to inherit from.

CMakeLists.txt are:
I2CKeypad:
idf_component_register(SRCS "I2CKeypad.cpp" INCLUDE_DIRS "." "../I2CPeripheral")

I2CPeripheral:
idf_component_register(SRCS "I2CPeripheral.cpp" INCLUDE_DIRS ".")

main:
idf_component_register(SRCS "main.cpp" INCLUDE_DIRS ".")

project:
cmake_minimum_required(VERSION 3.5)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(i2cKeypad)

I2CPeripheral.h is includes in I2CKeypad.h

Hopefully there is a person out there that knows how to solve this.
Please let me know if you need more information.
Thanks.
Attachments
Tree.png
Tree.png (14.72 KiB) Viewed 6908 times

ESP_renz
Posts: 18
Joined: Tue May 14, 2019 2:41 am

Re: undefined reference

Postby ESP_renz » Thu Apr 02, 2020 2:26 am

You need to populate the REQUIRES, PRIV_REQUIRES argument to idf_component_register with the proper dependency relationships.

For example, you mentioned that I2CKeypad depends on I2CPeripheral for I2CPeripheral.h, I2CKeypad should be:

Code: Select all

idf_component_register(SRCS "I2CKeypad.cpp" INCLUDE_DIRS "." REQUIRES I2CPeripheral)

Notice I also removed the "../I2CPeripheral". Establishing this dependency between I2CKeypad and I2CPeripheral should automatically propagate I2CPeripheral's public include directories (INCLUDE_DIR argument) to other component that REQUIREs it.

su-Koch
Posts: 11
Joined: Sat Jan 25, 2020 1:43 pm

Re: undefined reference

Postby su-Koch » Fri Apr 03, 2020 11:48 am

What I did now:

Changed
CMakeLists.txt of I2CKeypad:
idf_component_register(SRCS "I2CKeypad.cpp" INCLUDE_DIRS "." "../I2CPeripheral")

to
idf_component_register(SRCS "I2CKeypad.cpp" INCLUDE_DIRS "." REQUIRES I2CPeripheral)

but the error is still there.

ESP_renz
Posts: 18
Joined: Tue May 14, 2019 2:41 am

Re: undefined reference

Postby ESP_renz » Tue Apr 07, 2020 3:02 am

Can you post the build log?

Who is online

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