Am I doing it wrong or is this a bug ?

Ezneh petitv.isat at gmail.com
Thu Aug 12 00:48:35 PDT 2010


Hello !

I'm doing some tests with the DLL example which is in the samples directory but I have some problem with it.


Well, when I'm compiling the DLL with that files, I got no error and it works in the test.d sample but doesn't work in another project (in another language) :

//mydll.d
module mydll;
import std.c.stdio;

export string dllprint() { return "hello"; }


//dll.d

import std.c.windows.windows;
import core.dll_helper;

__gshared HINSTANCE g_hInst;

extern (Windows)
BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved)
{
    switch (ulReason)
    {
	case DLL_PROCESS_ATTACH:
	    g_hInst = hInstance;
	    dll_process_attach( hInstance, true );
	    break;

	case DLL_PROCESS_DETACH:
	    dll_process_detach( hInstance, true );
	    break;

	case DLL_THREAD_ATTACH:
	    dll_thread_attach( true, true );
	    break;

	case DLL_THREAD_DETACH:
	    dll_thread_detach( true, true );
	    break;
    }
    return true;
}

// .def file
LIBRARY "mydll.dll"
EXETYPE NT
SUBSYSTEM WINDOWS
CODE SHARED EXECUTE
DATA WRITE

// test.d
import mydll;
import std.stdio;

int main(string args[])
{
   writeln(mydll.dllprint());
   return 0;
}


With all theses files, test.exe works well.

But when I want to use it with another programming language, I got this error :

"Cannot find the entry point for 'dllprint' in 'mydll.dll'


So, I tried to change the .def file like this :

LIBRARY "mydll.dll"
EXETYPE NT
SUBSYSTEM WINDOWS
CODE SHARED EXECUTE
DATA WRITE
EXPORTS
	dllprint

but I got this error :

D:\D\dmd\samples\d\mydll>dmd -ofmydll.dll -L/IMPLIB mydll.d dll.d mydll.def
OPTLINK (R) for Win32  Release 8.00.2
Copyright (C) Digital Mars 1989-2009  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
OPTLINK : Error 180: No Match Found for Export/ENTRY -  : dllprint
OPTLINK : Error 81: Cannot EXPORT : dllprint


So what I'm doing wrong ? Is this a bug from optlink ?


More information about the Digitalmars-d mailing list