Multipe C files - Update make?

ocnek1
Posts: 3
Joined: Fri Mar 16, 2018 5:08 pm

Multipe C files - Update make?

Postby ocnek1 » Fri Mar 16, 2018 5:13 pm

Hello,
Sorry for the basic question. I've ran through some of the examples with no troubles, but would like to add some of my own functionality in separate c files so I don't have one big long source file. How do go about adding my own files to a project? Do I have to update a make file somewhere?

Sorry for the basic question. Just getting going with the ESP32, but having fun ;)

Thanks,
Oc.

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Multipe C files - Update make?

Postby kolban » Sat Mar 17, 2018 3:49 am

If you are using the ESP-IDF build system and the template application, you should find a folder called "main" in your project. Create your new source files in that directory with the file suffix of ".c". Now when you run the existing build / make, your new source files will be automatically compiled and linked. It appears that the build system will compile all source files in main that end in .c or .cpp and link them together for you. There is more that can be said on this topic but I'm hoping that this answers the core question.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

ocnek1
Posts: 3
Joined: Fri Mar 16, 2018 5:08 pm

Re: Multipe C files - Update make?

Postby ocnek1 » Sat Mar 17, 2018 4:06 am

Hi Kolban.

Thanks for the reply. Yep, looks like you are correct :) I've just added a couple of new .c / .h files and everything seems to link and work OK.

.....well that was easy :o

Yes, I'm just working with the ESP-IDF build system.

Thanks.

Who is online

Users browsing this forum: No registered users and 63 guests