Please read this well to make sure you understand what I want to do.
What I have done (also as a future reference for people who might want to do the same thing):
I have added the following paths to the Header Search Paths and Library Search Paths:
(If you have installed Arduino.app somewhere other than the Applications folder, you will need to adjust the paths accordingly.)
In main.cpp, I have included <WProgram.h>
, but it wasn't enough. I was getting undefined identifier errors (for SPCR, SPE, MSTR, SPR1, SPR0) due to not being able to pass the -mmcu=somechipname
as a flag to the compiler, which caused no device to be defined and avr/io.h
to be unable to include the file that defined those symbols. I got around it by manually including <avr/iom328p.h>
which is the appropriate header file for my chip.
That's how far I got.
Now I get these errors:
Undefined symbols for architecture i386:
"_init", referenced from:
_main in main.o
"_setup", referenced from:
_main in main.o
"_loop", referenced from:
_main in main.o
"_pinMode", referenced from:
SBSetup() in main.o
"_digitalWrite", referenced from:
SBSetup() in main.o
The whole main.cpp including the evil offending code is this:
#include <WProgram.h>
#include <avr/iom328p.h> // Getting around warning "device type not defined"
#define NumLEDs 25
#define clockpin 13 // CI
#define enablepin 10 // EI
#define latchpin 9 // LI
#define datapin 11 // DI
int LEDChannels[NumLEDs][3] = {0};
int SB_CommandMode;
int SB_RedCommand;
int SB_GreenCommand;
int SB_BlueCommand;
void SBSetup(void) {
pinMode(datapin, OUTPUT);
pinMode(latchpin, OUTPUT);
pinMode(enablepin, OUTPUT);
pinMode(clockpin, OUTPUT);
SPCR = (1<<SPE)|(1<<MSTR)|(0<<SPR1)|(0<<SPR0);
digitalWrite(latchpin, LOW);
digitalWrite(enablepin, LOW);
}
int main(void)
{
init();
setup();
for (;;)
loop();
return 0;
}
What do I about this?
These two great references let you set up XCode not only for compile, but also for upload:
The first explains the additional tools you need, while the second provides a project template for XCode 4.2 (and previous versions).
I have used both and it works.
I think your best approach might be to forget about XCode, and just use the Arduino IDE.
For whatever it's worth, it doesn't even sound like you're building for the correct platform (i386?). Assuming you've got the AVR toolchain for GCC, you might have some luck looking at the default switches in the Arduino IDE's source:
src\Compiler.java
Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With