In the function `_start ': init.c :(. Text + 0x30): undefined reference to` main'

I am working on a C project with about 30 source files (.c). I build this project on a 32-bit microcontroller (i.MX515), running on Ubuntu using GNU tools.

The compilation phase succeeds, however, when I start the binding process, I get this error (for a complete error at the end of quesiton):

In function `_start': init.c:(.text+0x30): undefined reference to `main' 

I have a main() function that makes simple printf() .

My link makefile is as follows.

 final: $(OBJDIR)/main.o $(OBJDIR)/TchClaKnn_BuildKdtreeInt.o $(OBJDIR)/TchClaKnn_FreeKdtreeInt.o.... (Go upto 30 files like this) @echo ".Linking" $(CC) $(LFLAGS) -o $(OBJDIR)/main.o $(OBJDIR)/TchClaKnn_BuildKdtreeInt.o $(OBJDIR)/TchClaKnn_FreeKdtreeInt.o..... (Go upto 30 files like this) 

Help !!!

Hi

Vikram


Complete binding error

 /usr/lib/gcc/arm-linux-gnueabi/4.3.3/../../../crt1.o: In function `_start': init.c:(.text+0x30): undefined reference to `main' collect2: ld returned 1 exit status make[1]: *** [final] Error 1 make[1]: Leaving directory `/home/ubuntu/Documents/Project/IMX_Project_v1' make: *** [all] Error 2 
+4
source share
2 answers

final depends on main.o (and several others), but your make file accepts all the "others" and displays them in main.o (something most compilers do)

edit your line of links to: -o final $(OBJDIR)/main.o

+8
source

A component cannot find object code for a source that has main () defined in it. Probably they donโ€™t collect it. Make sure that in any of the 30 files that have main (), it compiles to .OBJ.

+3
source

Source: https://habr.com/ru/post/1308656/


All Articles