Open jminardi opened 10 years ago
I am having the same issue including the Xbee library. I have tried with the library in the lib/ directory and placing the files alongside the sketch:
pi@raspberrypi ~/ino/settop_controller_box $ tree
.
├── lib
│ ├── XBee.cpp
│ └── XBee.h
└── src
└── sketch.ino
2 directories, 3 files
pi@raspberrypi ~/ino/settop_controller_box $ ino build
src/sketch.cpp
.build/uno/src/sketch.cpp:2:18: fatal error: XBee.h: No such file or directory
compilation terminated.
make: *** [.build/uno/src/sketch.o] Error 1
Make failed with code 2
pi@raspberrypi ~/ino/settop_controller_box $ mv lib/XBee.* src/
pi@raspberrypi ~/ino/settop_controller_box $ tree
.
├── lib
└── src
├── sketch.ino
├── XBee.cpp
└── XBee.h
2 directories, 3 files
pi@raspberrypi ~/ino/settop_controller_box $ ino build
src/sketch.cpp
.build/uno/src/sketch.cpp:2:18: fatal error: XBee.h: No such file or directory
compilation terminated.
make: *** [.build/uno/src/sketch.o] Error 1
Make failed with code 2
pi@raspberrypi ~/ino/settop_controller_box $
I was able to build and load my script using the arduino GUI, so the problem only exists with the ino
command line tool.
I have the same problem. I think the problem is when ino generates the dependencies it does not include the options passed with --cflags or --cxxflags. If you repeat the dependency step by hand (after correcting the command), then you can invoke ino build with the proper options again and the build finishes correctly.
Here is a sample session:
$ ino build -v --cxxflags=-I${PWD}/lib --ldflags=-L${PWD}/lib # this fails
$ /usr/lib64/ccache/avr-gcc [options ino used last time] -I${PWD}/lib \
-MM .build/uno/src/sketch.cpp > .build/uno/src/sketch.d
$ ino build -v --cxxflags=-I${PWD}/lib --ldflags=-L${PWD}/lib # this succeeds
So I guess that means commands/build.py
has a bug! If someone can
point me to the method responsible for the dependency command, I can
take a look.
@ciasaboark Did you try your second attempt with the option --cxxflags=-I$PWD/src
? I just tried, and it worked. That said, this is just a temporary work around. There is a bug in the dependency generation which should be fixed.
I just tried it. The compile succeeds, but the linker fails when linking to the 3rd party library. The sketch builds fine using the arduino ide, so I suppose I can just scp the hex file over for now.
pi@raspberrypi ~/ino/settop_controller_box $ ino build -v --cxxflags=-I${PWD}/lib --ldflags=-L${PWD}/lib
src/sketch.cpp
/usr/bin/avr-g++ -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=101 -I/usr/share/arduino/hardware/arduino/cores/arduino -ffunction-sections -fdata-sections -g -Os -w -I/usr/share/arduino/hardware/arduino/variants/standard -I/usr/share/arduino/libraries/SoftwareSerial -I/usr/share/arduino/hardware/arduino/cores/arduino -I/home/pi/ino/settop_controller_box/lib -iquote src -o .build/uno/src/sketch.o -c .build/uno/src/sketch.cpp
SoftwareSerial/SoftwareSerial.cpp
/usr/bin/avr-g++ -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=101 -I/usr/share/arduino/hardware/arduino/cores/arduino -ffunction-sections -fdata-sections -g -Os -w -I/usr/share/arduino/hardware/arduino/variants/standard -I/usr/share/arduino/libraries/SoftwareSerial -I/usr/share/arduino/hardware/arduino/cores/arduino -I/home/pi/ino/settop_controller_box/lib -o .build/uno/SoftwareSerial/SoftwareSerial.o -c /usr/share/arduino/libraries/SoftwareSerial/SoftwareSerial.cpp
Linking libSoftwareSerial.a
/usr/bin/avr-ar rcs .build/uno/SoftwareSerial/libSoftwareSerial.a .build/uno/SoftwareSerial/SoftwareSerial.o
<snip>
arduino/WString.cpp
/usr/bin/avr-g++ -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=101 -I/usr/share/arduino/hardware/arduino/cores/arduino -ffunction-sections -fdata-sections -g -Os -w -I/usr/share/arduino/hardware/arduino/variants/standard -I/usr/share/arduino/libraries/SoftwareSerial -I/usr/share/arduino/hardware/arduino/cores/arduino -I/home/pi/ino/settop_controller_box/lib -o .build/uno/arduino/WString.o -c /usr/share/arduino/hardware/arduino/cores/arduino/WString.cpp
Linking libarduino.a
/usr/bin/avr-ar rcs .build/uno/arduino/libarduino.a .build/uno/arduino/wiring_shift.o .build/uno/arduino/wiring_digital.o .build/uno/arduino/WInterrupts.o .build/uno/arduino/wiring_analog.o .build/uno/arduino/wiring.o .build/uno/arduino/wiring_pulse.o .build/uno/arduino/Stream.o .build/uno/arduino/WMath.o .build/uno/arduino/CDC.o .build/uno/arduino/HID.o .build/uno/arduino/new.o .build/uno/arduino/USBCore.o .build/uno/arduino/IPAddress.o .build/uno/arduino/Print.o .build/uno/arduino/HardwareSerial.o .build/uno/arduino/main.o .build/uno/arduino/Tone.o .build/uno/arduino/WString.o
Linking firmware.elf
/usr/bin/avr-gcc -mmcu=atmega328p -Wl,-L/home/pi/ino/settop_controller_box/lib -o .build/uno/firmware.elf .build/uno/src/sketch.o .build/uno/SoftwareSerial/libSoftwareSerial.a .build/uno/arduino/libarduino.a -lm
.build/uno/src/sketch.o: In function `_GLOBAL__sub_D_softSerial':
/home/pi/ino/settop_controller_box/src/sketch.ino:346: undefined reference to `XBee::begin(Stream&)'
/home/pi/ino/settop_controller_box/src/sketch.ino:346: undefined reference to `XBeeAddress64::XBeeAddress64(unsigned long, unsigned long)'
/home/pi/ino/settop_controller_box/src/sketch.ino:346: undefined reference to `ZBTxRequest::ZBTxRequest(XBeeAddress64&, unsigned char*, unsigned char)'
/home/pi/ino/settop_controller_box/src/sketch.ino:346: undefined reference to `XBee::send(XBeeRequest&)'
/home/pi/ino/settop_controller_box/src/sketch.ino:346: undefined reference to `XBee::readPacket(int)'
/home/pi/ino/settop_controller_box/src/sketch.ino:346: undefined reference to `XBee::getResponse()'
/home/pi/ino/settop_controller_box/src/sketch.ino:346: undefined reference to `XBeeResponse::isAvailable()'
/home/pi/ino/settop_controller_box/src/sketch.ino:346: undefined reference to `XBee::getResponse()'
/home/pi/ino/settop_controller_box/src/sketch.ino:346: undefined reference to `XBeeResponse::getApiId()'
/home/pi/ino/settop_controller_box/src/sketch.ino:346: undefined reference to `XBee::getResponse()'
/home/pi/ino/settop_controller_box/src/sketch.ino:346: undefined reference to `XBeeResponse::getZBRxResponse(XBeeResponse&)'
/home/pi/ino/settop_controller_box/src/sketch.ino:346: undefined reference to `ZBRxResponse::getOption()'
/home/pi/ino/settop_controller_box/src/sketch.ino:346: undefined reference to `ZBRxResponse::getDataLength()'
/home/pi/ino/settop_controller_box/src/sketch.ino:346: undefined reference to `RxDataResponse::getData(int)'
/home/pi/ino/settop_controller_box/src/sketch.ino:346: undefined reference to `ZBRxResponse::getDataLength()'
/home/pi/ino/settop_controller_box/src/sketch.ino:346: undefined reference to `XBee::getResponse()'
/home/pi/ino/settop_controller_box/src/sketch.ino:346: undefined reference to `XBeeResponse::getApiId()'
/home/pi/ino/settop_controller_box/src/sketch.ino:346: undefined reference to `XBee::getResponse()'
/home/pi/ino/settop_controller_box/src/sketch.ino:346: undefined reference to `XBeeResponse::getModemStatusResponse(XBeeResponse&)'
/home/pi/ino/settop_controller_box/src/sketch.ino:346: undefined reference to `ModemStatusResponse::getStatus()'
/home/pi/ino/settop_controller_box/src/sketch.ino:346: undefined reference to `ModemStatusResponse::getStatus()'
/home/pi/ino/settop_controller_box/src/sketch.ino:346: undefined reference to `XBee::getResponse()'
/home/pi/ino/settop_controller_box/src/sketch.ino:346: undefined reference to `XBeeResponse::isError()'
/home/pi/ino/settop_controller_box/src/sketch.ino:346: undefined reference to `XBee::XBee()'
/home/pi/ino/settop_controller_box/src/sketch.ino:346: undefined reference to `XBeeResponse::XBeeResponse()'
/home/pi/ino/settop_controller_box/src/sketch.ino:346: undefined reference to `ZBRxResponse::ZBRxResponse()'
/home/pi/ino/settop_controller_box/src/sketch.ino:346: undefined reference to `ModemStatusResponse::ModemStatusResponse()'
collect2: error: ld returned 1 exit status
make: *** [.build/uno/firmware.elf] Error 1
Make failed with code 2
@ciasaboark You misunderstood me. This will fail because it still needs the correct dependency file. Try the second attempt you made, with the library files in the src
directory. Like this:
$ tree
.
├── lib
└── src
├── Blink.ino
├── TinkerKit.cpp
└── TinkerKit.h
This also means there should not be a need for the flag --ldflags
.
That works, thanks for the help.
Jonathan Nelson
On Thursday, May 1, 2014 at 3:06 AM, Suvayu Ali wrote:
@ciasaboark (https://github.com/ciasaboark) You misunderstood me. This will fail because it still needs the correct dependency file. Try the second attempt you made, with the library files in the src directory. Like this: $ tree . ├── lib └── src ├── Blink.ino ├── TinkerKit.cpp └── TinkerKit.h
— Reply to this email directly or view it on GitHub (https://github.com/amperka/ino/issues/164#issuecomment-41886149).
Ok. I've tried this and works !
src ├── TinkerKit │ ├── TinkerKit.cpp │ └── TinkerKit.h └──Blink.ino
This way, the libraries can be recognized
This layout is working for me:
lib
├── TinkerKit
│ ├── TinkerKit.cpp
│ └── TinkerKit.h
src
└──Blink.ino
I had the same problem with other library. In my case, I just move ros_lib
on lib
to under src
. Then run ino build
resulting in error. Then move ros_lib
to original position of lib
. After run clean and build, it is working!
I've tried:
and the project's
lib
directory.None of these seemed to work for me. I am getting the following error: