October 03, 2004
Hi,
I have noticed that there are many windows api's that are not included by import
std.windows.windows. This isn't too much of a problem since I can write my own
code to declare the api functions I need, however, when trying to link my
program to the .lib files, the linker can't find the api functions!

For example, I am trying to write a program that uses threads through the
CreateThread api function.
I decleared the function like this:
extern (Windows) HANDLE CreateThread(int,int,int delegate(),int,int,int);
and also tried it like this:
extern (Windows) HANDLE CreateThread(int,int,int,int,int,int);

I compiled it like this:
dmd picsampler.d comm sampler graph gdi32.lib user32.lib kernel32.lib
(comm, sampler, & graph are my own modules)

And I get this error message:
Error 42: Symbol Undefined __D7sampler7Sampler12CreateThreadWiiDWZiiiiZT3std1c7
windows7windows6HANDLE@28
--- errorlevel 1

CreateThread should be defined in kernel32.lib. Can anyone help? I have done this with other api's and they have worked fine.


October 03, 2004
Shane wrote:
> Hi,
> I have noticed that there are many windows api's that are not included by import
> std.windows.windows. This isn't too much of a problem since I can write my own
> code to declare the api functions I need, however, when trying to link my
> program to the .lib files, the linker can't find the api functions!
> 
> For example, I am trying to write a program that uses threads through the
> CreateThread api function.
> I decleared the function like this:
> extern (Windows) HANDLE CreateThread(int,int,int delegate(),int,int,int);
> and also tried it like this:
> extern (Windows) HANDLE CreateThread(int,int,int,int,int,int);
> 
> I compiled it like this:
> dmd picsampler.d comm sampler graph gdi32.lib user32.lib kernel32.lib (comm, sampler, & graph are my own modules)
> 
> And I get this error message:
> Error 42: Symbol Undefined __D7sampler7Sampler12CreateThreadWiiDWZiiiiZT3std1c7
> windows7windows6HANDLE@28
> --- errorlevel 1
> 
> CreateThread should be defined in kernel32.lib. Can anyone help? I have done
> this with other api's and they have worked fine.
> 
> 

I did:

----- begin createthread.d -----

module createthread;

typedef void* winHandle;

extern (Windows) winHandle CreateThread(int, int, int, int, int, int);

int main(char[][] args) {
	winHandle pointer = CreateThread(0, 0, 0, 0, 0, 0);
	return cast(int)pointer;
}

----- end createthread.d -----

and compiled it using standard DMD (dmd createthread.d) and it worked perfectly. (It did even run without a problem.)

Regards,
Sjoerd