www.digitalmars.com         C & C++   DMDScript  

D - DLLs

reply C <dont respond.com> writes:
Im trying to create a DLL, Ill just run through a quick example.  Given =

the file FX.d

import std.c.stdio;

class Foo{

	this() {}
	void doCrap() { puts("HERE"); }
}

I compile and create the object file , I then use Burtons omfListExports=
 =

to create the definition file


EXPORTS
D2FX3Foo5_ctorFZC2FX3Foo
D2FX3Foo6doCrapFZv


, which works great except when trying to link to the lib i get this err=
or

foo.obj(foo)
  Error 42: Symbol Undefined __Class_2FX3Foo

Where foo is just a class that instaitaes Foo and tries the method.  I t=
ry =

adding this definition to the .def file but get

OPTLINK : Error 180: No Match Found for Export/ENTRY -  : __Class_2FX3Fo=
o
OPTLINK : Error 81: Cannot EXPORT : __Class_2FX3Foo

I try prepending it with D2 , but same error.

How should I proceed ?

Thanks,
Charlie

-- =

D Newsgroup.
Mar 26 2004
parent reply C <dont respond.com> writes:
A tad more info

file FX.d is linked with FX_dll_main.d ( and the .def file ) which reads=


import std.c.windows.windows;

extern (C) void gc_init();
extern (C) void gc_term();
extern (C) void _minit();
extern (C) void _moduleCtor();
extern (C) void _moduleUnitTests();

extern(Windows)
BOOL DllMain(HINSTANCE hinst, ULONG reason, LPVOID reserved)
{
     switch (reason)
     {
         case DLL_PROCESS_ATTACH:
             gc_init ();
             _minit ();
             _moduleCtor ();
             _moduleUnitTests ();
             break;

         case DLL_PROCESS_DETACH:
             gc_term ();
             break;
     }

     return true;
}

I get this __Class not defined error if I use digc directly or my own =

rolled version.


C

On Fri, 26 Mar 2004 23:41:33 -0800, C <dont respond.com> wrote:

 Im trying to create a DLL, Ill just run through a quick example.  Give=
n =
 the file FX.d

 import std.c.stdio;

 class Foo{

 	this() {}
 	void doCrap() { puts("HERE"); }
 }

 I compile and create the object file , I then use Burtons omfListExpor=
ts =
 to create the definition file


 EXPORTS
 D2FX3Foo5_ctorFZC2FX3Foo
 D2FX3Foo6doCrapFZv


 , which works great except when trying to link to the lib i get this =
 error

 foo.obj(foo)
   Error 42: Symbol Undefined __Class_2FX3Foo

 Where foo is just a class that instaitaes Foo and tries the method.  I=
=
 try adding this definition to the .def file but get

 OPTLINK : Error 180: No Match Found for Export/ENTRY -  : __Class_2FX3=
Foo
 OPTLINK : Error 81: Cannot EXPORT : __Class_2FX3Foo

 I try prepending it with D2 , but same error.

 How should I proceed ?

 Thanks,
 Charlie
-- = D Newsgroup.
Mar 26 2004
parent reply Vathix <vathix dprogramming.com> writes:
I had a problem with this awhile back, and came to no conclusion. But 
just now, I finally got it to link, but the program causes an access 
violation.

I don't think export is working on classes, but it does work on member 
functions. To get it to export the class, I had to do what you tried in 
the dll exports in the def file, but remove one leading underscore:
_Class_2FX3Foo
I then created the dll, and used implib -a on it (to put the underscore 
back on) and it linked.

-- 
Christopher E. Miller
Mar 27 2004
parent reply Vathix <vathix dprogramming.com> writes:
Vathix wrote:
 I had a problem with this awhile back, and came to no conclusion. But 
 just now, I finally got it to link, but the program causes an access 
 violation.
 
 I don't think export is working on classes, but it does work on member 
 functions. To get it to export the class, I had to do what you tried in 
 the dll exports in the def file, but remove one leading underscore:
 _Class_2FX3Foo
 I then created the dll, and used implib -a on it (to put the underscore 
 back on) and it linked.
 
implib -a is for borland, for digital mars it's implib /s -- Christopher E. Miller
Mar 27 2004
parent C <dont respond.com> writes:
Yea that links alright , then using the -L/IMPLIB:FX.lib linker flag i g=
et

The procedure entry point _Class_2FX3Foo coud not be located in the dll =

FX.dll

for foo.exe ( thats linked against FX.lib ).

Using implib /s FX.lib FX.dll

I then try to link to fx.lib and get

__Class undefined for foo.obj.

Seems an issue that needs some attention ?

Charles

On Sun, 28 Mar 2004 00:59:46 -0500, Vathix <vathix dprogramming.com> wro=
te:

 Vathix wrote:
 I had a problem with this awhile back, and came to no conclusion. But=
=
 just now, I finally got it to link, but the program causes an access =
 violation.

 I don't think export is working on classes, but it does work on membe=
r =
 functions. To get it to export the class, I had to do what you tried =
in =
 the dll exports in the def file, but remove one leading underscore:
 _Class_2FX3Foo
 I then created the dll, and used implib -a on it (to put the undersco=
re =
 back on) and it linked.
implib -a is for borland, for digital mars it's implib /s
-- = D Newsgroup.
Mar 28 2004