DMD + Dynamic Library.

Damien Gibson via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Mar 7 20:30:21 PST 2017


Hi everyone. My first post here - I'm not one to usually resort 
to trying to ask forums directly for help but I'm a bit desperate 
at this point as I have wasted about 3 days in total of no-life 
googling trying to figure something out here.

My current setup works fine for creation of EXE's and Static 
libs. Dynamic libs are the only problem. I have some libraries I 
created and used just fine with static libs that I'd like to 
start using dynamically as managing them with multiple projects 
has just become too cumbersome.

My setup uses Mono-D using -shared and -H(-shared should already 
be called as it already generated .lib and .dll files but I added 
again just in case) and creating a new EXE project and trying to 
use the functions from the generated .di files works fine -> As 
long as the lib was generated static. While attempting to use 
dynamic generated .lib I always get the error "Library Reference 
Missing".

On each of my source files I've attempted adding export 
extern(D): right after Module declaration(Which again works just 
fine when using static edition of .lib) as well as I've used this 
for the dllmain (Which has only been modified slightly from the 
ones in guides)

version(Windows) {
	import core.sys.windows.windows : HINSTANCE;
	extern(Windows)	bool DllMain(HINSTANCE hInstance, uint ulReason, 
void* reserved) {
		import core.sys.windows.dll, core.sys.windows.windows;
		switch(ulReason) {
			default: assert(0);
			case DLL_PROCESS_ATTACH: return dll_process_attach( hInstance, 
true );
			case DLL_PROCESS_DETACH: dll_process_detach( hInstance, true 
);	return true;
			case DLL_THREAD_ATTACH:	return dll_thread_attach( true, true );
			case DLL_THREAD_DETACH:	return dll_thread_detach( true, true );
		}
	}
}


I've compiled EVERYTHING into x32 for windows and this being of 
course with the latest dmd2 compiler.

I'm all out of ideas here. From some of the threads I've come 
across researching the .def files that were in the main guides 
aren't needed as long as using the export extern(D): however 
whether or not they are actually needed or not -> Either the 
compiler or linker were throwing errors(I cant remember which).

I've even tried running .def made for example modules as well and 
it gave the same error so i know i wasn't just making it 
improperly.

I'm literally a couple tests from pulling my hair out so any 
wisdom on this issue would be greatly appreciated!


More information about the Digitalmars-d-learn mailing list