I know how to create my own arduino library and use it. I am using Xcode to create a c++ project. I have the arduino library files(Servo, Wire, Keypad, etc). If I want to include the Servo.h library file in my created library, how do I go about linking that? For some reason, I can't just add the Servo.h/.cpp files in my project because then I get other linking file problems that Servo.h references and are not linked in my project. Has anyone done this before?

1 Answer 1


I can't speak for Xcode, but in general with Arduino IDEs (UECIDE excepting) if you use a library within another library, that library also has to be #included in the main sketch. That is the only way most IDEs determine which libraries need to be compiled into the finished program.

That's one of the first targets I had for UECIDE - to enable fully recursive library compilation. Any libraries found within the master header of a library will also be included for compilation - and any found in those libraries, etc. It took a lot of work (and it's by no means 100% perfect), which is why so few others do it and leave it up to the programmer to ensure the inclusion of the right sub-libraries in their sketch.

  • Yea, I guess I was just asking in general not necessarily with Xcode. If I were using Visual Studios, is there anyway I can use the current arduino library files (h/cpp) in my own library I am creating to be able to compile it before using? If I add, for example, Servo.h to my library it does not compile as there are other files Servo.h links to that I do not. Just seeing if there is an easy way to add other library files to my project to be able to compile.
    – JEB
    Dec 17, 2014 at 17:00
  • No, it takes an intelligent IDE that properly understands the concept of the Arduino library to do that. If the libraries were all pre-compiled code as .a files you'd still need to manually add all the -l... flags to the linker command, so it's not something that's unique to the Arduinosphere. We just have a different way of telling the IDE what libraries need including (#include) than "normal" systems (which would equate to -lservo -lkeyboard etc)
    – Majenko
    Dec 17, 2014 at 17:03
  • Believe I have accomplished what I wanted to do. Using the VS Visual Micro plugin.
    – JEB
    Dec 17, 2014 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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