10 Tips for Building a Native Shared Library

Who doesn’t love a good API? SmartFile sure does! That’s one of the reasons we created the SmartFile API with 38 endpoints for our developer product!

We learned many things while created the SmartFIle for Developer API. Here are a few things to keep in mind when building a native shared library:

  • Choose a programming language that it does not pull in the whole runtime that takes up CPU and memory.
  • Avoid global state if you can. Use “context objects” instead.
  • Do not define common types in public headers.
  • Headers should be light on “includes”. Consider adding a way to disable all includes through a define.
  • Do not expose symbols you do not want exposed in your namespace.
  • Create a macro, like YL_API , that prefixes each symbol you want to expose.
  • Try to build a stable ABI.
  • Do not go overboard with structs.
  • Allow customized memory allocators. If you can’t do it per “context” object, at least do it per library!
  • Don’t force users to use your favorite build tool.

Hopefully this list will help you build your own native library. In the meantime, feel free to get your own SmartFile API key! Acccessing it is easy once you’ve signed up for a free SmartFile for Developers account. As an added bonus, the first three thousand users to signup receive 100GB of space as a thank you. Other features of SmartFile for Developers include five different SDKs, Live Documentation, and OAuth.

Image Credit: Flickr, the_tahoe_guy

SmartFile is a business file mangement platform that gives you more control, compliance and security.