amperka / ino

Command line toolkit for working with Arduino hardware
http://inotool.org
MIT License
1.08k stars 232 forks source link

the problem of the dependencies <SPI.h> #172

Closed ghost closed 10 years ago

ghost commented 10 years ago

Hi,everybody. Description is not as good as the code to quickly. See the code :

#include <SPI.h>

#define LED_PIN 13

void setup()
{
    pinMode(LED_PIN, OUTPUT);
}

void loop()
{
    digitalWrite(LED_PIN, HIGH);
    delay(100);
    digitalWrite(LED_PIN, LOW);
    delay(900);
}

The code is the test code,Note the first line of code: "#include " This code generation dependencies.d is as follows:

.build/uno/src/sketch.d .build/uno/src/sketch.o: .build/uno/src/sketch.cpp \
  /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Arduino.h \
  /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/binary.h \
  /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WCharacter.h \
  /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WString.h \
  /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/HardwareSerial.h \
  /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Stream.h \
  /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Print.h \
  /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Printable.h \
  /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/new.h \
  /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/variants/standard/pins_arduino.h \
  /Applications/Arduino.app/Contents/Resources/Java/libraries/Robot_Control/SPI.h

Note the last line: Robot_Control/SPI.h????? is not SPI/SPI.h???? So the code didn't compile. and the build out is as fellows:

earching for Board description file (boards.txt) ... /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/boards.txt
Searching for Arduino lib version file (version.txt) ... /Applications/Arduino.app/Contents/Resources/Java/lib/version.txt
Detecting Arduino software version ...  1.0.5 (1.0.5)
Searching for Arduino core library ... /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino
Searching for Arduino standard libraries ... /Applications/Arduino.app/Contents/Resources/Java/libraries
Searching for Arduino variants directory ... /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/variants
Searching for make ... /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/make
Searching for avr-gcc ... /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-gcc
Searching for avr-g++ ... /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-g++
Searching for avr-ar ... /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar
Searching for avr-objcopy ... /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-objcopy
src/sketch.ino
Searching for Arduino lib version file (version.txt) ... /Applications/Arduino.app/Contents/Resources/Java/lib/version.txt
Detecting Arduino software version ...  1.0.5 (1.0.5)
Scanning dependencies of src
Scanning dependencies of arduino
Scanning dependencies of Robot_Control
src/sketch.cpp
Robot_Control/glcdfont.c
Robot_Control/utility/twi.c
Robot_Control/Adafruit_GFX.cpp
Robot_Control/Arduino_LCD.cpp
Robot_Control/ArduinoRobot.cpp
/Applications/Arduino.app/Contents/Resources/Java/libraries/Robot_Control/ArduinoRobot.cpp: In constructor 'RobotControl::RobotControl()':
/Applications/Arduino.app/Contents/Resources/Java/libraries/Robot_Control/ArduinoRobot.cpp:8: error: 'LCD_CS' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Robot_Control/ArduinoRobot.cpp:8: error: 'DC_LCD' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Robot_Control/ArduinoRobot.cpp:8: error: 'RST_LCD' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Robot_Control/ArduinoRobot.cpp: In member function 'void RobotControl::begin()':
/Applications/Arduino.app/Contents/Resources/Java/libraries/Robot_Control/ArduinoRobot.cpp:18: error: 'MUXA' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Robot_Control/ArduinoRobot.cpp:18: error: 'MUXB' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Robot_Control/ArduinoRobot.cpp:18: error: 'MUXC' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Robot_Control/ArduinoRobot.cpp:18: error: 'MUXD' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Robot_Control/ArduinoRobot.cpp:19: error: 'MUX_IN' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Robot_Control/ArduinoRobot.cpp:22: error: 'BUZZ' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Robot_Control/ArduinoRobot.cpp:25: error: 'Serial1' was not declared in this scope
make: *** [.build/uno/Robot_Control/ArduinoRobot.o] Error 1
Make failed with code 2

Oh, my work environment is OS X 10.8.5,Arduino IDE 1.0.5,Arduino uno r3

Any clues on this one?

Thanx

nophead commented 10 years ago

I don't know why but I had the same problem. Robot_Control seemed to get used for no reason at all and would not compile. I deleted it and then had to delete .build and it would then compile without that library.

In general ino seems to try to compile dependencies that are not actually used because they are inside #if something false.

hoosierEE commented 10 years ago

This is because when Ino uses the first SPI.h it finds (when searching alphabetically, Robot comes before SPI), regardless of the parent directory. I ran into this when trying to include SPI.h and noticed others have the same problem.

As a workaround, I copied SPI.h from /usr/share/arduino/libraries/SPI/SPI.h (Ubuntu) into my ino project's lib directory, then included it as such:

#include "../lib/SPI.h"

This lets me compile at least, but it would be great if Ino was a little smarter about #include-ing.

nophead commented 10 years ago

Ah, so there are actually two problems: One it finds include files from the wrong library and two it processes includes inside preprocessor conditional blocks that are false.

ghost commented 10 years ago

@hoosierEE I saw the resolve of #134 ,Whether can consider to set a fixed order about dependencies of the core library.

hoosierEE commented 10 years ago

Hey @commissar this fixed it for me, I can ino build without errors now. Thanks!