How to call a GDI+ function from D ?

Vinod K Chandran kcvinu82 at gmail.com
Sun Jun 5 10:51:17 UTC 2022


Hi all,
I want to call the Bitmap function from gdi+. This is the syntax 
of the function in C++.
```c++
void Bitmap(
   [in] const WCHAR *filename,
   [in] BOOL        useEmbeddedColorManagement
);
```
And this is the mangled name which I got from goldbolt compiler.
`?Bitmap@@YAXPEB_WH at Z `

Now, this is my declaration in D.
```d
extern (C++, "Bitmap") void * Bitmap(const(wchar)* file, BOOL 
useClr);
```
And this is my call site.
```d
auto imgPath = toUTF16z(r"C:\Users\AcerLap\Pictures\Saved 
Pictures\d3.png") ;
auto pBmp = Bitmap(imgPath, FALSE);
```
But I got this error message.
```
app.obj : error LNK2019: unresolved external symbol "void * 
__cdecl Bitmap::Bitmap(char16_t const *,int)" 
(?Bitmap at 0@YAPAXPB_SH at Z) referenced in function 
__D4wing9imagelist9ImageList8addImageMFAyaZv
app.exe : fatal error LNK1120: 1 unresolved externals
Error: linker exited with status 1120
```
You see, the mangled names are different.
 From D - `?Bitmap at 0@YAPAXPB_SH at Z`
 From C++ - `?Bitmap@@YAXPEB_WH at Z`
How to fix this ?



More information about the Digitalmars-d-learn mailing list