creating DLL using Tango fails.

Sean Kelly sean at f4.ca
Thu Jan 17 11:42:30 PST 2008


Bjoern wrote:
> Hi,
> Subject: Creating a DLL using Tango.
> Beside / Dear Tango folks, please add some DLL info to the Tango WIKI;
> 
> My DLLMain as follows :
> 
> module dll.test;
> import tango.sys.win32.UserGdi;
> 
> extern (C) bool  rt_init( void delegate( Exception ) dg = null );
> extern (C) bool  rt_term( void delegate( Exception ) dg = null );
> HINSTANCE g_hInst;
> 
> extern (Windows)
> BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved)
> {
>     switch (ulReason)
>     {
>     case DLL_PROCESS_ATTACH:
>             rt_init();
>         break;
>     case DLL_PROCESS_DETACH:
>         rt_term();
>             break;
> 
>     case DLL_THREAD_ATTACH:
>     case DLL_THREAD_DETACH:
>         // Multiple threads not supported yet
>         return false;
>     }
>     g_hInst=hInstance;
>     return true;
> }
> 
> // a DLL func ..
> alias extern(Windows) void function(char[] token, bool eof = false)
> LexerCallBack;
> extern(Windows) export bool Lexer(LexerCallBack cb, char* code)
> {
> bla ...
> }
> 
> Is /Tangofied/   DLLMain  correct ?
> 
> My DEF
> LIBRARY "testdll.dll"
> EXETYPE NT
> SUBSYSTEM WINDOWS
> CODE SHARED EXECUTE
> DATA WRITE
> 
> DLL creating fails ....
> C:\dmd\projects>dmd -oftestdll.dll dll.d testdll.def
> C:\dmd\bin\link.exe
> dll,testdll.dll,,user32+kernel32,testdll.def/noi+tango-user-
> dmd.lib;
> OPTLINK ....
> OPTLINK : Warning 183: Extension not .RES : tango-user-dmd.lib
> C:\dmd\bin\..\lib\tango-user-dmd.lib
>  Error 30: Unexpected End of File
> 
> I use the DMD snapshots updated for 1.025. Tango only.
> 
> Any ideas ?

One of the items in DFLAGS in sc.ini is this:

-L+tango-user-dmd.lib

It's an instruction to the linker to pull in tango-user-dmd.lib.  For
whatever reason however, the linker doesn't seem to like this when
you're building a DLL.  I don't know why however, nor do I know of a
simple fix.  If someone could suggest one I'd be happy to make any
necessary changes.


Sean



More information about the Digitalmars-d mailing list