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.
undefined reference
undefined reference
- Attachments
-
- Tree.png (14.72 KiB) Viewed 6882 times
Re: undefined reference
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:
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.
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.
Re: undefined reference
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.
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.
Re: undefined reference
Can you post the build log?
Who is online
Users browsing this forum: Baidu [Spider] and 118 guests