Page 1 of 1

GDIPlus import library for 64 bit

Posted: Sun Jan 11, 2009 12:51 am
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 !

Posted: Sun Jan 11, 2009 1:27 am
by ts-soft
I think polib should do the trick

Posted: Sun Jan 11, 2009 3:41 pm
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.

Posted: Sun Jan 11, 2009 3:45 pm
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.

Posted: Sun Jan 11, 2009 4:13 pm
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.

Posted: Sun Jan 11, 2009 4:32 pm
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 ?

Posted: Sun Jan 11, 2009 4:54 pm
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?

Posted: Sun Jan 11, 2009 5:18 pm
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.

Posted: Sun Jan 11, 2009 5:21 pm
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.