www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - dmd + optlink Symbol Undefined _StretchDIBits 52

reply Joshua Hodkinson <joshua.hodkinson.42 gmail.com> writes:
Hi everyone,

I am getting a linker error when compiling with dmd (v2.085.1) 
when using StrechDIBits from the win32 api.

Error 42: Symbol Undefined _StretchDIBits 52

However with ldc (v1.15.0) the program compiles correctly.

Wondering if I've missed something here, or possibly identified a 
bug with dmd?

Thanks
May 02 2019
parent reply Mike Parker <aldacron gmail.com> writes:
On Thursday, 2 May 2019 at 22:54:20 UTC, Joshua Hodkinson wrote:
 Hi everyone,

 I am getting a linker error when compiling with dmd (v2.085.1) 
 when using StrechDIBits from the win32 api.

 Error 42: Symbol Undefined _StretchDIBits 52

 However with ldc (v1.15.0) the program compiles correctly.

 Wondering if I've missed something here, or possibly identified 
 a bug with dmd?

 Thanks
By default, DMD uses the Optlink linker and some quite old system import libraries in the OMF format. They’re missing a number of functions. If you compile with -m32mscoff for 32-bit or -m64, DMD will use the Microsoft linker and import libraries if you have Visual Studio or the MS Build tools installed, and the LDC linker with some import libraries from MinGW if you don’t.
May 02 2019
parent Dennis <dkorpel gmail.com> writes:
On Friday, 3 May 2019 at 06:20:37 UTC, Mike Parker wrote:
 If you compile with -m32mscoff for 32-bit or -m64, DMD will use 
 the Microsoft linker and import libraries if you have Visual 
 Studio or the MS Build tools installed, and the LDC linker with 
 some import libraries from MinGW if you don’t.
I don't know if it's specific to me, but with dmd and mscoff I found the need to explicitly mention that I wanted to use the import libraries. E.g. looking at the requirements section of the docs: (https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/nf-wingdi-stretchdibits) I would put this in my code: pragma(lib, "Gdi32.lib");
May 03 2019