
Ask HN: Resources for developing multi-platform native code libraries? - ahpaja
Can anyone recommend any course, books or learning materials when it comes to developing low-level and multi-platform native code libraries? Are there standard industry practices when it comes to building, packaging, and deploying native code libraries? It seems like a great skill to have, and I’d like to be better at it.<p>For context, I work in the mobile game industry developing for iOS and Android phones in a multi-platform (Mac, Window, Linux) development environment. You can do a lot without having to worry about writing low level code, but every once in a while, it becomes necessary. I have a basic working knowledge of these things, and of course, there are many case-by-case considerations when dealing with a device’s specific architecture, but much of my knowledge around this stuff is cobbled together from all sorts of different sources over the years. Anything more formal?<p>It seems like CMake and its reference guide is actually the closest and most informative thing that I have found in this ballpark. Any other recommendations or go-to sources for this kind software development?
======
generic_user
I will assume by 'low level' you mean C/C++. Writing cross platform code at
the system interface level is usually only something you do because you have
to not something you do because you want to. It can be quite tedious and some
times close to impossible. lets narrow the question to just C. And lets also
narrow the specification to 'native' system interfaces. Lets also limit our
operating systems to UNIX, Linux and Windows.

The goal of standardisation for C was in part to aid portability. That worked
out to some degree. So thats the best place to start. The goal of POSIX was to
standardize UNIX system interfaces across the various flavors. That worked out
to some degree also. You also need to to get the interfaces for Windows, Linux
and so forth because they all have various 'innovations' that have been
created which are not adherent to any standard or portable.

At a minimum you should become familiar with the fallowing material.

* ISO/IEC 9899:1999 - ISO/IEC 9899:2011 [http://www.open-std.org/jtc1/sc22/wg14/](http://www.open-std.org/jtc1/sc22/wg14/)

* POSIX.1-2008 / IEEE Std 1003.1 [http://pubs.opengroup.org/onlinepubs/9699919799/](http://pubs.opengroup.org/onlinepubs/9699919799/)

* Linux system interfaces [http://man7.org/linux/man-pages/](http://man7.org/linux/man-pages/)

* Win API/Win32 API [https://msdn.microsoft.com/en-us/library/windows/desktop/ff8...](https://msdn.microsoft.com/en-us/library/windows/desktop/ff818516\(v=vs.85\).aspx)

Thats a lot of reading. A good starting point for a project is to code to the
C standard and one abstract interface that wraps your main target OS. Then
port portions of the implamentation for your interface to the various systems
you need to run on. In reality there are a lot of specific factors that you
need to take into account to design your portability strategy.

~~~
ahpaja
Thanks very much for this! I have been poking around a bit this week and this
is indeed what I need. :)

More importantly, where you say "A good starting point for a project..." is
exactly the kind of know-how and practical advice that I have found hard to
come by in this area of software engineering. Any idea on where to find more
of it (blogs, articles) would be always welcome.

