Can't compile easyzlib - could use some pointers

Previous topic - Next topic

Wampus

Hi!

I found Easyzlib, which simplifies the task of including zlib compression. However, when I try to compile there seems to be a lot of clashes with GLBasic. I've attached the code I'm trying to use as a starting point. Could someone give me some hints as to how to fix the errors? Would simply renaming variables work, for example.

First few errors...
Code (glbasic) Select
easyzlib.c:1608: error: `const char*__GLBASIC__::zError' redeclared as different kind of symbol
easyzlib.c:1308: error: previous declaration of `const char* __GLBASIC__::zError(int)'
easyzlib.c:1608: error: declaration of `const char*__GLBASIC__::zError'
easyzlib.c:1308: error: conflicts with previous declaration `const char* __GLBASIC__::zError(int)'
easyzlib.c:1608: error: `err' was not declared in this scope
easyzlib.c:1609: error: expected `,' or `;' before "int"
easyzlib.c:1610: error: expected unqualified-id before '{' token
easyzlib.c:1775: error: `void*__GLBASIC__::zcalloc' redeclared as different kind of symbol
easyzlib.c:1564: error: previous declaration of `void* __GLBASIC__::zcalloc(void*, unsigned int, unsigned int)'
easyzlib.c:1775: error: declaration of `void*__GLBASIC__::zcalloc'
easyzlib.c:1564: error: conflicts with previous declaration `void* __GLBASIC__::zcalloc(void*, unsigned int, unsigned int)'
easyzlib.c:1775: error: `opaque' was not declared in this scope
easyzlib.c:1775: error: `items' was not declared in this scope
easyzlib.c:1775: error: `size' was not declared in this scope
easyzlib.c:1776: error: initializer expression list treated as compound expression
easyzlib.c:1776: error: expected `,' or `;' before "voidpf"


[attachment deleted by admin]

Wampus

I'd been trying to get the original source for zlib compiling for much of the day. All sorts of problems cropped up with several restarts and it felt overwhelming. I went looking for something that would reduce the number of source files to work with and found easyzlib. When all those error messages came up on trying to compile I despaired at that point, knowing I wasn't going to get far without help.

I hoped someone could give me some pointers about how to resolve the clashes, even if the pointer was 'learn C++'. If you don't want to offer any help Ocean, that's fine too.

Wampus

Quote from: Ocean on 2012-Feb-04
Isn't the zlib library also available as a DLL or .SO file?   Likely it is easier to wrap a few such function calls...

Yes I guess they must be. I'll try that route instead.

Wampus

Oh, heheh. I cheated. I found a way to use zlib without needing anything that wasn't already in GLBasic itself. Using SAVESPRITE to save a specially prepared PNG file can do it. See this thread: http://www.glbasic.com/forum/index.php?topic=7631.0

Its a bit of a strange way of doing things and has its limitations. Nonetheless it suits my needs perfectly. - On closer examination I found it actually doesn't work. File size is as expected. The data in the file is not at all as expected.


MrTAToad

C code from other sources can be a problem - if they keep it simple then it's just a matter of doing an extern "c".  However, the problem comes when file handling is used - unless open is used, instead of fopen, then it is impossible to "convert"...

That EasyLib routine looks okay - the #ifdef all over the place could cause problems (and you will need to get rid of the #include "malloc.h" line, and replace it with extern "c" void free(void *) and the associated parameters for malloc), but it should be fine.

spacefractal

#5
Those errors look for me its conflict we original static zlib which might have shared some of those functions. So I think its really a conflict issue between easyzlib and zlib that allready is included.

So its would been nice if we could have new commands for that simple because zlib as kittyhello have informated before the forum was "timed" back. I think its would been most easist and combatible way to simply to invoke those functions directly. Either as a glbasic commands or inline commands.

Its would been nice for more advanced use of zlib when we need to extend zip support a bit more (or gz). Example like for generating levels or such things....

Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

Wampus

Ah, already statically linked in. It has to be somewhere, since loading and saving PNG files requires ZLIB. I will investigate trying to call the functions with INLINE. Thanks a lot!

Yesterday I was trying to compress an array by using MEM2SPRITE then saving it as a PNG file. Its a strange approach but I did get it working in the end (and will post in code snippets about it). The trouble is the header in a PNG file weighs in at an extra ~800 extra bytes. So, when compressing smaller arrays there is a chance the file size would be larger than if it wasn't compressed.