Go Down

Topic: Arduino Libary - Link Files (Read 1 time) previous topic - next topic

Reiter

Hello,

I have one question about linking the libary files.

I created a new class (testlib.cpp and testlib.h file) in the Arduino IDE. The structure auf an arduino-libary is:

Libary: root/src/testlib.cpp and root/src/testlib.h
Example: root/examples/test.ino
Keywords:  root/keywords.txt

Example of this structure: https://github.com/arduino-libraries/Stepper

I would like to use the #include "testlib.h" an i wouldn't like to use the #include "PATH/testlib.h".

When i will use this structure, i have problems to find the files in the IDE. It will run when the libary- and example files are in the same folder.

I think this is a linking-problem. i searched in google and find some answers, but these are not helpful:
write a make-file (only Linux?)
get cmake on github.


I think this is a linking-problem. i searched in google and find some answers as

write a make-file (only Linux?)
get cmake on github.

I hope somebody can help me about his problem!

pert

You need to put the library in the libraries subfolder of your sketchbook folder. You can find the location of your sketchbook folder in the Arduino IDE at File > Preferences > Sketchbook location.

{sketchbook folder}
|_libraries
   |_testlib
      |_keywords.txt
      |_library.properties
      |_examples
      |_src
         |_testlib.cpp
         |_testlib.h

Since you have the library source files under the library's src subfolder (Arduino library format 1.5), the library.properties file in the root of the library folder is required. You can find the specification for this file here:
https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#libraryproperties-file-format

After doing that, #include "testlib.h" will work fine.

Reiter

Ah, o.k.  thank you!

it depends on the library.properties.

And when i use a sublib:


i take this structure

{sketchbook folder}
|_libraries
   |_testlib
      |_keywords.txt
      |_library.properties
      |_examples
      |_src
         |_testlib.cpp
         |_testlib.h
         |_sublib
            |_sub.cpp
            |_sub.h

and not this

{sketchbook folder}
|_libraries
   |_testlib
      |_keywords.txt
      |_library.properties
      |_examples
      |_src
      |  |_testlib.cpp
      |  |_testlib.h
      |_sublib
         |_sub.cpp
         |_sub.h

pert

You're welcome.

The Arduino IDE only recognizes libraries in the 1.5 format if they have a library.properties. A library.properties file is not required for libraries in the Arduino library format 1.0 (source files in the library root folder) when using the Arduino IDE, but the Arduino Web Editor requires all libraries to have a library.properties file.

Recursive compilation of 1.5 format libraries is done only on the src folder. Withe 1.0 format libraries, compilation is only done for files in the root and utility folders.

Reiter

You're welcome.

The Arduino IDE only recognizes libraries in the 1.5 format if they have a library.properties. A library.properties file is not required for libraries in the Arduino library format 1.0 (source files in the library root folder) when using the Arduino IDE, but the Arduino Web Editor requires all libraries to have a library.properties file.

Recursive compilation of 1.5 format libraries is done only on the src folder. Withe 1.0 format libraries, compilation is only done for files in the root and utility folders.
I want include the sub-lib in the teslib, which path has the include header?

#include "sublib/sublib.h"

pert

Well, actually #include "sublib/sub.h" according to your diagram, but you got the idea.

Reiter

Well, actually #include "sublib/sub.h" according to your diagram, but you got the idea.
Thanks, I will try this in the afternoon.

Reiter

Thanks, I will try this in the afternoon.
FIX IT, with the properties file!!

Go Up