Functional Overview Cocotron Differences Platform Specific Resources Optional Libraries Sharing Modifications

Frameworks and OBJCRegisterDLL on Windows

** Warning, this will be automatic in the future so don't customize the code if you don't have to.

If you are compiling frameworks for Windows, you will need this code somewhere in it. I recommend creating a file dllmain.m and adding it to the Windows target only. This only applies to frameworks which are you linking the .exe against, bundles don't need it.

#import <windows.h>

__declspec(dllimport) int OBJCRegisterDLL(HINSTANCE handle);

int APIENTRY DllMain(HINSTANCE handle,DWORD reason,LPVOID _reserved) {

   if(reason==DLL_PROCESS_ATTACH)
    return OBJCRegisterDLL(handle);

   return TRUE;
}

Whenever a DLL is loaded/unloaded, etc, the Windows linking system calls DllMain to do any initialization. The Objective-C runtime needs the 'handle' argument to generate the .dll<->class mapping.