Multiple source codes cannot be built

Hiroki
Posts: 5
Joined: Mon Jan 20, 2025 11:38 pm

Multiple source codes cannot be built

Postby Hiroki » Fri Feb 14, 2025 1:38 am

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?

nopnop2002
Posts: 153
Joined: Thu Oct 03, 2019 10:52 pm
Contact:

Re: Multiple source codes cannot be built

Postby nopnop2002 » Fri Feb 14, 2025 7:32 pm

esp-idf contains many samples consisting of multiple sources.

This is one example.

https://github.com/espressif/esp-idf/tr ... le_serving

Hiroki
Posts: 5
Joined: Mon Jan 20, 2025 11:38 pm

Re: Multiple source codes cannot be built

Postby Hiroki » Wed Feb 19, 2025 3:14 am

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.

ESP_Sprite
Posts: 9985
Joined: Thu Nov 26, 2015 4:08 am

Re: Multiple source codes cannot be built

Postby ESP_Sprite » Wed Feb 19, 2025 9:13 am

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.

User avatar
ok-home
Posts: 116
Joined: Sun May 02, 2021 7:23 pm
Location: Russia Novosibirsk
Contact:

Re: Multiple source codes cannot be built

Postby ok-home » Wed Feb 19, 2025 12:19 pm

Hiroki wrote:
Wed Feb 19, 2025 3:14 am
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.
https://docs.espressif.com/projects/esp ... ystem.html

nopnop2002
Posts: 153
Joined: Thu Oct 03, 2019 10:52 pm
Contact:

Re: Multiple source codes cannot be built

Postby nopnop2002 » Wed Feb 19, 2025 12:31 pm

>The only information I can find in various languages is to write the source file name in “CMakeLists.txt”

That's really all.

Code: Select all

set(srcs "main.c" "test.c")

idf_component_register(SRCS "${srcs}" INCLUDE_DIRS ".")

Hiroki
Posts: 5
Joined: Mon Jan 20, 2025 11:38 pm

Re: Multiple source codes cannot be built

Postby Hiroki » Wed Feb 19, 2025 11:42 pm

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.

Hiroki
Posts: 5
Joined: Mon Jan 20, 2025 11:38 pm

Re: Multiple source codes cannot be built

Postby Hiroki » Thu Mar 06, 2025 1:04 am

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.

Who is online

Users browsing this forum: No registered users and 132 guests