www.digitalmars.com         C & C++   DMDScript  

D - [win32]How use a dll?

reply uwem <uwem_member pathlink.com> writes:
Hello!

I'm new to 'D' .. sorry for this stupid question.
1. I create a dll with a class (proceeding: D for Win32)
class test
{
export
{
this()
{
}
~this()
{
}
void doIt()
{
printf("Im the dll\n");
}
}
}

2. compile: dmd test.d test.def
3. I have: test.dll, test.map, test.obj

In c++ i have a '*.lib' file for the dll. How can i use this dll in a other
D - exe (program)?

Thanks in advance.
Bye
Uwe

My english is not the best. :-)
Dec 01 2003
parent reply Ant <Ant_member pathlink.com> writes:
In article <bqhc0g$jph$1 digitaldaemon.com>, uwem says...
Hello!

I'm new to 'D' .. sorry for this stupid question.

I'm not sure about this but it might be the same problem I had (I'm not a windows guy). You have to use the implib utility from http://www.digitalmars.com/download/freecompiler.html as I remember that will create a .lib. Ant
Dec 02 2003
parent reply uwem <uwem_member pathlink.com> writes:
In article <bqig9q$2bob$1 digitaldaemon.com>, Ant says...
I'm not sure about this but it might be the same problem I
had (I'm not a windows guy).

You have to use the implib utility from 
http://www.digitalmars.com/download/freecompiler.html
as I remember that will create a .lib.

Thanks! My proceeding: in the file 'test.d': class test { export { this() { } ~this() { } void doIt() { printf("test.doIt()\n"); } } } and the other stuff for win-dll creation compile: dmd test.d test.def implib : implib /s test.lib test.dll In the file 'testdll.d': import test; void myfunc() { test xx = new test; xx.doIt(); } compile: dmd testdll.d test.lib linker says: OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved dlltest.obj(dlltest) Error 42: Symbol undefined __Class_4test3test --- errorlevel 1 :-( Any ideas? Thanks in advance. Bye Uwe
Dec 02 2003
parent reply "Lars Ivar Igesund" <larsivar igesund.net> writes:
Have you tried to add
module test;
to the top of your test.d file?

Lars Ivar Igesund

"uwem" <uwem_member pathlink.com> wrote in message
news:bqk1gu$1ieu$1 digitaldaemon.com...
 In article <bqig9q$2bob$1 digitaldaemon.com>, Ant says...
I'm not sure about this but it might be the same problem I
had (I'm not a windows guy).

You have to use the implib utility from
http://www.digitalmars.com/download/freecompiler.html
as I remember that will create a .lib.

Thanks! My proceeding: in the file 'test.d': class test { export { this() { } ~this() { } void doIt() { printf("test.doIt()\n"); } } } and the other stuff for win-dll creation compile: dmd test.d test.def implib : implib /s test.lib test.dll In the file 'testdll.d': import test; void myfunc() { test xx = new test; xx.doIt(); } compile: dmd testdll.d test.lib linker says: OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved dlltest.obj(dlltest) Error 42: Symbol undefined __Class_4test3test --- errorlevel 1 :-( Any ideas? Thanks in advance. Bye Uwe

Dec 02 2003
parent reply uwem <uwem_member pathlink.com> writes:
In article <bqk2d9$1joc$1 digitaldaemon.com>, Lars Ivar Igesund says...
Have you tried to add
module test;
to the top of your test.d file?

Lars Ivar Igesund

Uwe
Dec 02 2003
parent "Lars Ivar Igesund" <larsivar igesund.net> writes:
Ah, I think I see your problem now. Put the export
in front of the class declaration:
export class test {
etc.

This will export both your class and the public methods of
your class. Note that when you use the export keyword,
you don't need to use a .def file.

Lars Ivar Igesund

"uwem" <uwem_member pathlink.com> wrote in message
news:bqk4i6$1mpr$1 digitaldaemon.com...
 In article <bqk2d9$1joc$1 digitaldaemon.com>, Lars Ivar Igesund says...
Have you tried to add
module test;
to the top of your test.d file?

Lars Ivar Igesund

Uwe

Dec 03 2003