Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By Andrei Candale
#16389
jcmvbkbc wrote:
Andrei Candale wrote:And here is my Makefile
Code: Select all...
# name for the target project
TARGET      = user_main.c
...

Please give it different name. I can't tell if it's really the problem, but it looks fishy.


I did; the value of TARGET is now 'app'. It was a desperate move to change it to user_main.c. I did not know what else to do. The result is the same though.
User avatar
By jcmvbkbc
#16392
Andrei Candale wrote:I did; the value of TARGET is not 'app'. It was a desperate move to change it to user_main.c. I did not know what else to do. The result is the same though.

Ok. The idea of this makefile is the following:
- you put it into root of your project;
- you put your sources into subdirectories of this root, and list these subdirectories in MODULES;
- when you run make it builds all c files in subdirectories listed in MODULES and puts them into an archive in the 'build' subdirectory called $(TARGET)_app.a. Then it links ELF file in the same directory called $(TARGET).out. Then it makes firmware binaries from that ELF.

So, I suggest you to change TARGET and MODULES in your Makefile as follows:
Code: Select all# name for the target project
TARGET      = test

# which modules (subdirectories) of the project to include in compiling
MODULES     = user

(assuming you don't have 'drivers' directory, otherwise add drivers to the MODULES line).
Then put your user_main.c into 'user' subdirectory and run make again.
User avatar
By Andrei Candale
#16393
jcmvbkbc wrote:
Andrei Candale wrote:I did; the value of TARGET is not 'app'. It was a desperate move to change it to user_main.c. I did not know what else to do. The result is the same though.

Ok. The idea of this makefile is the following:
- you put it into root of your project;
- you put your sources into subdirectories of this root, and list these subdirectories in MODULES;
- when you run make it builds all c files in subdirectories listed in MODULES and puts them into an archive in the 'build' subdirectory called $(TARGET)_app.a. Then it links ELF file in the same directory called $(TARGET).out. Then it makes firmware binaries from that ELF.

So, I suggest you to change TARGET and MODULES in your Makefile as follows:
Code: Select all# name for the target project
TARGET      = test

# which modules (subdirectories) of the project to include in compiling
MODULES     = user

(assuming you don't have 'drivers' directory, otherwise add drivers to the MODULES line).
Then put your user_main.c into 'user' subdirectory and run make again.


Holy sh*t! It worked. I am forever in your debt! Thank you! It seems simple enough but without having the proper understanding, one could spend days on this. Thank you!
User avatar
By trendchaster
#32373 Hello Guys ,
Me too suffering from same issue.How to resolve it?

AR build/test_app.a
LD build/test.out
c:/Espressif/ESP8266_SDK/lib\libmain.a(app_main.o): In function `user_uart_wait_tx_fifo_empty':
(.irom0.text+0x598): undefined reference to `user_init'
c:/Espressif/ESP8266_SDK/lib\libmain.a(app_main.o): In function `user_rf_pre_init':
(.irom0.text+0x804): undefined reference to `user_init'
collect2.exe: error: ld returned 1 exit status
C:/Users/Girish/worksorg/mesh/Makefile:187: recipe for target 'build/test.out' failed
mingw32-make.exe: *** [build/test.out] Error 1

18:18:58 Build Finished (took 1s.306ms)