概述
minio是一款开源的对象存储服务器,用了存储和下载文件;
C++ 没有直接调用minio的接口,需要使用aws来进行调用;
github: GitHub - aws/aws-sdk-cpp: AWS SDK for C++
.
注:
(1) 目前已测试架构:x86(PC机)和aarch64(xavier盒子和ajx盒子)
(2) 目前已测试ubuntu版本: 16、18、20、22
(3) 由于我们主要目的是用C++调用minio接口,因此这里仅需要将core和s3编译成功即可,不强求全部编译通过。
编译安装
https://github.com/aws/aws-sdk-cpp/archive/1.0.164.tar.gz
aws-sdk-cpp-1.0.164.tar.gz (可以根据自己需要在github的tags里面寻找自己需要的版本)
资料链接:(minIO) aws sdk for C++ - 简书
依赖:
sudo apt-get install openssl
sudo apt-get install libssl-dev
sudo apt-get install libcurl4-openssl-dev
编译:
mkdir build
cd build
cmake ..
make -j12
注:编译只需要core和s3编译成功即可,自己手动将include和so文件拷出来就行(使用时主要里面include的包含,可能会报错,但把#include改对就行了)
cmake报错1:Syntax error in cmake code
具体报错:
-- Encryption: Openssl
CMake Error at /usr/local/share/cmake-3.17/Modules/FindOpenSSL.cmake:421 (file):
Syntax error in cmake code at
/usr/local/share/cmake-3.17/Modules/FindOpenSSL.cmake:422
when parsing string
^#[\t ]*define[\t ]+OPENSSL_VERSION_STR[\t ]+\"([0-9])+\.([0-9])+\.([0-9])+\".*
Invalid escape sequence \.
Call Stack (most recent call first):
cmake/external_dependencies.cmake:44 (include)
CMakeLists.txt:108 (include)
-- Configuring incomplete, errors occurred!
报错原因:
cmake 3.17.3的版本+ubuntu22+openssl 3.0.2的版本,使得有一个cmake的bug出现,导致cmake时报错。
资料链接:openssl - Syntax error in CMake code at FindOpenSSL.cmake:422 when parsing string - Stack Overflow
解决(成功):
重新编译安装一个更高版本的cmake,我这里重新编译了一个3.20.0版
cmake报错2: aws-crt-cpp
完整报错信息如下:
CMake Error at CMakeLists.txt:180 (include):
include could not find load file:
AwsFindPackage
CMake Error at CMakeLists.txt:192 (add_subdirectory):
The source directory
/home/chenmq/work/aws-sdk-cpp/crt/aws-crt-cpp
does not contain a CMakeLists.txt file.
报错原因:缺少子库
解决方式1():
git clone --recurse-submodules https://github.com/aws/aws-sdk-cpp.git
git clone的时候加了选项 --recurse-submodules 能够将子库也一起clone下来
解决方式2(解决成功):
这种通常直接使用下载的tar.gz包使用这种
源码包中有个shell脚本:prefetch_crt_dependency.sh
直接运行 ./prefetch_crt_dependency.sh, 然后再cmake .. 即可
make报错1:AWSError出错
具体报错:
[ 0%] Building CXX object aws-cpp-sdk-core/CMakeFiles/aws-cpp-sdk-core.dir/source/client/AWSClient.cpp.o
/home/fedora/aws-sdk-cpp/aws-cpp-sdk-core/source/client/AWSClient.cpp: In member function ‘virtual Aws::Client::AWSError<Aws::Client::CoreErrors> Aws::Client::AWSJsonClient::BuildAWSError(const std::shared_ptr<Aws::Http::HttpResponse>&) const’:
/home/fedora/aws-sdk-cpp/aws-cpp-sdk-core/source/client/AWSClient.cpp:750:111: error: implicitly-declared ‘Aws::Client::AWSError<Aws::Client::CoreErrors>& Aws::Client::AWSError<Aws::Client::CoreErrors>::operator=(const Aws::Client::AWSError<Aws::Client::CoreErrors>&)’ is deprecated [-Werror=deprecated-copy]
750 | error = AWSError<CoreErrors>(CoreErrors::NETWORK_CONNECTION, "", "Unable to connect to endpoint", true);
| ^
In file included from /home/fedora/aws-sdk-cpp/aws-cpp-sdk-core/source/client/AWSClient.cpp:20:
/home/fedora/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSError.h:51:13: note: because ‘Aws::Client::AWSError<Aws::Client::CoreErrors>’ has user-provided ‘Aws::Client::AWSError<ERROR_TYPE>::AWSError(const Aws::Client::AWSError<Aws::Client::CoreErrors>&) [with ERROR_TYPE = Aws::Client::CoreErrors]’
51 | AWSError(const AWSError<CoreErrors>& rhs) :
| ^~~~~~~~
/home/fedora/aws-sdk-cpp/aws-cpp-sdk-core/source/client/AWSClient.cpp:763:54: error: implicitly-declared ‘Aws::Client::AWSError<Aws::Client::CoreErrors>& Aws::Client::AWSError<Aws::Client::CoreErrors>::operator=(const Aws::Client::AWSError<Aws::Client::CoreErrors>&)’ is deprecated [-Werror=deprecated-copy]
763 | IsRetryableHttpResponseCode(responseCode));
| ^
In file included from /home/fedora/aws-sdk-cpp/aws-cpp-sdk-core/source/client/AWSClient.cpp:20:
/home/fedora/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSError.h:51:13: note: because ‘Aws::Client::AWSError<Aws::Client::CoreErrors>’ has user-provided ‘Aws::Client::AWSError<ERROR_TYPE>::AWSError(const Aws::Client::AWSError<Aws::Client::CoreErrors>&) [with ERROR_TYPE = Aws::Client::CoreErrors]’
51 | AWSError(const AWSError<CoreErrors>& rhs) :
| ^~~~~~~~
/home/fedora/aws-sdk-cpp/aws-cpp-sdk-core/source/client/AWSClient.cpp:768:61: error: implicitly-declared ‘Aws::Client::AWSError<Aws::Client::CoreErrors>& Aws::Client::AWSError<Aws::Client::CoreErrors>::operator=(const Aws::Client::AWSError<Aws::Client::CoreErrors>&)’ is deprecated [-Werror=deprecated-copy]
768 | error = GetErrorMarshaller()->Marshall(*httpResponse);
| ^
In file included from /home/fedora/aws-sdk-cpp/aws-cpp-sdk-core/source/client/AWSClient.cpp:20:
/home/fedora/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSError.h:51:13: note: because ‘Aws::Client::AWSError<Aws::Client::CoreErrors>’ has user-provided ‘Aws::Client::AWSError<ERROR_TYPE>::AWSError(const Aws::Client::AWSError<Aws::Client::CoreErrors>&) [with ERROR_TYPE = Aws::Client::CoreErrors]’
51 | AWSError(const AWSError<CoreErrors>& rhs) :
| ^~~~~~~~
/home/fedora/aws-sdk-cpp/aws-cpp-sdk-core/source/client/AWSClient.cpp: In member function ‘virtual Aws::Client::AWSError<Aws::Client::CoreErrors> Aws::Client::AWSXMLClient::BuildAWSError(const std::shared_ptr<Aws::Http::HttpResponse>&) const’:
/home/fedora/aws-sdk-cpp/aws-cpp-sdk-core/source/client/AWSClient.cpp:846:111: error: implicitly-declared ‘Aws::Client::AWSError<Aws::Client::CoreErrors>& Aws::Client::AWSError<Aws::Client::CoreErrors>::operator=(const Aws::Client::AWSError<Aws::Client::CoreErrors>&)’ is deprecated [-Werror=deprecated-copy]
846 | error = AWSError<CoreErrors>(CoreErrors::NETWORK_CONNECTION, "", "Unable to connect to endpoint", true);
| ^
In file included from /home/fedora/aws-sdk-cpp/aws-cpp-sdk-core/source/client/AWSClient.cpp:20:
/home/fedora/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSError.h:51:13: note: because ‘Aws::Client::AWSError<Aws::Client::CoreErrors>’ has user-provided ‘Aws::Client::AWSError<ERROR_TYPE>::AWSError(const Aws::Client::AWSError<Aws::Client::CoreErrors>&) [with ERROR_TYPE = Aws::Client::CoreErrors]’
51 | AWSError(const AWSError<CoreErrors>& rhs) :
| ^~~~~~~~
/home/fedora/aws-sdk-cpp/aws-cpp-sdk-core/source/client/AWSClient.cpp:858:104: error: implicitly-declared ‘Aws::Client::AWSError<Aws::Client::CoreErrors>& Aws::Client::AWSError<Aws::Client::CoreErrors>::operator=(const Aws::Client::AWSError<Aws::Client::CoreErrors>&)’ is deprecated [-Werror=deprecated-copy]
858 | error = AWSError<CoreErrors>(errorCode, "", ss.str(), IsRetryableHttpResponseCode(responseCode));
| ^
In file included from /home/fedora/aws-sdk-cpp/aws-cpp-sdk-core/source/client/AWSClient.cpp:20:
/home/fedora/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSError.h:51:13: note: because ‘Aws::Client::AWSError<Aws::Client::CoreErrors>’ has user-provided ‘Aws::Client::AWSError<ERROR_TYPE>::AWSError(const Aws::Client::AWSError<Aws::Client::CoreErrors>&) [with ERROR_TYPE = Aws::Client::CoreErrors]’
51 | AWSError(const AWSError<CoreErrors>& rhs) :
| ^~~~~~~~
/home/fedora/aws-sdk-cpp/aws-cpp-sdk-core/source/client/AWSClient.cpp:872:61: error: implicitly-declared ‘Aws::Client::AWSError<Aws::Client::CoreErrors>& Aws::Client::AWSError<Aws::Client::CoreErrors>::operator=(const Aws::Client::AWSError<Aws::Client::CoreErrors>&)’ is deprecated [-Werror=deprecated-copy]
872 | error = GetErrorMarshaller()->Marshall(*httpResponse);
| ^
In file included from /home/fedora/aws-sdk-cpp/aws-cpp-sdk-core/source/client/AWSClient.cpp:20:
/home/fedora/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSError.h:51:13: note: because ‘Aws::Client::AWSError<Aws::Client::CoreErrors>’ has user-provided ‘Aws::Client::AWSError<ERROR_TYPE>::AWSError(const Aws::Client::AWSError<Aws::Client::CoreErrors>&) [with ERROR_TYPE = Aws::Client::CoreErrors]’
51 | AWSError(const AWSError<CoreErrors>& rhs) :
| ^~~~~~~~
In file included from /home/fedora/aws-sdk-cpp/aws-cpp-sdk-core/source/client/AWSClient.cpp:31:
/home/fedora/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/Outcome.h: In instantiation of ‘Aws::Utils::Outcome<R, E>& Aws::Utils::Outcome<R, E>::operator=(Aws::Utils::Outcome<R, E>&&) [with R = std::shared_ptr<Aws::Http::HttpResponse>; E = Aws::Client::AWSError<Aws::Client::CoreErrors>]’:
/home/fedora/aws-sdk-cpp/aws-cpp-sdk-core/source/client/AWSClient.cpp:164:23: required from here
/home/fedora/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/Outcome.h:84:27: error: implicitly-declared ‘Aws::Client::AWSError<Aws::Client::CoreErrors>& Aws::Client::AWSError<Aws::Client::CoreErrors>::operator=(const Aws::Client::AWSError<Aws::Client::CoreErrors>&)’ is deprecated [-Werror=deprecated-copy]
84 | error = std::move(o.error);
| ~~~~~~^~~~~~~~~~~~~~~~~~~~
In file included from /home/fedora/aws-sdk-cpp/aws-cpp-sdk-core/source/client/AWSClient.cpp:20:
/home/fedora/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSError.h:51:13: note: because ‘Aws::Client::AWSError<Aws::Client::CoreErrors>’ has user-provided ‘Aws::Client::AWSError<ERROR_TYPE>::AWSError(const Aws::Client::AWSError<Aws::Client::CoreErrors>&) [with ERROR_TYPE = Aws::Client::CoreErrors]’
51 | AWSError(const AWSError<CoreErrors>& rhs) :
| ^~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [aws-cpp-sdk-core/CMakeFiles/aws-cpp-sdk-core.dir/build.make:204: aws-cpp-sdk-core/CMakeFiles/aws-cpp-sdk-core.dir/source/client/AWSClient.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:9693: aws-cpp-sdk-core/CMakeFiles/aws-cpp-sdk-core.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
报错环境:
aws-sdk-cpp-1.0.164 + ubuntu22 + cmake 3.20.0 + gcc 11.2.0
报错原因:
这是由于gcc版本过高,aws版本低了,导致有个bug,
资料链接:Build Error on GCC9 · Issue #1136 · aws/aws-sdk-cpp · GitHub
解决1(成功):
在aws-cpp-sdk-core/include/aws/core/client/AWSError.h 中的AWSError类中加一句:
AWSError& operator=(const AWSError<ERROR_TYPE>&) = default;
,然后重新编译即可
.
make报错2:openssl 3.0出错
报错信息:
/home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp: In function ‘void Aws::Utils::Crypto::OpenSSL::init_static_state()’:
/home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:59:44: error: ‘int ERR_load_CRYPTO_strings()’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
59 | ERR_load_CRYPTO_strings();
| ~~~~~~~~~~~~~~~~~~~~~~~^~
In file included from /usr/include/openssl/cryptoerr.h:17,
from /usr/include/openssl/crypto.h:38,
from /usr/include/openssl/bio.h:30,
from /usr/include/openssl/evp.h:30,
from /home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/include/aws/core/utils/crypto/openssl/CryptoImpl.h:23,
from /home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:19:
/usr/include/openssl/cryptoerr_legacy.h:41:27: note: declared here
41 | OSSL_DEPRECATEDIN_3_0 int ERR_load_CRYPTO_strings(void);
| ^~~~~~~~~~~~~~~~~~~~~~~
/home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp: In member function ‘virtual Aws::Utils::Crypto::HashResult Aws::Utils::Crypto::MD5OpenSSLImpl::Calculate(const String&)’:
/home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:130:25: error: ‘int MD5_Init(MD5_CTX*)’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
130 | MD5_Init(&md5);
| ~~~~~~~~^~~~~~
In file included from /home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:21:
/usr/include/openssl/md5.h:49:27: note: declared here
49 | OSSL_DEPRECATEDIN_3_0 int MD5_Init(MD5_CTX *c);
| ^~~~~~~~
/home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:131:27: error: ‘int MD5_Update(MD5_CTX*, const void*, size_t)’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
131 | MD5_Update(&md5, str.c_str(), str.size());
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:21:
/usr/include/openssl/md5.h:50:27: note: declared here
50 | OSSL_DEPRECATEDIN_3_0 int MD5_Update(MD5_CTX *c, const void *data, size_t len);
| ^~~~~~~~~~
/home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:134:26: error: ‘int MD5_Final(unsigned char*, MD5_CTX*)’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
134 | MD5_Final(hash.GetUnderlyingData(), &md5);
| ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:21:
/usr/include/openssl/md5.h:51:27: note: declared here
51 | OSSL_DEPRECATEDIN_3_0 int MD5_Final(unsigned char *md, MD5_CTX *c);
| ^~~~~~~~~
/home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp: In member function ‘virtual Aws::Utils::Crypto::HashResult Aws::Utils::Crypto::MD5OpenSSLImpl::Calculate(Aws::IStream&)’:
/home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:142:25: error: ‘int MD5_Init(MD5_CTX*)’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
142 | MD5_Init(&md5);
| ~~~~~~~~^~~~~~
In file included from /home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:21:
/usr/include/openssl/md5.h:49:27: note: declared here
49 | OSSL_DEPRECATEDIN_3_0 int MD5_Init(MD5_CTX *c);
| ^~~~~~~~
/home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:160:35: error: ‘int MD5_Update(MD5_CTX*, const void*, size_t)’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
160 | MD5_Update(&md5, streamBuffer, static_cast<size_t>(bytesRead));
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:21:
/usr/include/openssl/md5.h:50:27: note: declared here
50 | OSSL_DEPRECATEDIN_3_0 int MD5_Update(MD5_CTX *c, const void *data, size_t len);
| ^~~~~~~~~~
/home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:168:26: error: ‘int MD5_Final(unsigned char*, MD5_CTX*)’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
168 | MD5_Final(hash.GetUnderlyingData(), &md5);
| ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:21:
/usr/include/openssl/md5.h:51:27: note: declared here
51 | OSSL_DEPRECATEDIN_3_0 int MD5_Final(unsigned char *md, MD5_CTX *c);
| ^~~~~~~~~
/home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp: In member function ‘virtual Aws::Utils::Crypto::HashResult Aws::Utils::Crypto::Sha256OpenSSLImpl::Calculate(const String&)’:
/home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:176:28: error: ‘int SHA256_Init(SHA256_CTX*)’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
176 | SHA256_Init(&sha256);
| ~~~~~~~~~~~^~~~~~~~~
In file included from /home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:22:
/usr/include/openssl/sha.h:73:27: note: declared here
73 | OSSL_DEPRECATEDIN_3_0 int SHA256_Init(SHA256_CTX *c);
| ^~~~~~~~~~~
/home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:177:30: error: ‘int SHA256_Update(SHA256_CTX*, const void*, size_t)’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
177 | SHA256_Update(&sha256, str.c_str(), str.size());
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:22:
/usr/include/openssl/sha.h:74:27: note: declared here
74 | OSSL_DEPRECATEDIN_3_0 int SHA256_Update(SHA256_CTX *c,
| ^~~~~~~~~~~~~
/home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:180:29: error: ‘int SHA256_Final(unsigned char*, SHA256_CTX*)’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
180 | SHA256_Final(hash.GetUnderlyingData(), &sha256);
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:22:
/usr/include/openssl/sha.h:76:27: note: declared here
76 | OSSL_DEPRECATEDIN_3_0 int SHA256_Final(unsigned char *md, SHA256_CTX *c);
| ^~~~~~~~~~~~
/home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp: In member function ‘virtual Aws::Utils::Crypto::HashResult Aws::Utils::Crypto::Sha256OpenSSLImpl::Calculate(Aws::IStream&)’:
/home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:188:28: error: ‘int SHA256_Init(SHA256_CTX*)’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
188 | SHA256_Init(&sha256);
| ~~~~~~~~~~~^~~~~~~~~
In file included from /home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:22:
/usr/include/openssl/sha.h:73:27: note: declared here
73 | OSSL_DEPRECATEDIN_3_0 int SHA256_Init(SHA256_CTX *c);
| ^~~~~~~~~~~
/home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:207:38: error: ‘int SHA256_Update(SHA256_CTX*, const void*, size_t)’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
207 | SHA256_Update(&sha256, streamBuffer, static_cast<size_t>(bytesRead));
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:22:
/usr/include/openssl/sha.h:74:27: note: declared here
74 | OSSL_DEPRECATEDIN_3_0 int SHA256_Update(SHA256_CTX *c,
| ^~~~~~~~~~~~~
/home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:215:29: error: ‘int SHA256_Final(unsigned char*, SHA256_CTX*)’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
215 | SHA256_Final(hash.GetUnderlyingData(), &sha256);
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:22:
/usr/include/openssl/sha.h:76:27: note: declared here
76 | OSSL_DEPRECATEDIN_3_0 int SHA256_Final(unsigned char *md, SHA256_CTX *c);
| ^~~~~~~~~~~~
/home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp: In constructor ‘Aws::Utils::Crypto::HMACRAIIGuard::HMACRAIIGuard()’:
/home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:226:41: error: ‘HMAC_CTX* HMAC_CTX_new()’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
226 | m_ctx = HMAC_CTX_new();
| ~~~~~~~~~~~~^~
In file included from /home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/include/aws/core/utils/crypto/openssl/CryptoImpl.h:24,
from /home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:19:
/usr/include/openssl/hmac.h:33:33: note: declared here
33 | OSSL_DEPRECATEDIN_3_0 HMAC_CTX *HMAC_CTX_new(void);
| ^~~~~~~~~~~~
/home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp: In destructor ‘Aws::Utils::Crypto::HMACRAIIGuard::~HMACRAIIGuard()’:
/home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:235:34: error: ‘void HMAC_CTX_free(HMAC_CTX*)’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
235 | HMAC_CTX_free(m_ctx);
| ~~~~~~~~~~~~~^~~~~~~
In file included from /home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/include/aws/core/utils/crypto/openssl/CryptoImpl.h:24,
from /home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:19:
/usr/include/openssl/hmac.h:35:28: note: declared here
35 | OSSL_DEPRECATEDIN_3_0 void HMAC_CTX_free(HMAC_CTX *ctx);
| ^~~~~~~~~~~~~
/home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp: In member function ‘virtual Aws::Utils::Crypto::HashResult Aws::Utils::Crypto::Sha256HMACOpenSSLImpl::Calculate(const ByteBuffer&, const ByteBuffer&)’:
/home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:260:29: error: ‘int HMAC_Init_ex(HMAC_CTX*, const void*, int, const EVP_MD*, ENGINE*)’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
260 | HMAC_Init_ex(m_ctx, secret.GetUnderlyingData(), static_cast<int>(secret.GetLength()), EVP_sha256(),
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
261 | NULL);
| ~~~~~
In file included from /home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/include/aws/core/utils/crypto/openssl/CryptoImpl.h:24,
from /home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:19:
/usr/include/openssl/hmac.h:43:27: note: declared here
43 | OSSL_DEPRECATEDIN_3_0 int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
| ^~~~~~~~~~~~
/home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:262:28: error: ‘int HMAC_Update(HMAC_CTX*, const unsigned char*, size_t)’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
262 | HMAC_Update(m_ctx, toSign.GetUnderlyingData(), toSign.GetLength());
| ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/include/aws/core/utils/crypto/openssl/CryptoImpl.h:24,
from /home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:19:
/usr/include/openssl/hmac.h:45:27: note: declared here
45 | OSSL_DEPRECATEDIN_3_0 int HMAC_Update(HMAC_CTX *ctx, const unsigned char *data,
| ^~~~~~~~~~~
/home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:263:27: error: ‘int HMAC_Final(HMAC_CTX*, unsigned char*, unsigned int*)’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
263 | HMAC_Final(m_ctx, digest.GetUnderlyingData(), &length);
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/include/aws/core/utils/crypto/openssl/CryptoImpl.h:24,
from /home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:19:
/usr/include/openssl/hmac.h:47:27: note: declared here
47 | OSSL_DEPRECATEDIN_3_0 int HMAC_Final(HMAC_CTX *ctx, unsigned char *md,
| ^~~~~~~~~~
/home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:268:31: error: ‘int HMAC_CTX_reset(HMAC_CTX*)’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
268 | HMAC_CTX_reset(m_ctx);
| ~~~~~~~~~~~~~~^~~~~~~
In file included from /home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/include/aws/core/utils/crypto/openssl/CryptoImpl.h:24,
from /home/hir/softs/aws-sdk-cpp-1.0.164/aws-cpp-sdk-core/source/utils/crypto/openssl/CryptoImpl.cpp:19:
/usr/include/openssl/hmac.h:34:27: note: declared here
34 | OSSL_DEPRECATEDIN_3_0 int HMAC_CTX_reset(HMAC_CTX *ctx);
| ^~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [aws-cpp-sdk-core/CMakeFiles/aws-cpp-sdk-core.dir/build.make:917:aws-cpp-sdk-core/CMakeFiles/aws-cpp-sdk-core.dir/source/utils/crypto/openssl/CryptoImpl.cpp.o] 错误 1
make[2]: *** 正在等待未完成的任务....
make[1]: *** [CMakeFiles/Makefile2:4841:aws-cpp-sdk-core/CMakeFiles/aws-cpp-sdk-core.dir/all] 错误 2
make: *** [Makefile:136:all] 错误 2
报错版本:
aws-sdk-cpp-1.0.164 + Ubuntu22 + openssl 3.0 (使用openssl version
命令可查看版本)
报错原因:
此版本的aws暂未支持openssl3.0,使用了很多openssl 3.0中很多已经弃用了的函数。
资料链接:openssl 3.0.0 compatible aws-sdk-cpp version · Issue #1582 · aws/aws-sdk-cpp · GitHub
解决1(失败):
在cmake时加上 -Wno-error=deprecated-declarations
或-DUSE_OPENSSL=OFF
,然后重新编译。
测试时分别使用两种,还是都make失败了.
解决2(成功):
重新编译安装openssl 1.1.1o (由于无法直接apt install ,因此编译安装),具体编译安装方式查看 ubuntu安装openssl
然后重新编译aws