Build OF as a DLL under windows

I have a couple of custom libraries which use OF code and are built as dlls. Since OF is a static lib each dll get linked with a static copy of OF which means that any static OF variables can potentially contain different values as each dll has it’s own copy of the library. Is this a problem? I’ve run into this issue before and usually solve it by creating all libraries as dlls. However there does not seem to be support for building OF as a dll under Windows.

Any suggestions would be appreciated.

1 Like

So since I did not get an answer I went ahead and refactored the code and now can build OF as a DLL under windows and android. Pretty straight forward, although quite a pain. But now I can actually write code as plugins against OF,.

2 Likes

Oh wow that’s pretty awesome. Do you have the modifications you made on your repo?

I think Arturo did something already to build openFrameworks as a DLL:

Hi there, what’s the state on this? Is there a way to configure the OF build to generate a DLL?

I’m guessing (please confirm) @ceebee7777’s modifications were adding dllexport definitions all over OF… which does look like a pain.

Best!

Extremely interested that anybody else is looking into this
Exporting symbols on gcc/clang based systems is possible from build flags alone

on windows you need to manually export symbols
right now i use a super-duper hacky approach to this:

have been thinking of ways to generate these def file, or a way to include oF into a class which is exported, e.g. oF::ofImage, oF::ofTrueTypeFont, etc. But that would make incompatabilities with addons.

would love if we considered marking evrything up with OF_EXPORTS and a compile time flag would activate them all. i completely didn’t think anybody else would want this so i didn’t even dare to ask :slight_smile:

p.s.

Elliot

CMake and other builders do auto-generate a Windows .def for you. I think someone is maintaining a CMake OF fork but can’t find it now

Still, all statics / globals do need EXPORT decorations

@ceebee7777 Hi, I’m trying to build OF as a DLL as well.[quote=“ceebee7777, post:2, topic:19019”]
I went ahead and refactored the code
[/quote]

Could you please elaborate more on how you refactored the code?
Did you add dllexport definitions all over OF?
Thanks!