zlib problem

who is also having a problem with zlib1.dll? I’m getting a function not found error in zlibCompress. This is new and I’ve tried to download a new copy of zlib . . . didn’t help.

can you give us more details? I am using zlib.dll with @Thomas Tempelmann’s zip class with no problems.

Do you mean compress (or compress2)? zlib1.dll doesn’t export a method called zlibCompress.

Crash is here (message = “Could not load compress from ZLIB1.DLL”):
I’m using fpdf to write a pdf. It calls zlibcompress(s as string). The comment in the fpdf function says “// Heres goes the gzip compression algoritm or plugin call”

I’ve used this for years and it has always worked. Now, I’m suddenly getting this error.

Function zlibCompress(input as String) As String
pLastErrorCode = 0

soft declare function zlibcompress lib zlibPath alias “compress” (dest as Ptr, ByRef destLen as Uint32, source as CString, sourceLen as UInt32) as Integer

dim output as new MemoryBlock(12 + 1.002*LenB(input))
dim outputSize as UInt32 = output.Size

pLastErrorCode = zlibcompress(output, outputSize, input, LenB(input)) <-------
if pLastErrorCode = 0 then
return output.StringValue(0, outputSize)
return “”
end if
End Function

Is there another call to compress somewhere else in the program? The code you posted uses a “soft” declare; when a soft-declared external function can’t be found at runtime a FunctionNotFoundException is raised, not the loader error you’re getting.

fpdf (the PDF writing program) calls the gzcompress routine, which calls zlibcompress, from two places.

What’s throwing me is that there is no change to the programming, but this error has cropped up.

It’s working on one computer but not the new one. must be something missing but I can’t find it.

I put msgbox zLib.version in shown event handler for the main window and I get the same error: “Could not load zlibVersion from ZLIB1.DLL.”

Function Version() As String
soft declare function zlibVersion lib zlibPath () as Ptr

dim p as MemoryBlock = zlibVersion
if p <> nil then
return p.CString(0)
return “”
end if
End Function

So . . . I could be wrong but I’m convinced something is missing from the computer. zlibPath has always been ZLIB1.DLL

What am I missing? Where should there be a copy of zlib1.dll for xojo to find it?

The DLL should be in the same directory as the EXE file.

Got it !!! zlib1.dll has to be in root:\windows\system

I always used to ship it in the same folder as the EXE.

Windows will try a number of locations.
your app folder

and any other folder which is on the ‘PATH’ environment variable

I would not build an app which requires something in Windows System folder.
Better make it work with DLL in app folder.

Now get the error (when deploying to Xojo Cloud): Declares directly into the runtime via Lib “” are no longer allowed

soft declare function zlibcompress lib zlibPath alias “compress” (dest as Ptr, ByRef destLen as Uint32, source as CString, sourceLen as UInt32) as Integer

Any work arounds?

The Real Basic (Xojo) version of fpdf (fpdf.org) uses this in writing to a pdf.

The zlibPath constant probably needs to be updated to support Xojo Cloud. The constant has different values for each platform (Windows/Mac/Linux) but not for Xojo Cloud (which should use the same library name as Linux, /usr/lib/libz.so.1). The default value for the constant is the empty string, which explains the error message.