Including external libraries in modules

Started by bgardon, February 03, 2017, 01:53:14 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

bgardon

I'm working on developing some extensions to an existing module and I want to include an external library. I've finally figured out how to get my code to link against the library, however standard library functions in the library such as malloc do not seem to have anything to link against since the implementation of those functions in ML seems to be a bit different (malloc, for example, appears to be a macro). Does anyone know how I could get the library working with the standard library functions it needs without having to go through and include dryos.h or something in all the library source files?

a1ex

Lua includes a subset of dietlibc, so you can look there for an example.

You may be also interested in these (they use external libraries as well):
https://bitbucket.org/hudson/magic-lantern/pull-requests/705
https://bitbucket.org/hudson/magic-lantern/branch/hdparm
https://bitbucket.org/hudson/magic-lantern/src/unified/modules/tinypy/
http://www.magiclantern.fm/forum/index.php?topic=14853.0

Currently, malloc is defined as a macro, but other than that, it works as plain malloc (so you could try to include mem.h in your library). Unless you have a good reason to use a custom allocator (we had for Lua).

I'd also like to have more stdlib functionality in ML core, so any help is welcome in this direction.