2 years ago

#38086

test-img

navidcity

Conflict between "zlib.h" header of ZLIB and CryptoPP

I use a library in my project which uses ZLIB library for compression. On the other hand I use CryptoPP library in my project. The consequence is that when compiling compiler makes a mistake and loads the zlib.h of CryptoPP instead of ZLIB.

Here is the compiler error:

/usr/local/include/crow/compression.h:25:13: error: ‘z_stream’ was not declared in this scope
   25 |             z_stream stream{};
      |             ^~~~
/usr/local/include/crow/compression.h:27:19: error: ‘::deflateInit2’ has not been declared
   27 |             if (::deflateInit2(&stream, Z_DEFAULT_COMPRESSION, Z_DEFLATED, algo, 8, Z_DEFAULT_STRATEGY) == Z_OK)
      |                   ^~~~~~
/usr/local/include/crow/compression.h:27:33: error: ‘stream’ was not declared in this scope; did you mean ‘std::io_errc::stream’?
   27 |             if (::deflateInit2(&stream, Z_DEFAULT_COMPRESSION, Z_DEFLATED, algo, 8, Z_DEFAULT_STRATEGY) == Z_OK)
      |                                 ^~~~
      |                                 std::io_errc:stream
/usr/local/include/crow/compression.h:27:41: error: ‘Z_DEFAULT_COMPRESSION’ was not declared in this scope; did you mean ‘CROW_ENABLE_COMPRESSION’?
   27 |             if (::deflateInit2(&stream, Z_DEFAULT_COMPRESSION, Z_DEFLATED, algo, 8, Z_DEFAULT_STRATEGY) == Z_OK)
      |                                         ^~~~~~~~~
      |                                         CROW_ENABLE_COMPRESSION
/usr/local/include/crow/compression.h:27:64: error: ‘Z_DEFLATED’ was not declared in this scope; did you mean ‘DEFLATE’?
   27 |             if (::deflateInit2(&stream, Z_DEFAULT_COMPRESSION, Z_DEFLATED, algo, 8, Z_DEFAULT_STRATEGY) == Z_OK)
      |                                                                ^~~~
      |                                                                DEFLATE
[ 78%] Building CXX object _deps/cryptopp-build/CMakeFiles/cryptest.dir/validat2.cpp.o
/usr/local/include/crow/compression.h:27:85: error: ‘Z_DEFAULT_STRATEGY’ was not declared in this scope
   27 |             if (::deflateInit2(&stream, Z_DEFAULT_COMPRESSION, Z_DEFLATED, algo, 8, Z_DEFAULT_STRATEGY) == Z_OK)
      |                                                                                     ^~~~~~~~
/usr/local/include/crow/compression.h:27:108: error: ‘Z_OK’ was not declared in this scope; did you mean ‘R_OK’?
   27 |             if (::deflateInit2(&stream, Z_DEFAULT_COMPRESSION, Z_DEFLATED, algo, 8, Z_DEFAULT_STRATEGY) == Z_OK)
      |                                                                                                            ^~
      |                                                                                                            R_OK
/usr/local/include/crow/compression.h:33:45: error: ‘Bytef’ does not name a type
   33 |                 stream.next_in = const_cast<Bytef*>(reinterpret_cast<const Bytef*>(str.c_str()));
      |                                             ^~~
/usr/local/include/crow/compression.h:33:50: error: expected ‘>’ before ‘*’ token
   33 |                 stream.next_in = const_cast<Bytef*>(reinterpret_cast<const Bytef*>(str.c_str()));
      |                                                  ^
/usr/local/include/crow/compression.h:33:50: error: expected ‘(’ before ‘*’ token
   33 |                 stream.next_in = const_cast<Bytef*>(reinterpret_cast<const Bytef*>(str.c_str()));
      |                                                  ^
      |                                                  (
/usr/local/include/crow/compression.h:33:51: error: expected primary-expression before ‘>’ token
   33 |                 stream.next_in = const_cast<Bytef*>(reinterpret_cast<const Bytef*>(str.c_str()));
      |                                                   ^
/usr/local/include/crow/compression.h:33:76: error: expected ‘>’ before ‘Bytef’
   33 |                 stream.next_in = const_cast<Bytef*>(reinterpret_cast<const Bytef*>(str.c_str()));
      |                                                                            ^~~
/usr/local/include/crow/compression.h:33:76: error: expected ‘(’ before ‘Bytef’
   33 |                 stream.next_in = const_cast<Bytef*>(reinterpret_cast<const Bytef*>(str.c_str()));
      |                                                                            ^~~
      |                                                                            (
/usr/local/include/crow/compression.h:33:76: error: ‘Bytef’ was not declared in this scope
   33 |                 stream.next_in = const_cast<Bytef*>(reinterpret_cast<const Bytef*>(str.c_str()));
      |                                                                            ^~~
/usr/local/include/crow/compression.h:33:82: error: expected primary-expression before ‘>’ token
   33 |                 stream.next_in = const_cast<Bytef*>(reinterpret_cast<const Bytef*>(str.c_str()));
      |              

It's just a part of errors. The rest is like above.

ZLIB, CryptoPP and the third party library are all installed on my ubuntu linux. The compiler is gcc 11.1.0.

What's your idea about this problem? How to address this issue?

c++

zlib

crypto++

name-collision

crow

0 Answers

Your Answer

Accepted video resources