arduino / Arduino

Arduino IDE 1.x
https://www.arduino.cc/en/software
Other
14.16k stars 7.01k forks source link

Relative includes of libaries will not work anymore (1.6.11) #5296

Closed rkost closed 8 years ago

rkost commented 8 years ago

Got compiling issues when upgrading from 1.6.9 to 1.6.11: Following (very simple) code:

mainFile.ino

#include "internals/Servo.h"

Servo servo;

void setup()
{
  servo.attach(6, 0, 160); // Numbers doesn't matter...
}

void loop()
{
  servo.write(20);
}

In the directory anywhere/mainFile/internals/ are the three files Servo.h, Servo.cpp, ServoTimers.h with some adjustments to the includes and timers (they are copied from the original Arduino 1.6.9 lib (anyhere/arduino1611/libraries/Servo/src/andSoOn). See attachments for these files: Servo.zip

This code compiles completly fine with ardunino 1.6.9 but not with arduino 1.6.11 using this command: arduino169 --board arduino:avr:mega:cpu=atmega2560 --verify ./mainFile/mainFile.ino (while arduino169 is a soft link to the arduino executable) but failing when compiling on 1.6.11 (doesn't matter if from command line or from IDE's GUI).

Output for 1.6.11:

Picked up JAVA_TOOL_OPTIONS: 
Loading configuration...
Initializing packages...
Preparing boards...
Verifying...
/tmp/ccLxdyd8.ltrans0.ltrans.o: In function `main':
ccLxdyd8.ltrans0.o:(.text.startup+0xf0): undefined reference to `Servo::attach(int, int, int)'
ccLxdyd8.ltrans0.o:(.text.startup+0x100): undefined reference to `Servo::write(int)'
/tmp/ccLxdyd8.ltrans0.ltrans.o: In function `_GLOBAL__sub_I_servo':
ccLxdyd8.ltrans0.o:(.text.startup+0x112): undefined reference to `Servo::Servo()'
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.

Any suggests? What am I missing?

rkost commented 8 years ago

Just note that changing #include "internals/Servo.h" to #include <Servo.h> is doing fine.

matthijskooijman commented 8 years ago

Since 1.6.10, only .cpp files in (subdirectories of) the src/ subdirectory will be compiled, so you'll have to move your internals directory into src. This should also work with earlier versions. I'll go ahead and close this, assuming my answer solves your issue. Feel free to leave a comment if not, then we can reopen.

rkost commented 8 years ago

Okay, that was pretty straightforward. Thanks for helping me out on this. Is there any chance to get information about this kind of changes. Don't want to ask silly questions when information is available (could not find them in release notes).

matthijskooijman commented 8 years ago

Yeah, this should have been made more clear in the release notes. I already pointed this out, but apparently the release notes were not yet updated. @cmaglie, did you have any plans for this still?