1

I created this question because I find many questions with similar problems, so I wanted to provide a reference/ more generic question for these type of problems.

For my projects I have installed 3rd party libraries by cloning from the library's git repository into the folder that preferences.txt's sketchbook.path value exists into a folder named libraries. In other words if the sketchbook.path has the value /home/myuser/sketchbook I clone the repositories into the folder /home/myuser/sketchbook/libraries.

Then on the folder /home/myuser/sketchbook/myexample I store my code myexample.ino that needs a library with header files Something.h.

While I click on Arduino IDE the verify button I get the error:

/usr/share/arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions 
    -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD 
    -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -D__PROG_TYPES_COMPAT__         
    -I/usr/share/arduino/hardware/arduino/cores/arduino 
    -I/usr/share/arduino/hardware/arduino/variants/standard 
    -I/usr/share/arduino/libraries/SPI 
    /tmp/build6596169359663087897.tmp/LoRaSerialGateway.cpp -o 
    /tmp/build6596169359663087897.tmp/LoRaSerialGateway.cpp.o 
LoRaSerialGateway.ino:15:18: fatal error: Something.h: 
compilation terminated.

So my guess is that I cannot make avr-gcc to compile using the 3rd party library. Do you know how to pass into avr-gcc the correct paths for the appropriate libraries?

1
  • 1
    The Arduino IDE will handle it, provided the libraries are actually installed via the IDE. Apr 24, 2018 at 21:41

2 Answers 2

1

Assuming you have a working library system already, i.e., there are some libraries in .../libraries now and they compile properly or at least the compiler are successfully finds them; and you want to add another library, say "CrashAndBurn.h" and "CrashAndBurn.cpp", you need to put those two files into a folder named .../libraries/CrashAndBurn/. Then in your sketch, you add an include directive #include <CrashAndBurn.h>.

An alternative is to put the .h and .cpp files somewhere else, such as a folder under your project folder, and modify the include directive to point to them, as #include "libs/CrashAndBurn.h", where the libs folder is within the sketch folder. Or you could put them in any folder, anywhere, and write an absolute path to them: /home/some/place/else/CrashAndBurn.h

1

Sometimes you should modify a bit the library's file stricture in case of this library in order to make it avaialble I moved the code in folder ./src outside to the project's root folder.

Also an another problem is that you may use older version of the ide. Especially this can happen in GNU/Linux if you install the arduino ide from the distribution's repositories.

3
  • just rename the folder from zip to LoRa in libraries. no need to move files
    – Juraj
    Apr 25, 2018 at 9:32
  • I used the git method. Apr 25, 2018 at 9:32
  • I create file system link from git folder to libraries folder, with the correct library name
    – Juraj
    Apr 25, 2018 at 9:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.