Some of the time I'm using Xcode (with EmbedXcode) to write my Arduino programs. EmbedXcode creates a main.cpp file in the same directory as my ino file. On my mac, when I compile my sketch, I get an error: crtm32u4.o undefined reference to main. But if I compile it again a second time, I don't get any errors. If I make a change and save it, then compile, I get the error, but the 2nd time I don't. This is all on my Mac with Arduino IDE 1.05.
Now I also have a Windows 7 laptop with Arduino 1.05 running and I get the same error, but it never goes away. Here is the full error:
c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5/crtm32u4.o:(.init9+0x0): undefined reference to `main'
In my .ino file I just have
void setup()
{}
void loop()
{}
And main.cpp is totally empty.
I'd like to use Xcode to create my files, but I do need to run them from the Arduino IDE from time to time. Any idea why it kind of works on the Mac and doesn't in Windows? Does anyone have a solutions to the windows problem? The only thing I can think of is rename main.cpp to something else, which I will do if I can't find a better way.
Windows has Xcode?
Xcode on Mac creates an EMPTY mail.cpp? That doesn't sound right.
When the Arduino IDE compiles a sketch, it compiles the core and puts the objects into a temporary directory. The core includes a main.cpp file that produces a main.cpp.o file containing the main() function. Then it copies and compiles the user's sketch files to the same directory. If you have an empty main.cpp, it probably overwrites the arduino main.cpp.o with an empty object file, and there ends up being no main() function at all.
I'm not sure why it would work the second time on the mac...
Renaming your main.cpp should work. But if it's empty, why not just delete it?
westfw:
Windows has Xcode?
Xcode on Mac creates an EMPTY main.cpp? That doesn't sound right.
Windows doesn't have Xcode. I have arduino IDE installed on a few computers, one is Mac another is Windows. Xcode is only used with my Mac, but my windows computer will open up the same sketch files as the Mac. I use dropbox to keep libraries and sketches synced up. it works pretty well.
Xcode doesn't create an empty main.cpp file, it's got a bunch of stuff in it. I just deleted everything for this forum post to keep it simple and to make sure nothing in the main.cpp was causing the problem. I get the same behavior whether the main.cpp is empty or not.