Building a dylib?

Archives Forums/MacOS X Discussion/Building a dylib?

markcw(Posted 2014) [#1]
I'm trying to build a dylib on Mac 10.6 for Openb3d and have managed to get it to load in Max by specifying 32bit compilation flags, either -m32 or -arch i386 will work. Max wouldn't load the 64bit lib at all. I still have problems though, it seems some things aren't working like half lit objects and no shadows but I can't think of anything else to try now, so I thought I'd ask. Does anyone know what you need to do to get a library built on Mac that works with Max? Maybe it needs some other compiler arguments or maybe another framework?


markcw(Posted 2014) [#2]
Well I've narrowed it down a bit. I built it on Windows and it has the same half lit objects with no shadows as well, but the same code on ubuntu is fine so it's something to do with GLee as the linux version doesn't use GLee.

It looks like it's not using GLee at all, so maybe my code in the makefile for building GLee is wrong. It doesn't seem to be the -m32 option as I just removed that and it was still the same, so the only other thing is the way I'm including GLee. It works when I link to GLee (like #include <gl\GLee.h>) but not when I add it to the makefile (like #include "GLee.h").


markcw(Posted 2014) [#3]
Well now it looks like GLee won't work unless it's linked to as a shared library but I don't know how to go about that on Mac as there's no instructions. Can you just put it in OpenGL.framework? I tried but it didn't work. Do I need to build GLee.lib for Mac?


Brucey(Posted 2014) [#4]
I'm afraid I can't answer most of your questions... :-p

Does anyone know what you need to do to get a library built on Mac that works with Max?

-shared and -arch i386 should generally be enough, used in both the compilation and linking.
You'd call it something like libminib3d.dylib
and link to it in BlitzMax with something like -lminib3d


markcw(Posted 2014) [#5]
Thanks that's very helpful.

I thought on Mac you couldn't use -lminib3d and had to use -framework something. Is there a general shared include and lib folder on Mac?


Brucey(Posted 2014) [#6]
I thought on Mac you couldn't use -lminib3d

You'll find -l used on a lot of my modules which have 3rd-party shared objects (bass, fmod and irrlicht are three examples).

-framework is used for actual frameworks, which are something else.

Is there a general shared include and lib folder on Mac?

Yes, they are much in the same places as on Linux, but you don't need to use them for 3rd-party libs you want to ship with your app, as you can store everything in the app bundle. (assuming it's a GUI app you are making, of course).


markcw(Posted 2014) [#7]
Thanks, that helps a lot.


markcw(Posted 2014) [#8]
More dumb questions! :P

Is it possible to create a glee.a file with BlitzMax that is just code from a glee.c file (and glee.h)? So I could link to it from the makefile. I tried using import "GLee.c" but it builds it all into the app.

I am thinking maybe there's some compiler flags Max uses that would make GLee (or Openb3d) work properly. Since the source wrapper works fine.

I see there is a GLee.a file in ofx.mod here.

Edit: well I tried that and it's version 5.21 and it wouldn't compile.


markcw(Posted 2014) [#9]
Ok, I got it working. I did a stupid thing. I remove the stencilbuffer and alphabuffer flags from graphics3d and managed to not realize shadows won't work without the stencil buffer. Doh!