-1

I am trying to use gzip compression feature on VxWorks 6.8.

VxWorks development guide help give says,

You can add the gzip compression feature to your system independently of the Wind River Web Server by adding the zlib library files to your project. To do so, add the files from installDir/components/webcli-4.x/target/src/wrn/wm/common/zlib to your project. Then use the -DWITH_ZLIB compiler flag when you build your system.

I tried it but getting build errors

../zlib/zlib_adler32.cpp:21: error: 'z_uLong zlib_z_adler32' redeclared as different kind of symbol

../zlib/zlib.h:822: error: previous declaration of 'z_uLong zlib_z_adler32(z_uLong, const z_Bytef*, z_uInt)'

../zlib/zlib_adler32.cpp:25: error: expected unqualified-id before '{' token 
C:\WindRiver\utilities-1.0\x86-win32\bin\make.exe: *** [.../zlib/zlib_adler32.o] Error 1 

Note : The files were with .c extension, changed it to .cpp and using C++ compiler. functions are declared with extern "C"

declaration of the function can be checked here

ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));

Any clue?

Abhay
  • 41
  • 6
  • 4
    *"The files were with .c extension, changed it to .cpp and using C++ compiler"* Hmm that sounds concerning, `zlib` is a `C` library, not a `C++` library. That has important implications regarding linking, name mangling, etc. You should instead compile it as a C library, then link against it, don't try to force it to be a C++ library. [See here](https://stackoverflow.com/questions/12066279/using-c-libraries-for-c-programs) – Cory Kramer Sep 07 '16 at 11:56
  • Thank you. Already using #ifdef __cplusplus extern "C" in code , trying to make C++ lib but if it takes more efforts I would go with C library. – Abhay Sep 08 '16 at 04:09

1 Answers1

0

The problem was with C old style definition not supported by GNU C++

uLong ZEXPORT adler32(adler, buf, len) uLong adler; const Bytef *buf; uInt len; {...}

corrected with uLong ZEXPORT adler32(uLong adler, const Bytef * buf, uInt len) {...}

solved my problem.

Abhay
  • 41
  • 6