-
Notifications
You must be signed in to change notification settings - Fork 7.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IDF v4.x multi-component application build fails at final linking stage due to "undefined reference to ..." ld errors (IDFGH-5195) #6968
Comments
Hi @ul-gh, Thanks for the very clear report. I cloned your project master branch from GitHub and using the current ESP-IDF master branch commit I was able to reproduce different linker errors, so something is clearly not quite right! I think probably the underlying issue is something with transitive dependencies, or at least it looks like it (i.e. some break in the chain of component A depends on component B depends on component C). Or possibly a dependency cycle where the linker command line doesn't end up with the libraries in the right place. Can I ask exactly which ESP-IDF version you're using? I'll see if I can reproduce the exact error you're seeing by using it. Also, if you still have the file |
Hi @projectgus! My current esp-idf version is v4.3-beta3, e9cf9e2 (with added patch of PR6578) I also tried with master branch head a few days ago, same result. arduino-esp32 is current master with following added dependencies to make it compile:
|
At last! It seems there is some cyclic dependency in my components/ESPAsyncWebServer. I have not yet found out where exactly, but setting the CMake "LINK_INTERFACE_MULTIPLICITY" which defaults to 2 to a value of 3 in that component makes the compilation succeed. (See: GNU LD linker and CMake Link order documentation) While I am definitely a first-time-user of CMake: This seems to be a non-obvious but very likely issue one might encounter when building with the ESP-IDF build system. IMO ESP-IDF should not choke on a wrong, automatically generated, link order. Set LINK_INTERFACE_MULTIPLICITY in components/ESPAsyncWebServer/CMakeLists.txt :
|
Hi @ul-gh, Well done figuring this out! After a bit of further analysis, I can confirm there is a circular dependency in arduino-esp32. It depends on "main" component, where "main" is the top-level component that depends on all other components. This creates the circular dependency arduino-esp32 -> main -> arduino-esp32, which can cause linker issues with other components that also depend on arduino-esp32 (or their dependencies, in this case it was causing issues because main -> ESPAsyncWebServer -> AsyncTCP -> arduino-esp32 -> main.) Adding I'll submit a PR to arduino-esp32 repo to remove the "main" dependency as I don't think it's needed. If it turns out that it is needed for some reason then we can probably add
Agree on both counts. Will add a note about this kind of error, possible workarounds, and some ways to find dependency cycles (as this is also not very simple!) We'll see if we can improve ESP-IDF tooling for this as well. |
Oh! Of course it's needed, for the case where "Autostart Arduino setup and loop on boot" is enabled. In this case, app_main is in arduino-esp32 and it needs to be able to depend on "main" where setup() and loop() functions are found... I think we can still find a better fix for it, either with linker tricks or by making a separate |
wouldnt it be more ESPish to write it like
|
inside ESP-IDF i find it as
|
I've been hitting this same issue for days many thanks for this! And in hindsight that loop was something I noticed and should have picked up on 😁 For the benefit of anyone using Github's global search (which is how I found this) I was getting linker errors with
But like was noted in the thread, this probably ends up erroring out at a non-deterministic point. Slightly different note but related to the original comment (and what really sent me down the wrong path) is I believe ESPAsyncWebServer has a header access issue when built in It's relying on the Arduino core's
I have a hunch that if the circular reference is fixed this might be an issue, but I haven't had a chance to test |
arduino-esp32 has to depend on main in autostart mode, for setup() and loop(), but this can be done with undefined symbol entries to avoid a large dependency cycle and other linker errors. Closes espressif/esp-idf#6968
Glad the workaround is helping. I've pushed the PR linked above to arduino-esp32, this should remove the need for the workaround at all. Have a pending change also to add LINK_INTERFACE_MULTIPLICITY to the ESP-IDF build system docs. |
arduino-esp32 has to depend on main in autostart mode, for setup() and loop(), but this can be done with undefined symbol entries to avoid a large dependency cycle and other linker errors. Closes espressif/esp-idf#6968
This issue I found during the transition from PlatformIO IDE to a pure ESP-IDF setup using multiple components, i.e. arduino-esp32, ESPAsyncWebServer, among others.
After two days of trying, I can't seem to compile using IDF v4x any more.
The complete project code you find here:
ESP-LiveControl
With the current ESP-IDF build system, the compilation of all source files first /succeeds/ (after some fixing of arduino-esp32, see arduino-esp32 issue 5064 but then at the final stage, I get multiple ld linker errors:
(Full build log output attached as a text file):
This is although the particular references were definitely successfully built before, as from the same build log output. A full error output I am attaching as a file.
I closely followed the project setup instructions from ESP-IDF build system documentation.
This is the project CMakeLists.txt:
This is the main component CMakeLists.txt:
This is a component CMakeLists.txt:
Am I missing anything or is the build system broken?
Regards,
Ulrich Lukas
build_log.txt
build_log_full.txt.gz
The text was updated successfully, but these errors were encountered: