Arduino on Xcode Project — Official Thread

I'm implementing support for Due on Xcode for Mac OS X with the template embedXcode.

Building and linking work fine.

Unfortunately, I can't proceed with the uploading tests as I don't own an Arduino Due board.

Can an Arduino Due owner post the verbose output for upload?

Thanks!

Dear avenue33 (or anybody else who may help),

I have installed embedXcode but get stuck since a couple of days when trying to execute the build target.
I get errors that suggest that the compiler would not accept overloading functions. (screenshot attached)
Also, the UDPbytewise library seems to request a "Types.h" include that cannot be found.
What kind of confuses me is also that those are "Shell Script Invocation Errors".
Any idea if this is a compiler flag not set or something of that sort? I really would like this to work, as I have a project that I need to separate into different libraries and classes to be maintainable, and the Arduino IDE is just not made for that.

Any help would be greatly appreciated.

Does the project compile with the standard Arduino IDE?

The "already defined here" message occurs when the same libraries are in two places:

  • first under the sketchbook / libraries folder
  • and second under the project folder.

The screenshot doesn't provide enough clues to help you more. What is the board used?

Thank you for your input.

I try to build for Arduino Mega 2560

On the standard IDE, I get the following error:

main.cpp:45:25: error: BlinkTest.ino: No such file or directory

If I remove main.cpp from the project, it compiles (this does not seem strange, as the main.cpp is probably already "hidden" in the Arduino IDE), but I get some warnings:
Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/HardwareSerial.cpp: In function 'void store_char(unsigned char, ring_buffer*)':
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/HardwareSerial.cpp:82: warning: comparison between signed and unsigned integer expressions
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/HardwareSerial.cpp: In member function 'virtual size_t HardwareSerial::write(uint8_t)':
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/HardwareSerial.cpp:390: warning: comparison between signed and unsigned integer expressions
and
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Print.cpp: In member function 'size_t Print::print(const __FlashStringHelper*)':
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Print.cpp:44: warning: 'progmem' attribute ignored
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Tone.cpp:93: warning: only initialized variables can be placed into program memory area

Attached is the path of the project folder. The Sketchbook folder is empty, except for the .txt file, the others have all the .h and .cpp files in them.
Does that seem right?

Any clues?

Screen Shot 2012-11-05 at 18.24.57.png

Well, it seems your project is having some issues even in the Arduino IDE.

How complex is your project?

The sketchbook folder is the place were you place a link to the libraries you've developed.

Please refer to section 3.3. Add User's Libraries on pages 25 et sq. of the User Manual.

it's really just the test project that appears when you create a new embedxcode project. I haven't changed a line of code and just wanted to try if it compiles, at all... :~
maybe I should try a regular c++ project to see what's wrong with the environment?

Which release of embedXcode are you using?

Which release of the Arduino IDE are you using?

Is the Arduino IDE installed on the folder /Applications?

Current version 17 of embedXcode doesn't invoque any HardwareSerial in the default sketch.

According to the messages, it seems Arduino 23 and 1.0 are mixed. Best solution consists on deleting the Arduino IDEs and proceeding with a clean install.

Arduino IDE 1.0.2. Just deleted the whole thing (including sketch folder) and reinstalled. (I think it was 1.0.1, before, they must have updated it quite recently).
embedxcode downloaded installer package from your website on 21 oct 2012 (where do I see the version?)
Same result...
I will try a little more over the weekend

Strange indeed. This is the first time such error is reported.

Can I ask you or some other Xcode/Makefile craig again if you have some clues?
I discovered the following:

When I add in main.cpp the full path of BlinkTest.ino (i.e. #include"/Users/myname/Documents/Arduino/BlinkTest/BlinkTest/BlinkTest.ino") the test project compiles in the Arduino IDE.
The warnings are still present. They appear in Libraries HardwareSerial.cpp, Print.cpp and Tone.cpp which are included from a previous compile (although I installed the whole Arduino.app new).
E.g. the last lines of the compiler output before the warnings are:

/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega2560 -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=102 \
  -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino \
  -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/variants/mega /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/HardwareSerial.cpp \
  -o /var/folders/gq/_c97z0614fj267w8732pn4r00000gn/T/build4731805130703822254.tmp/HardwareSerial.cpp.o 
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/HardwareSerial.cpp: In function 'void store_char(unsigned char, ring_buffer*)':

I suspect this may be independent from the build errors in XCode, but on the other hand, I was able to avoid all warnings in previous sketches.

What I also observed: If I insert some rubbish into the main.cpp (either within main{} or outside), it is not picked up during the build target, at all. This can be because it lists too many other errors and parses all includes, first, but may still be a clue.

I still believe this may be some problem with errors due to function overloading which would normally work in C++ (maybe some functions are not interpreted as being part of a class ??)

If I look at the first bit that generates an error:

#ifdef __cplusplus
#include "WCharacter.h"
#include "WString.h"
#include "HardwareSerial.h"
uint16_t makeWord(uint16_t w);
uint16_t makeWord(byte h, byte l);

#define word(...) makeWord(__VA_ARGS__)

Which is some part of Arduino.h I get the first error in the lower line of uint16_t makeWord saying Declaration of C function 'uint16_t makeWord(byte, byte)' conflicts with and in the line above the error is Previous declaration 'uint16_t makeWord(uint16_t)' here.

I also included in Arduino1.mk the line $(shell env>theEnvironment) and the anonymized result is attached...

Thank you anyone for your help.

theEnvironment.txt (9.91 KB)

I'm sorry not to be able to help you on your specific case.

I don't understand why the blink.ino file isn't inside the folder of the Xcode project:

MyProject/
. MyProject.xcode
. MyProject/
. . blink.ino
. . main.cpp
. . and other files

Please find the new release of embedXcode

  • Oct 26, 2012 release 18 • Support for Arduino Due
  • Oct 28, 2012 release 19 • Support for StellarPad
  • Nov 09, 2012 release 20 • Support for Teensy 3.0

The user manual has been updated too

  • Nov 09, 2012 release 16 • Updated with new boards

Please note the Arduino 1.5, Energia for StellarPad and Teensy 3.0 softwares are in development.

I've tested build, link and upload successfully for all boards except for the Arduino Due I don't own.

Website: http://embedxcode.weebly.com
Download: http://embedxcode.weebly.com/download
User guide: http://embedxcode.weebly.com/tutorial

Enjoy :wink:

ok, I got it to work. (The directory structure was correct, it was just as you mentioned it should be, above, btw).
The problem was that apparently from Arduino 1.0.1 (?) but definitely in 1.0.2 there is a library WiFi in the libraries path in the applications folder, which is included automatically by the makefiles (the APP_LIB_PATH directory seems to be parsed in step2.mk).
Uncommenting the BOARD_TAG and and other variables in the root makefile and running a "make build" from the Terminal gave me that clue.
(btw, is there any way to make XCode give you the verbose build output. It would give better clues, sometimes).

The triggering error was actually

/Applications/Arduino.app/Contents/Resources/Java/libraries/WiFi/WiFiClient.cpp: In member function 'uint8_t WiFiClient::getFirstSocket()':
/Applications/Arduino.app/Contents/Resources/Java/libraries/WiFi/WiFiClient.cpp:177: error: 'SOCK_NOT_AVAIL' was not declared in this scope
make: *** [Builds/libs/WiFi/WiFiClient.o] Error 1

SOCK_NOT_AVAIL is some preprocessor definition in a utility header from that WiFi library, which probably was not parsed.
The duplicates appeared then because it probably messed up the whole preprocessing.

I worked around this by just adding WiFi to the EXCLUDE_NAMES tag definition of step1.mk.
The build target then went straight through without any errors or warnings.

I tried to manually copy the WiFi library to the project folder and included it to all targets in XCode, but that did not work. You probably understand why :wink: and may want to add that library to the next release (or could it not be parsed, anyway?).

Thanks for the tool, it looks great and I will now try out my real projects with it :slight_smile:

I'm glad it works for you now.

matzrh:
Uncommenting the BOARD_TAG and and other variables in the root makefile and running a "make build" from the Terminal gave me that clue.

The BOARD_TAG variable is defined when you select the board on Info pane.
Please refer to section 4.2. Change the Board on the User Manual.

matzrh:
(btw, is there any way to make XCode give you the verbose build output. It would give better clues, sometimes).

All the build, link and upload commands as well as the error messages are available on the Issue navigator.
Please refer to section 5.4. Error Messages on the User Manual.

Xcode is a professional IDE and requires some learning. I strongly recommend Xcode 4 Unleashed by Fritz F. Anderson I bought thanks to contributions I've received.

Please find the new release of embedXcode

Nov 13, 2012 release 21 • Stability enhancement and better information

• Stability enhancement, especially for Arduino Due and StellarPad linking
• Better information in a more structured presentation

As always,

• Website: http://embedxcode.weebly.com
• Download: http://embedxcode.weebly.com/download
• User guide: http://embedxcode.weebly.com/tutorial

Enjoy :wink:

Please find the new release of embedXcode

Nov 17, 2012 release 22 • New Make and Fast optimised targets

embedXcode release 22 includes two new targets: Make and Fast.

The Make and Fast targets feature an optimisation for the build of the foundation libraries.

The new targets are much faster than the corresponding Build and All targets. This is especially important for the ARM-based boards.

Learn more.

As always,
• Website: http://embedxcode.weebly.com
• Download: http://embedxcode.weebly.com/download
• User guide: http://embedxcode.weebly.com/tutorial

Enjoy :wink:

Context - OSX MountainLion, Xcode4.5.2

I have installed embeddedXcode and I can (after some messing about ) generate an Arduino (Uno) project.

I find I cannot compile it here is the error report - the Arduino is not connected and I have not editted the code created

embedXcode

----------------------------------

Embedded Computing on Xcode 4

Copyright © Rei VILO, 2010-2012

Licence CC = BY NC SA

References and contribution

----------------------------------

See About folder

include $(MAKEFILE_PATH)/Avrdude.mk

ifneq ($(MAKECMDGOALS),boards)
ifneq ($(MAKECMDGOALS),build)
ifneq ($(MAKECMDGOALS),make)
ifneq ($(MAKECMDGOALS),document)
ifneq ($(MAKECMDGOALS),clean)
ifeq ($(AVRDUDE_PORT),)
$(error Serial port not available)
endif
endif
endif
endif
endif
endif

I would like to be more explicit - but I simply dont know what to say - except that I would expect it to be able to compile a 'null program'! Earlier attempts encountered other errors ( like 'init()' not defined) - but these have now gone away!

Any help will be much appreciated before I am forced to use VisualStudio!

Thank-you

What target have you selected?

Thank-you for such a quick response!

The only option I can have is All->My Mac 32bit.

The Project Targets/All Build Settings show
Debug Board Port as tty.usbmodem*, and the Debug Board Tag as uno

davidhux:
Thank-you for such a quick response!

You're welcome!

davidhux:
The only option I can have is All->My Mac 32bit.

Strange, you should have also Build, which builds and links without uploading, and many other options as shown is my previous post.

davidhux:
The Project Targets/All Build Settings show
Debug Board Port as tty.usbmodem*, and the Debug Board Tag as uno

I the case your genuine Arduino Uno board —and not a compatible board that may use another driver to upload— is connected, open the Terminal and type

ls /dev/tty.usb*

It might be the serial port is managed by /dev/tty.usbserial* instead of the default /dev/tty.usbmodem*

  • Arduino Uno rev 2 board = /dev/tty.usbmodem411
  • Compatible Uno board = /dev/tty.usbserial-A40084mc

In such a case, just edit the the Arduino UNO.xcconfig file with the USB port.