I have the strange effect that some of my declares that invoke “libz.so.1” on a Fedora 32 or Debian 10 system crash the app, and I can’t figure out why.
Same declares work on macOS, linked to the same lib, and even on another Debian 9 system. All built for 64 bit.
Are there any known issues with declares on Linux 64 bit, such as that the ABI used for libs is not 100% compatible with how Xojo uses it?
Here are some details:
C prototypes:
const char * zlibVersion (void);
int deflateInit_ (z_streamp strm, int level, const char *version, int stream_size);
int deflateInit2_ (z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy, const char *version, int stream_size);
Declares in Xojo:
[code]soft declare function zlibVersion lib “libz.so.1” () as CString
soft declare function deflateInit_ lib “libz.so.1” (stream as Ptr, level as Integer, version as CString, stream_size as Integer) as Integer
soft declare function deflateInit2_ lib “libz.so.1” (stream as Ptr, level as Integer, method as Integer, windowBits as Integer, memLevel as Integer, strategy as Integer, version as CString, stream_size as Integer) as Integer
const MAX_WBITS = 15
const DEF_MEM_LEVEL = 8
const Z_DEFAULT_STRATEGY = 0
dim err as Integer
dim mStream as new MemoryBlock (112) // size for 64 bit
// works:
dim version as String = zlibVersion()
err = deflateInit_ (mStream, level, version, mStream.Size)
// crashes:
err = deflateInit2_ (mStream, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, version, mStream.Size)[/code]
But it’s not just the higher number of arguments. Even calling “deflate”, which only takes two args, crashes.
So, there’s something very odd going on.