Creation of custom component - "undefined reference" error
Posted: Mon Jun 17, 2019 12:24 pm
Hello all !
I'm new to the forum and already browse it, found similar issues but didn't succeed to find a solution in my case...
I'm using an ESP-32 and try to make a custom component. I'm not able to build it, I have a linker error... here is my project tree:
project
--components
----test
------include
--------test.h
------component.mk
------test.c
--main
----CMakeLists.txt
----component.mk
----main.c
--CMakeLists.txt
--Makefile
The content of the file is the following (not all the file, only the main one regarding to this issue):
project\components\test\include\test.h
project\components\test\component.mk
project\components\test\test.c
project\main\CMakeLists.txt
project\main\component.mk
project\CMakeLists.txt
project\Makefile
My application access to the "test_function" of the new component "test".
When building I have error "undefined reference to `test_function`"
If I define the "test_function" in the "test.h" file, this is working.
I have already checked logs with "make V=1", the library is included in the building of my application "-ltest", and it exists.
I don't know where my setup is wrong.
If anyone can point something which is not good, I will try to do it, at this moment I have no more idea after several hours of testing and searching for custom component tutorial !
Thanks to all,
Joel
I'm new to the forum and already browse it, found similar issues but didn't succeed to find a solution in my case...
I'm using an ESP-32 and try to make a custom component. I'm not able to build it, I have a linker error... here is my project tree:
project
--components
----test
------include
--------test.h
------component.mk
------test.c
--main
----CMakeLists.txt
----component.mk
----main.c
--CMakeLists.txt
--Makefile
The content of the file is the following (not all the file, only the main one regarding to this issue):
project\components\test\include\test.h
Code: Select all
void test_function(void);
Code: Select all
# Empty
Code: Select all
void test_function(void) { /* Some stuff */ }
Code: Select all
set(COMPONENT_SRCS "main.c")
set(COMPONENT_ADD_INCLUDEDIRS ".")
register_component()
Code: Select all
# Empty
Code: Select all
cmake_minimum_required(VERSION 3.5)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(project)
Code: Select all
PROJECT_NAME := project
include $(IDF_PATH)/make/project.mk
When building I have error "undefined reference to `test_function`"
If I define the "test_function" in the "test.h" file, this is working.
I have already checked logs with "make V=1", the library is included in the building of my application "-ltest", and it exists.
I don't know where my setup is wrong.
If anyone can point something which is not good, I will try to do it, at this moment I have no more idea after several hours of testing and searching for custom component tutorial !
Thanks to all,
Joel