You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wrote a small program with no errors in it, but found when compiling I got the error "Undefined reference to main". Obviously that is stupid since Arduino defines its own main... But wait... I bet I know how they've screwed up (I thought).
Turns out I was right! If you call your program main Arduino's none-too-bright build system will get confused and fail to find its own main. There's obviously some serious bodgery going on in there since my program resides in main.ino and doesn't declare any main() functions. And presumably the Arduino source code is specified with an absolute path (right? guys? right?) and does have a main(). You're surely not doing #include "main.ino" somewhere because that would be crazy.
Anyway, when I renamed my program it worked fine. At the very least you should add a warning to the File->Save As dialogue in case the user tries to save the program as "main" (a quite reasonable name I think!).
The text was updated successfully, but these errors were encountered:
The problem here is that main.ino gets compiled as main.o, which overwrites the main.o compiled from the Arduino core (or vice versa, not sure). The problem is that both the sketch and core end up in the same directory in the temp directory. IIRC there has been talk of fixing this properly by using subdirectories in the temp folder (here and here).
I wrote a small program with no errors in it, but found when compiling I got the error "Undefined reference to main". Obviously that is stupid since Arduino defines its own main... But wait... I bet I know how they've screwed up (I thought).
Turns out I was right! If you call your program
main
Arduino's none-too-bright build system will get confused and fail to find its own main. There's obviously some serious bodgery going on in there since my program resides inmain.ino
and doesn't declare anymain()
functions. And presumably the Arduino source code is specified with an absolute path (right? guys? right?) and does have amain()
. You're surely not doing#include "main.ino"
somewhere because that would be crazy.Anyway, when I renamed my program it worked fine. At the very least you should add a warning to the File->Save As dialogue in case the user tries to save the program as "main" (a quite reasonable name I think!).
The text was updated successfully, but these errors were encountered: