usando flashzlib en un proyecto flash

Yo integraré flashzlib into one of my flash project. As mentioned in documentation of project. I have successfully generated libz.a and z.l.bc and pushed libs and headers in appropriate places.

Now, I have written this small wrapper This compiles just fine using:

gcc example1_as3.c -lz -O3 -Wall -swc -o example.swc

This is included into flash project like this (uncompressedData is a byteArray):

private var loader:CLibInit = new CLibInit;
private var lib:Object = loader.init();"B : " + lib.returnString(uncompressedData, uncompressedData.length) + "");

But flash file falla at this last line. Am not sure what am i missing. z.l.bc file is 340KB while example.swc is just 80KB.

preguntado el 08 de noviembre de 11 a las 17:11

it logs nothing and no further code is executed. It just gets stuck here. -

Quickly trying it myself, the runtime error I'm getting on example.c:50 is Undefined sym: _inflateInit_. -

@The_asMan no, just logger (logging.ILogger) -

@Gunslinger47 how do you run it to see this error? I am running flash inside browser which doesn't throw anything at me :( -

@Gunslinger47 also any hints how to fix this error? (may be some compile options?) -

1 Respuestas

­It's failing for one of two reasons. Either Alchemy isn't finding z.l.bc (and isn't bothering to tell you about it), or you're not catching and reporting your error codes correctly.

As I mentioned in the question comments, I was getting a runtime error on the inflateInit invocation. For my case, it turned out that Alchemy wasn't searching $ALCHEMY_HOME/usr/local/lib para z.l.bc like it was supposed to be. This was solved by moving it to /usr/local/lib instead. After that, your code returned Z_OK como se esperaba.

I notice you have all the CHECK_ERR calls commented out, which means that you'll enter an infinite loop if you comment out the early return on example.c:52 since you're not checking for errors on your inflate call in the following unconditional for block. For me, inflate estaba volviendo Z_DATA_ERROR since I was just handing it some UTF bytes for test purposes.

Speaking of testing, I notice that there's a small test suite supplied by flashzlib:

I borrowed this code, renamed main a test_all, commented out the call to test_gzio¹, and replaced all printf llamadas con fprintf llamadas a stderr instead². This is the result:

zlib version 1.2.3 = 0x1230, compile flags = 0x2000095

uncompress(): hello, hello!

inflate(): hello, hello!

large_inflate(): OK

after inflateSync(): hello, hello!

inflate with dictionary: hello, hello! 


Everything appears to be in order.

notas al pie:
¹ No file access in Alchemy, of course.
² stdout is disconnected for me, but stderr appears in my trace console

respondido 11 nov., 11:09

thanks @Gunslinger47. the flashzlib was working totally cool for me too. I tried pushing z.l.bc in /usr/local/lib but thats not working for me :(. will dig more and get back. thanks again! - Nakul

ok, so am able to integrate it with command from Makefile i.e. gcc -O3 -DNO_vsnprintf -DUSE_MMAP -swc -o example.swc example1_as3.o -L. libz.a Making it work now by passing right values. Thanks! - Nakul

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.