GDIPlus import library for 64 bit

Just starting out? Need help? Post your questions and find answers here.
User avatar
luis
Addict
Addict
Posts: 3895
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

GDIPlus import library for 64 bit

Post by luis »

I was trying to recompile a program under vista 64 with PB 4.3 x64, I wrote the code thinking about portability to x64 so I was expecting a smooth ride. :roll:

Anyway, in my program I use the import library gdiplus.lib someone linked in the pb forum (don't recall exactly where at the moment, sorry).

In my code I'm using it in the usual way:

Code: Select all

Import "gdiplus.lib" ;{ IMPORTS
 GdiplusStartup (*token, *input.GdiplusStartupInput, *output.GdiplusStartupOutput)
 GdiplusShutdown (token)
 GdipGetImageWidth (image, *width)
 GdipGetImageHeight (image, *height)
 GdipGetImagePixelFormat (image, *format) 
 GdipCreateBitmapFromFile (filename.p-unicode, *image)
 GdipGetImageGraphicsContext (image, *graphics)
 GdipCreateFromHDC (hDC, *gfx) 
 GdipDrawImageRectI (gfx, image, x, y, width, height)
 GdipDeleteGraphics (gfx)
 GdipDisposeImage (image)
 GdipSetSmoothingMode(gfx, mode) 
 GdipSetInterpolationMode(gfx, mode)
 GdipSaveImageToFile (image, filename.p-unicode, *clsidEncoder.CLSID, *encoderParams)  
 GdipCreateBitmapFromHBITMAP (image, palette, *image)  
 GdipGetImageEncodersSize (*numEncoders, *size)
 GdipGetImageEncoders (numEncoders, size, *encoders.ImageCodecInfo)  
 GdipGetImageThumbnail (image, thumbWidth, thumbHeight, *thumbImage, *callback, *callbackData)
 GdipSaveImageToStream (image, stream.IStream, *clsidEncoder.CLSID, *encoderParams)
EndImport ;}
But it won't compile under Vista 64 because (having the gdiplus.lib copied from the 32 bit version) polink give errors for the above functions.

Where can I find a 64 bit version of the above import lib ?

Or how can I build it from the 64 bit dll in Vista ? Under win32 there are some tools like implib or the like, but I don't have the foggiest idea of what to use for 64 bits.

Thanks !
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

I think polib should do the trick
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
luis
Addict
Addict
Posts: 3895
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Post by luis »

ts-soft wrote:I think polib should do the trick
How ?

I'm not sure of what I was doing but I done it nevertheless.

I thought maybe the .def could be the same if the functions inside the vista 64 bit dll are the same as in the xp 32 bit dll. I thought "maybe it's sufficient to build a new import lib specifying a new architecture". But it isn't work.

What I did: I tried to build a .def file from the 32 bit import lib I have, then I generated a new .lib with the above file but specifying x64 or amd64 as target using the /machine: switch.

The linker is still complaining about unresolved externals.

Any suggestion ? As I said I'm in the dark.

I tried to do some searching on Internet but I didn't found anything pertinent.

Thanks.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Use POLIB from the command line to create a new .lib from the 64-bit version of the gdiplus dll. Abandon the 32-bit .lib completely.
I may look like a mule, but I'm not a complete ass.
User avatar
luis
Addict
Addict
Posts: 3895
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Post by luis »

srod wrote:Use POLIB from the command line to create a new .lib from the 64-bit version of the gdiplus dll. Abandon the 32-bit .lib completely.
OK, I tried.

I'm using:

Code: Select all

Pelles Library Manager, Version 5.00.1
Copyright (c) Pelle Orinius 1997-2008

Syntax:
POLIB [ { option | file | @commandfile } ... ]

Options:
/DEF:filename      Build import library from module-definition file
/EXPLODE           Create object files for all members
/EXTRACT:member    Create object file for the given member
/LIST              List all member names
/MACHINE:type      Set target machine type: AMD64, ARM, X64, or X86
/MAKEDEF:filename  Build module-definition file from import library
/NOUND             Don't add underscore to import names
/OUT:filename      Name the output file
/REMOVE:member     Remove the given member
/VERBOSE           Display more information

32 bit

source dll:

Code: Select all

20/06/2003  12:28       1.777.664  gdiplus.dll

Code: Select all

polib gdiplus.dll /out:gdiplus.lib /makedef:gdiplus.def
result:

Code: Select all

11/01/2009  16:00          25.111  gdiplus.def
20/06/2003  12:28       1.777.664  gdiplus.dll
11/01/2009  16:00         152.130  gdiplus.lib
Tried the above import lib in my program and it works.


64 bit

source dll:

Code: Select all

21/01/2008  03:49       2.190.848  gdiplus.dll

Code: Select all

polib gdiplus.dll /out:gdiplus.lib /makedef:gdiplus.def /machine:x64
result:

Code: Select all

POLIB: fatal error: Internal error (create_archive_file)

looking for the above error:

http://forum.pellesc.de/index.php?topic=2631.0


Any suggestions ?

Thanks.
User avatar
luis
Addict
Addict
Posts: 3895
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Post by luis »

just found this post (by the same bingo I suppose):

http://www.purebasic.fr/english/viewtop ... 372#264372
1. dumpbin /exports /out:ntdll.def c:\windows\sysnative\ntdll.dll
2. convert def-fomat to polib-def-format (pb tool )
3. polib.exe /out:ntdll.lib /machine:x64 /def:ntdll.def
What is the tool mentioned on point 2 ?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Why do you need the def file if using just from PB ? Try removing that switch from the command line given to POLIB; does it create an import lib for you?
I may look like a mule, but I'm not a complete ass.
User avatar
luis
Addict
Addict
Posts: 3895
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Post by luis »

srod wrote:Why do you need the def file if using just from PB ? Try removing that switch from the command line given to POLIB; does it create an import lib for you?
I don't need it. But the error persist even without the /makedef option.

I finally made it, anyway, following bingo's method.

I edited manually the .def file generated at point 1 (I didn't found a tool in the pb installion) to make it "polib compliant" and then generated the lib as in point 3.

Not very straightforward and requiring dumpbin.exe and link.exe from MS.

Would be nice to have a reply about the "internal error" from the POLIB author.

Thank you for your time.
Last edited by luis on Sun Jan 11, 2009 5:37 pm, edited 1 time in total.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Yea that is strange that you need dumpbin to list all the exports in a def file first; I'd have thought POLIB should be able to determine those for itself without needing a def file.
I may look like a mule, but I'm not a complete ass.
Post Reply