Hello everyone, the main component calls a function in component A(wifi_app), and component A calls a function in component B(port_event). Component A has added a dependency on component B to its CMakeLists, but when linking, the function defined in component B cannot be found, prompting an "undefined reference to 'port_clear/get/set_status (EVENT, GROUP, SELECT_T, unsigned long)'. I changed this statement to xEventGroupClearBits/xEventGroupSetBits/xEventGroupWaitBits , There are no issues with compiling and linking. May I ask where the problem lies? Seeking guidance.
Projects with successfully compiled links, such as new1, and projects with problematic compiled links, such as new2
I have compiled on both Ubuntu and Windows environments, and the ESP-IDF versions are 5.1.0 and 5.3.0 respectively (currently not affected), both of which report the same error.
The CakeLists for custom component A (wifi_app) are as follows:
idf_component_register(SRCS "wifi_device.cpp"
INCLUDE_DIRS ". "
REQUIRES freertos esp_system esp_wifi esp_event esp_ringbuf
main_config
port_debug
port_event
hal_param_manage
)
The CakeLists for custom component B (port_event) are as follows:
idf_component_register(SRCS "port_event.c"
INCLUDE_DIRS ". "
REQUIRES freertos esp_system log
)
The CakeLists for component mian are as follows:
idf_component_register(SRCS "user_main.c"
INCLUDE_DIRS ""
REQUIRES)
undefined reference to when linking
-
- Posts: 20
- Joined: Mon Jul 10, 2023 9:14 am
-
- Posts: 1725
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: undefined reference to when linking
If the main component needs to access functions from the "port_event" component, like port_event_init(), the main component should declare a dependency on "port_event" too.greenstone wrote: ↑Tue Sep 03, 2024 2:07 amComponent A has added a dependency on component B to its CMakeLists, but when linking, the function defined in component B cannot be found, prompting an "undefined reference to 'port_clear/get/set_status (EVENT, GROUP, SELECT_T, unsigned long)'.
-
- Posts: 20
- Joined: Mon Jul 10, 2023 9:14 am
Re: undefined reference to when linking
Thank you for your reply. I will give it a try, but the tutorial video I saw did not require this. Instead, it stated that 'main' is a special component that includes default components from the installation directory and custom components from the project directory.
Who is online
Users browsing this forum: No registered users and 213 guests