Tuesday, 1 January 2013

Makefail: undefined reference to `main'

Last time I have installed Eclipse following to some tutorial i found in the Internet. Then I tried to check if everything work properly, but as usual something came wrong. That time I saw beautiful announcement:
../crt1/gcrt1.S:195: undefined reference to `main'
Hmm... Linker suggested losing `main' function, which is called from  initialization code. However I saw `main' in the code. Pigs might flight if there wasn't `main' function.

I was looking for solution everywhere you can imagine. This problem had been discussed on some forums, but there is no unambiguous solution of this strange problem. When I said "I can't see any solution.", there was one more opportunity.

Solution

The solution was obvious. Ready? Steady? Go!!!

Let's press Ctrl+S and check if it works? Isn't it?