#Build odin lib for use in iOS

10 messages · Page 1 of 1 (latest)

crisp stratus
#

I am wondering if there is a way to build odin code as a static lib for use in iOS.

For example to do this with c code I can compile my code to a static library, include it in xcode and then write and obj-c header file that mirrors the api of the library.

I really want to try Odin out for a new project but really need the ability to eventually run it in iOS otherwise in the end it won't be useful for me.

lyric copper
#

is dynamic library not an option?

crisp stratus
#

I haven't ever done it with a dynamic library before (In the past iOS didn't alllow you to use and embed the dynamic library with your app but they may have changed)

Does Odin not have the ability to build to a static library and (if I am getting my terms right) allow access to that lib through the c abi?

lyric copper
#

you can do that, you have to compile an object file and archive it manually tho

#

the extra hassle is that you need to initialize the runtime (init and fini code, global constructors and etc), although my humble experiments worked without it just alright

crisp stratus
#

Okay so I have been looking at the build options and it looks like I could do something like this:

odin build -build-mode:static -microarch:"?"

And then I would get a static lib but if I then want to link that static lib as part of the compilation of an iOS or just another c application what would I do for the .h file? If I create that .h file correctly does it just work?

I will just assume that theoretically the microarch exists.

Are you saying you have done this already?

#

I guess a more generalized version of my question is how does one call/bind to odin code from another language?

cedar crag
#

If I remember correctly Apple's build process is geared toward dynamic libs, not static.

#

For your use-case (which sounds more prototype/speculative) it's not yet worth the headache to try to use static libs on Apple platforms.

#

dlopen dlsym and keep moving. Declare your procs proc "c" () {} and take a shot at lining up the stdint.h types with those in your compiled Odin.