The development environment is ESP-IDF v5.4.0 and VSCode.
Source files are divided by function.
However, an error occurs in the build.
I'm wondering if something is missing, since the sample on Github confirms that multiple source files also build successfully.
Please advise what is missing.
The file structure is
main.c
test.c
test.h
The three files are in the same path.
The addition to main.c is
#include “test.h”
The addition to CMakeLists.txt is “test.c” after SRCS.
If you write code to use a function in test.c in main.c, a build error will occur.
Of course, the build will succeed if the functions of test.c are not written in main.c.
The only information I could find was to append the name of the source file I added to CMakeLists.txt.
What else is needed?
Multiple source codes cannot be built
-
- Posts: 155
- Joined: Thu Oct 03, 2019 10:52 pm
- Contact:
Re: Multiple source codes cannot be built
esp-idf contains many samples consisting of multiple sources.
This is one example.
https://github.com/espressif/esp-idf/tr ... le_serving
This is one example.
https://github.com/espressif/esp-idf/tr ... le_serving
Re: Multiple source codes cannot be built
Thanks for answering.
But the information I want is not the URL of the sample source, but what exactly it does.
The only information I can find in various languages is to write the source file name in “CMakeLists.txt”, which gives me a build error when I try to put it into practice.
What else do I need to do to get a successful build?
I could not find a solution just by looking at the sample source.
But the information I want is not the URL of the sample source, but what exactly it does.
The only information I can find in various languages is to write the source file name in “CMakeLists.txt”, which gives me a build error when I try to put it into practice.
What else do I need to do to get a successful build?
I could not find a solution just by looking at the sample source.
-
- Posts: 9985
- Joined: Thu Nov 26, 2015 4:08 am
Re: Multiple source codes cannot be built
Can you post the actual text of your main.c, test.c and CMakeLists.txt here? Also the error you get when trying to compile it would be helpful.
Re: Multiple source codes cannot be built
https://docs.espressif.com/projects/esp ... ystem.htmlHiroki wrote: ↑Wed Feb 19, 2025 3:14 amThanks for answering.
But the information I want is not the URL of the sample source, but what exactly it does.
The only information I can find in various languages is to write the source file name in “CMakeLists.txt”, which gives me a build error when I try to put it into practice.
What else do I need to do to get a successful build?
I could not find a solution just by looking at the sample source.
-
- Posts: 155
- Joined: Thu Oct 03, 2019 10:52 pm
- Contact:
Re: Multiple source codes cannot be built
>The only information I can find in various languages is to write the source file name in “CMakeLists.txt”
That's really all.
That's really all.
Code: Select all
set(srcs "main.c" "test.c")
idf_component_register(SRCS "${srcs}" INCLUDE_DIRS ".")
Re: Multiple source codes cannot be built
Thanks for the reply.
The information I am getting seems to be correct.
I will try with reinstalling ESP-IDF and VSCode or try with another PC.
The information I am getting seems to be correct.
I will try with reinstalling ESP-IDF and VSCode or try with another PC.
Re: Multiple source codes cannot be built
Hello.
I'm sorry for the delay, but I tried on another PC.
As a result, I was able to build correctly with the same source code.
I can't pinpoint the cause, but it may be something wrong with the PC or with the development tools.
Thanks to all who have commented on this issue.
I'm sorry for the delay, but I tried on another PC.
As a result, I was able to build correctly with the same source code.
I can't pinpoint the cause, but it may be something wrong with the PC or with the development tools.
Thanks to all who have commented on this issue.
Who is online
Users browsing this forum: No registered users and 122 guests