4.50 B4 x64 zlib.lib

Just starting out? Need help? Post your questions and find answers here.
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

4.50 B4 x64 zlib.lib

Post by Rescator »

For some odd reason it's not possible to ImportC the zlib.lib that comes with PureBasic x64.

The error that zlib returns is the Z_VERSION_ERROR, when trying to use deflateInit2_()

Another odd error is this one:
PureBasic.asm [2]:

extrn crc32

error: reserved word used as symbol.
With PureBasic x86 there are none of these issues. *scratches head*
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: 4.50 B4 x64 zlib.lib

Post by Fred »

What's your code ?
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: 4.50 B4 x64 zlib.lib

Post by freak »

Your version error comes from a wrong z_stream structure definition.

With this one, it works fine on all systems:

Code: Select all

CompilerIf #PB_Compiler_Processor = #PB_Processor_x64 And #PB_Compiler_OS <> #PB_OS_Windows

	; On Linux x64, a long is 8 byte (unlike Windows x64)
	;
	Structure z_stream
	  *next_in.BYTE
	  avail_in.l
	  pad.l
	  total_in.i ; uLong
	  
	  *next_out.BYTE
	  avail_out.l
	  pad2.l
	  total_out.i ; uLong
	
	  *msg.BYTE
	  *state.i
	
	  zalloc.i
	  zfree.i
	  opaque.i
	  
	  data_type.l
	  pad3.l
	  adler.i    ; uLong
	  reserved.i ; uLong
	EndStructure

CompilerElse

	Structure z_stream
	  *next_in.BYTE
	  avail_in.l
	  total_in.l ; uLong
	  
	  *next_out.BYTE
	  avail_out.l
	  total_out.l ; uLong
	
	  *msg.BYTE
	  *state.i
	
	  zalloc.i
	  zfree.i
	  opaque.i
	  
	  data_type.l
	  adler.l    ; uLong
	  reserved.l ; uLong
	
	  ; without this, the inflateInit2() fails with a version error
	  CompilerIf #PB_Compiler_Processor = #PB_Processor_x64
	    alignment.l
	  CompilerEndIf
	EndStructure

CompilerEndIf
quidquid Latine dictum sit altum videtur
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Re: 4.50 B4 x64 zlib.lib

Post by Rescator »

Ah thanks, I was tearing my hair out with this one.

Hmm! Any chance you guys could add the z_stream structure to PureBasic?

But anyway, thanks, I had no idea I needed to align it.
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Re: 4.50 B4 x64 zlib.lib

Post by Rescator »

Didn't know where to post this so I'll tack it on here,
after some testing related to the extrn crc32 issue I mentioned (new bug report posted on that btw)
I tried replacing the crc with PureBasics function...

And PureBasic's CRC32Fingerprint() and zlib's crc32() are fully compatible.
They generate the same checksum given the same data.
Not only that, but they have the same implementation on the input/output of the checksum,
so they behave the same way when chaining, you could even intermix the two if you where silly.

So in cases where you have to code in another language than PureBasic but want to avoid breaking the checksum you use in your data files etc,
then you could use zlib's crc32, which is very cool as almost every language out there has a port or wrapper letting you use zlib in some way.
And seeing as zlib is used or supported in some way in even PHP and other server scripts, you can easily make a PureBasic client and use zlib's crc32 in a serverside script etc.

A pleasant surprise!

Freak, maybe you could add a line in the manual for CRC32FingerPrint() along the lines of "Compatible with zlib's crc32()." ?
Post Reply