I have some legacy code that uses the system's zlib. How to link it in?
Example details:
1. Create a simple C++ program, name it "hello_zlib.cpp", on OSX Mavericks
that uses the system preinstalled zlib:
#include <stdio.h>
#include <zlib.h> // located here "/usr/include"
int main()
{
uLong crc = crc32(0L, Z_NULL, 0);
char mybuffer[] = "some fake test data 012345678901234567890\
1234567890123456789012345678901234567890\
123456789012345678901234567890123456789";
int length = sizeof(mybuffer);
printf("Size of mybuffer %d\n", length);
crc = crc32(crc, (Bytef*)mybuffer, length); // crc32() is from zlib
printf("Hello world zlib, crc = %lu\n", crc);
return 0;
}
2. In terminal type "c++ hello_zlib.cpp -lz"
3. It compiles fine and "a.out" runs and produces this correctly:
Size of mybuffer 133
Hello world zlib, crc = 927298792
4. Now try to do same thing in emscripten. Type "emcc hello_zlib.cpp -lz"
which will produce this:
WARNING root: emcc: cannot find library "z"
warning: unresolved symbol: crc32
5. Typing "node a.out.js" produces this error as expected:
ReferenceError: _crc32 is not defined
at Object._main (/Users/username1/Desktop/test_zlib/a.out.js:4942:2)
at Object.callMain (/Users/username1/Desktop/test_zlib/a.out.js:5019:30)
at doRun (/Users/username1/Desktop/test_zlib/a.out.js:5059:25)
at run (/Users/username1/Desktop/test_zlib/a.out.js:5072:5)
at Object.<anonymous>
(/Users/username1/Desktop/test_zlib/a.out.js:5115:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
Basically emcc not linking system's zlib. How to do this correctly?
Any help greatly appreciated. Thanks in advance.
--
You received this message because you are subscribed to the Google Groups
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.