aws-sdk-cpp编译2

本文介绍了LEA指令的功能及其在汇编语言程序设计中的应用。LEA指令能够高效地计算存储单元的有效地址,并将其加载到指定的寄存器中。文章还讨论了LEA指令在INTEL优化手册中被推崇的原因,包括其单时钟周期特性、避免流水线相关问题以及模拟三操作数算术运算的能力。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

minio-cpp是一款文件系统服务的客户端,最近开发要用到,最开始从官网下载编译都是成功的,但是在使用示例的时候不通过,听说只在Linux上可以用,在Window上不能用,因此改用aws-sdk-cpp来实现客户端连接。用cmake编译aws-sdk-cpp时,编完后没有aws-cpp-sdk-transfer模块。本篇介绍使用vcpkg编译aws-sdk-cpp。

开发环境:window 11  Qt5.15.2, VS2022

首先参考官方的编译文档

GitHub - aws/aws-sdk-cpp: AWS SDK for C++

切换到F:\qtexample

git clone https://github.com/Microsoft/vcpkg.git

这步完成这后,切换到vcpkg目录

cd vcpkg

执行以下三条命令

./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install aws-sdk-cpp


Call Stack (most recent call first):
  ports/aws-crt-cpp/portfile.cmake:36 (vcpkg_copy_pdbs)
  scripts/ports.cmake:192 (include)


-- Installing: F:/qtexample/vcpkg/packages/aws-crt-cpp_x64-windows/share/aws-crt-cpp/copyright
-- Performing post-build validation
Stored binaries in 1 destinations in 321 ms.
Elapsed time to handle aws-crt-cpp:x64-windows: 27 s
aws-crt-cpp:x64-windows package ABI: 76fa04f59a00998fc5f03f8267146ecb437f8c6fc8a611c73f4b74f53fc26d97
Installing 15/16 zlib:x64-windows@1.3.1...
Elapsed time to handle zlib:x64-windows: 19.1 ms
zlib:x64-windows package ABI: 6f1d40f5c56cc1640c0700e444ca2e43b2dd2026b8b184057b6d448807b6f571
Installing 16/16 aws-sdk-cpp[core,dynamodb,kinesis,s3]:x64-windows@1.11.352...
Building aws-sdk-cpp[core,dynamodb,kinesis,s3]:x64-windows@1.11.352...
CMake Warning at scripts/cmake/vcpkg_buildpath_length_warning.cmake:4 (message):
  aws-sdk-cpp's buildsystem uses very long paths and may fail on your system.

  We recommend moving vcpkg to a short path such as 'C:\src\vcpkg' or using
  the subst command.
Call Stack (most recent call first):
  ports/aws-sdk-cpp/portfile.cmake:1 (vcpkg_buildpath_length_warning)
  scripts/ports.cmake:192 (include)


-- Downloading https://github.com/aws/aws-sdk-cpp/archive/1.11.352.tar.gz -> aws-aws-sdk-cpp-1.11.352.tar.gz...
-- Extracting source F:/qtexample/vcpkg/downloads/aws-aws-sdk-cpp-1.11.352.tar.gz

安装成功后在F:\qtexample\vcpkg\installed\x64-windows目录

这种安装成功后也有aws-cpp-sdk-transfer模块的dll和lib,因此得添加aws-cpp-sdk-transfer这个模块的安装

PS F:\qtexample\vcpkg> ./bootstrap-vcpkg.sh
PS F:\qtexample\vcpkg> ./vcpkg integrate install
Applied user-wide integration for this vcpkg root.
CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=F:/qtexample/vcpkg/scripts/buildsystems/vcpkg.cmake"

All MSBuild C++ projects can now #include any installed libraries. Linking will be handled automatically. Installing new libraries will make them instantly available.

单独安装aws-cpp-sdk-transfer模块

PS F:\qtexample\vcpkg> ./vcpkg install aws-sdk-cpp[transfer]
Computing installation plan...
The following packages will be rebuilt:
    aws-sdk-cpp[core,dynamodb,kinesis,s3,transfer]:x64-windows@1.11.352
warning: If you are sure you want to rebuild the above packages, run the command with the --recurse option.
PS F:\qtexample\vcpkg> ./vcpkg install --recurse aws-sdk-cpp[transfer]
Computing installation plan...
The following packages will be rebuilt:
    aws-sdk-cpp[core,dynamodb,kinesis,s3,transfer]:x64-windows@1.11.352
Detecting compiler hash for triplet x64-windows...
-- Automatically setting %HTTP(S)_PROXY% environment variables to "127.0.0.1:6987".
Compiler found: D:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.41.34120/bin/Hostx64/x64/cl.exe
Restored 0 package(s) from C:\Users\cheny\AppData\Local\vcpkg\archives in 436 us. Use --debug to see more details.
Removing 1/2 aws-sdk-cpp:x64-windows
Elapsed time to handle aws-sdk-cpp:x64-windows: 288 ms
Installing 2/2 aws-sdk-cpp[core,dynamodb,kinesis,s3,transfer]:x64-windows@1.11.352...
Building aws-sdk-cpp[core,dynamodb,kinesis,s3,transfer]:x64-windows@1.11.352...
CMake Warning at scripts/cmake/vcpkg_buildpath_length_warning.cmake:4 (message):
  aws-sdk-cpp's buildsystem uses very long paths and may fail on your system.

  We recommend moving vcpkg to a short path such as 'C:\src\vcpkg' or using
  the subst command.
Call Stack (most recent call first):
  ports/aws-sdk-cpp/portfile.cmake:1 (vcpkg_buildpath_length_warning)
  scripts/ports.cmake:192 (include)


-- Using cached aws-aws-sdk-cpp-1.11.352.tar.gz.
-- Cleaning sources at F:/qtexample/vcpkg/buildtrees/aws-sdk-cpp/src/1.11.352-0db2abf4a9.clean. Use --editable to skip cleaning for the packages you specify.
-- Extracting source F:/qtexample/vcpkg/downloads/aws-aws-sdk-cpp-1.11.352.tar.gz
-- Applying patch fix-aws-root.patch
-- Applying patch lock-curl-http-and-tls-settings.patch
-- Applying patch fix_find_curl.patch
-- Applying patch find-dependency.patch
-- Using source at F:/qtexample/vcpkg/buildtrees/aws-sdk-cpp/src/1.11.352-0db2abf4a9.clean
-- Found external ninja('1.11.0').
-- Configuring x64-windows-dbg
-- Configuring x64-windows-rel
-- Building x64-windows-dbg
-- Building x64-windows-rel
CMake Warning at scripts/cmake/vcpkg_copy_pdbs.cmake:44 (message):
  Could not find a matching pdb file for:

      F:/qtexample/vcpkg/packages/aws-sdk-cpp_x64-windows/bin/aws-cpp-sdk-core.dll
      F:/qtexample/vcpkg/packages/aws-sdk-cpp_x64-windows/bin/aws-cpp-sdk-dynamodb.dll
      F:/qtexample/vcpkg/packages/aws-sdk-cpp_x64-windows/bin/aws-cpp-sdk-kinesis.dll
      F:/qtexample/vcpkg/packages/aws-sdk-cpp_x64-windows/bin/aws-cpp-sdk-s3.dll
      F:/qtexample/vcpkg/packages/aws-sdk-cpp_x64-windows/bin/aws-cpp-sdk-transfer.dll
      F:/qtexample/vcpkg/packages/aws-sdk-cpp_x64-windows/debug/bin/aws-cpp-sdk-core.dll
      F:/qtexample/vcpkg/packages/aws-sdk-cpp_x64-windows/debug/bin/aws-cpp-sdk-dynamodb.dll
      F:/qtexample/vcpkg/packages/aws-sdk-cpp_x64-windows/debug/bin/aws-cpp-sdk-kinesis.dll
      F:/qtexample/vcpkg/packages/aws-sdk-cpp_x64-windows/debug/bin/aws-cpp-sdk-s3.dll
      F:/qtexample/vcpkg/packages/aws-sdk-cpp_x64-windows/debug/bin/aws-cpp-sdk-transfer.dll

Call Stack (most recent call first):
  ports/aws-sdk-cpp/portfile.cmake:57 (vcpkg_copy_pdbs)
  scripts/ports.cmake:192 (include)


-- Installing: F:/qtexample/vcpkg/packages/aws-sdk-cpp_x64-windows/share/aws-sdk-cpp/copyright
-- Performing post-build validation
Stored binaries in 1 destinations in 1.2 s.
Elapsed time to handle aws-sdk-cpp:x64-windows: 2.4 min
aws-sdk-cpp:x64-windows package ABI: dedb36f98d779109cbde73e5809b70a454710cfc1dd1143b6260a76894955e4b
Total install time: 2.4 min
The package aws-sdk-cpp:x64-windows provides CMake targets:

    When using AWSSDK, AWSSDK_ROOT_DIR must be defined by the user.
    find_package(AWSSDK CONFIG COMPONENTS core dynamodb kinesis s3 REQUIRED)
    target_include_directories(main PRIVATE ${AWSSDK_INCLUDE_DIRS})
    target_link_libraries(main PRIVATE ${AWSSDK_LIBRARIES})

    OR

    find_package(aws-cpp-sdk-core REQUIRED)
    target_include_directories(main PRIVATE aws-cpp-sdk-core)
    target_link_libraries(main PRIVATE aws-cpp-sdk-core)

PS F:\qtexample\vcpkg>

最后安装完成后,transfer安装到对应的目录里

 代码测试

pro文件

QT       += core gui
 
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
 
INCLUDEPATH += ../include
 
CONFIG += c++17
 
DESTDIR = ../bin
 
LIBS += -L../bin -laws-cpp-sdk-core
LIBS += -L../bin -laws-cpp-sdk-s3
LIBS += -L../bin -laws-cpp-sdk-transfer
 
message($$OUT_PWD)
 
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
 
SOURCES += \
    main.cpp \
    mainwindow.cpp
 
HEADERS += \
    mainwindow.h \
 
FORMS += \
    mainwindow.ui
 
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

dll和lib文件都放在bin目录下。

cpp文件

//mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
 
#include <QDebug>
#include <string.h>
 
#include <iostream>
#include <fstream>
 
#include "aws/s3/S3Client.h"
#include "aws/core/Aws.h"
#include "aws/core/auth/AWSCredentialsProvider.h"
#include "aws/s3/model/PutObjectRequest.h"
#include "aws/s3/model/GetObjectRequest.h"
 
 
using namespace std;
using namespace Aws::S3;
using namespace Aws::S3::Model;
 
//#pragma comment(lib, "ws2_32.lib")
 
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    connect(ui->btnTest, SIGNAL(clicked()), this, SLOT(slotTest()));
}
 
MainWindow::~MainWindow()
{
    delete ui;
}
 
void MainWindow::getBucketTest()
{
    // 初始化
    Aws::SDKOptions options;
    options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Debug;
    Aws::InitAPI(options);
 
    Aws::Client::ClientConfiguration cfg;
    cfg.endpointOverride = "play.min.io";//官方测试服务器
    cfg.scheme = Aws::Http::Scheme::HTTPS;  //https协议
    //cfg.verifySSL = false;
 
    Aws::Auth::AWSCredentials cred("Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");
 
 
    Aws::S3::S3Client client(cred, cfg, Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Always, false,
                             Aws::S3::US_EAST_1_REGIONAL_ENDPOINT_OPTION::NOT_SET);
 
    auto response = client.ListBuckets();
 
    if (response.IsSuccess()) {
        auto buckets = response.GetResult().GetBuckets();
        for (auto iter = buckets.begin(); iter != buckets.end(); ++iter) {
            cout << iter->GetName() << "\t" << iter->GetCreationDate().ToLocalTimeString(Aws::Utils::DateFormat::ISO_8601) << endl;
        }
    }
 
}
 
 
void MainWindow::slotTest()
{
    qDebug() << "MainWindow::slotTest=========================";
    getBucketTest();
}
 
 
 
 
 

测试结果;

官网桶列表

 参考:

GitHub - aws/aws-sdk-cpp: AWS SDK for C++

https://github.com/minio/minio-cpp

在windows下使用Qt连接minio_minio-cpp-优快云博客

### 如何在 Linux 上编译安装 AWS SDK for C++ #### 准备工作 为了成功编译和安装AWS SDK for C++,需要先确保开发环境已经配置好必要的依赖库。对于基于Red Hat的系统,可以使用如下命令来安装所需的开发工具和库: ```bash yum install -y openssl-devel ``` 此操作能够确保OpenSSL库及其头文件被正确安装到系统中[^1]。 #### 下载源码包 前往[AWS官方GitHub仓库](https://github.com/aws/aws-sdk-cpp),获取最新版本的SDK源代码压缩包。解压后得到的是完整的源代码树结构。 #### 创建并进入构建目录 为了避免污染原始源代码,在根目录之外新建一个专门用于编译过程的工作空间是非常重要的做法之一。通过执行下面两条指令完成这一步骤: ```bash mkdir sdk_build cd sdk_build ``` 这样做不仅有助于维护清晰有序的项目布局,同时也便于后续清理不必要的中间产物[^2]。 #### 配置CMake选项 接下来利用CMake工具来进行项目的初始化设置。这里推荐采用Debug模式以便于调试期间更好地理解程序行为;当然如果追求性能则可切换至Release模式。具体来说就是运行这条命令: ```bash cmake ../aws-DCMAKE_BUILD_TYPE=debug ``` 上述命令指定了相对路径指向父级目录下的`aws-sdk-cpp`作为源代码位置,并设置了构建类型为调试版。 #### 执行编译流程 根据实际需求决定是要编译整个SDK还是仅限某些特定的服务接口。全量编译可以通过简单的`make`调用来实现;而针对个别组件,则需指定相应的子目录名称加上额外参数控制并发作业数(`-j`)以及当前所在路径(`-C`): ```bash # 完整编译 make # 或者只编译核心功能与S3服务端口 make -j $(nproc) -C aws-cpp-sdk-core make -j $(nproc) -C aws-cpp-sdk-s3 ``` 这里的`$(nproc)`宏会自动检测CPU逻辑处理器数量从而最大化利用多核优势加快速度[^3]。 #### 进行安装部署 最后一步便是把生成的目标文件复制到系统的标准库路径下使得其他应用程序可以直接链接使用这些动态/静态库。同样支持全局范围内的全面铺开或是局部范围内按需分发两种方式: ```bash sudo make install # 或者分别处理各个模块 sudo make install -C aws-cpp-sdk-core sudo make install -C aws-cpp-sdk-s3 ``` 值得注意的是当尝试一次性打包所有特性时可能会遇到因硬件资源限制而导致失败的情况(比如EC2实例),因此建议至少配备有16GB RAM以上的机器来承担这项任务。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值