我在我的项目中使用了一个库,它使用 ZLIB 库进行压缩。另一方面,我在我的项目中使用 CryptoPP 库。结果是编译时编译器出错并加载 CryptoPP 的 zlib.h 而不是 ZLIB。
这是编译器错误:
/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()));
|
这只是错误的一部分。其余如上。
ZLIB、CryptoPP 和第三方库都安装在我的 ubuntu linux 上。编译器是 gcc 11.1.0。
你对这个问题有什么想法?如何解决这个问题?