Things to check:
- Make sure you declare
main
correctly. For example,int main(void)
orint main(int argc, char **argv)
, and notvoid main(void)
. This Stack Overflow article does a great job: What is the proper declaration of main? - Make sure you haven't accidentally wrapped
main
in anamespace
. - If you have an exceptionally quirky C++ compiler, you may need to mark
main
asextern "C"
, but to be quite honest, I've never seen tools that needed that.
You should be able to see what symbols got defined by your main.o
by running a tool such as nm
on it. (At least, UNIX-style tool chains, such as the GNU tool chain, offer an nm
tool.) nm
will list the set of symbols defined by your executable. You should see main
listed as-is.
For example, on my Linux box, int main(void) { }
in an otherwise empty .cpp file results in the following output from nm:
$ nm main.o
U __gxx_personality_v0
0000000000000000 T main
If I wrap main
in a namespace (in this case namespace fred
), I get a mangled name like this:
$ nm main.o
0000000000000000 T _ZN4fred4mainEv
U __gxx_personality_v0
Notice the extra gobbledegook around the name main
. You shouldn't see such gobbledegook in your nm
output.
You should be able to see if you're correctly declaring main
and not accidentally dropping it into a namespace. Once you get that sorted, then the initialization routine LoopFillZerobss
should be much happier.