Skip to content

Undefined reference to main [CAUSE KNOWN] #1537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Timmmm opened this issue Aug 9, 2013 · 3 comments
Closed

Undefined reference to main [CAUSE KNOWN] #1537

Timmmm opened this issue Aug 9, 2013 · 3 comments
Assignees
Labels
Component: IDE The Arduino IDE Type: Duplicate Another item already exists for this topic
Milestone

Comments

@Timmmm
Copy link

Timmmm commented Aug 9, 2013

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!).

@ffissore
Copy link
Contributor

I'd close this as wontfix. Passing to @cmaglie

@matthijskooijman
Copy link
Collaborator

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).

@cmaglie
Copy link
Member

cmaglie commented May 29, 2015

Yes this is basically a duplicate of #2997.

@cmaglie cmaglie closed this as completed May 29, 2015
@cmaglie cmaglie added the Type: Duplicate Another item already exists for this topic label May 29, 2015
@ffissore ffissore added this to the Release 1.6.5 milestone May 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: IDE The Arduino IDE Type: Duplicate Another item already exists for this topic
Projects
None yet
Development

No branches or pull requests

4 participants