How to fix 'undefined reference to `main' collect2: error: ld returned 1 exit status'

When I am trying to compile the host code using make command. It gave me this error:

`/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
make: *** [bin/host] Error 1
`

What’s your question? For C/C++ programs, you must provide your own main() method.
Perhaps you forgot to add the object module containing your definition of main() to the linker?

https://opensource.com/article/19/5/how-write-good-c-main-function

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.