The end goal is to allow end users/admins to be able to set program options through a combination of CLI switches (i.e. "--foo=31 --bar=0") and/or config file(s) (i.e. cat /etc/blah.conf -> "foo=31\nbar=0\n"). The language in question is c++, though that many not be greatly significant. The target is GNU/Linux on anything from ARMv6 (Raspberry Pi) through x86_64.

There are two obvious solutions, writing argc/v and conf file parsers using basic standard library functionality; OR, using an existing library like libconfig. My past practice has been to always use libraries instead of reinventing wheels; but, this is the first time I've targeted embedded platforms. That makes me wonder whether the waste and bug-risk involved in handwriting this code outweighs the benefit of fewer dependencies and possible smaller code.

The question then is, in this case, what to do? And, are there rules-of-thumb to use when evaluating the choice between library vs roll-your-own for multiplatform code?

有帮助吗?

解决方案

I understand your pain: development time/convenience versus footprint. Personally, I strongly believe that using existing packages is always beneficial in the end, as long as you choose for actively maintained packages. Libconfig seems be not-so-active, which in my book is still an acceptable state for a mature package.

For embedded Linux, with respect to footprint, you have to think about the larger picture. Is your app the only one who needs libconfig? Would other apps on the rootfs need things like libxml? In that case - use libxml. So check your rootfs for similar libraries.

Secondly, you're talking about approx. 150kB disk space. Is it really worth going through all the trouble for? There's a substantial amount of packages larger than that, so being able to strip another package from your list may be a better way to spend your efforts. Don't worry about RAM usage - that will be even less. Linux will only load code and data pages from disk when they're used.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top