我从 github 克隆了 aws-sdk-cpp,并且成功地构建了它(测试也通过了)。我没有做“make install”。我想专门编译 SDK 的 dynamodbstreams 部分,所以我在 cmake 参数中添加了 -DBUILD_ONLY="dynamodbstreams" 。我写了一个小测试代码,但由于报告为未定义的 DescribeStreamOutcome 类型(“inclomplete 类型”)而无法编译。但是,它存在于它应该存在的头文件中。
cmake 版本:3.5.1,g++ 版本:5.4.0(目前我没有尝试过clang)
任何人都可以查看代码并指出问题所在吗?
我有以下代码:
#include "aws/core/Aws.h"
#include "aws/dynamodbstreams/DynamoDBStreamsClient.h"
#include "aws/dynamodbstreams/model/DescribeStreamRequest.h"
int main()
{
Aws::SDKOptions options;
Aws::InitAPI(options);
Aws::DynamoDBStreams::DynamoDBStreamsClient client;
Aws::DynamoDBStreams::Model::DescribeStreamRequest request;
auto result = client.DescribeStream(request);
if (result.IsSuccess()) {}
Aws::ShutdownAPI(options);
return 0;
}
有了这个 Makefile:
all: test
CFLAGS = -std=c++11 -Wall -fPIC \
-I$(SDK_SOURCE_DIR)/aws-cpp-sdk-core/include \
-I$(SDK_SOURCE_DIR)/aws-cpp-sdk-dynamodbstreams/include
LFLAGS = -shared -fPIC \
-L$(SDK_BUILD_DIR)/aws-cpp-sdk-core -laws-cpp-sdk-core \
-L$(SDK_BUILD_DIR)/aws-cpp-sdk-dynamodbstreams -laws-cpp-sdk-dynamodbstreams
test: test.o \
$(CXX) -shared -fPIC -o $@ $^
test.o: test.cc
$(CXX) $(CFLAGS) -c -o $@ $<
.PHONY: clean
clean:
rm -f *.o test
制作后出现以下错误:
g++ -std=c++11 -Wall -fPIC -I/home/attilacsabai/git-projects/aws-sdk-cpp/aws-cpp-sdk-core/include -I/home/attilacsabai/git-projects/aws-sdk-cpp/aws-cpp-sdk-dynamodbstreams/include -c -o test.o test.cc
test.cc: In function ‘int main()’:
test.cc:12:48: error: invalid use of incomplete type ‘Aws::DynamoDBStreams::Model::DescribeStreamOutcome {aka class Aws::Utils::Outcome<Aws::DynamoDBStreams::Model::DescribeStreamResult, Aws::Client::AWSError<Aws::DynamoDBStreams::DynamoDBStreamsErrors> >}’
auto result = client.DescribeStream(request);
^
In file included from /home/attilacsabai/git-projects/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/crypto/Hash.h:19:0,
from /home/attilacsabai/git-projects/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSClient.h:23,
from /home/attilacsabai/git-projects/aws-sdk-cpp/aws-cpp-sdk-dynamodbstreams/include/aws/dynamodbstreams/DynamoDBStreamsClient.h:21,
from test.cc:2:
/home/attilacsabai/git-projects/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/crypto/HashResult.h:26:50: note: declaration of ‘Aws::DynamoDBStreams::Model::DescribeStreamOutcome {aka class Aws::Utils::Outcome<Aws::DynamoDBStreams::Model::DescribeStreamResult, Aws::Client::AWSError<Aws::DynamoDBStreams::DynamoDBStreamsErrors> >}’
template< typename R, typename E > class Outcome;
^
Makefile:16: recipe for target 'test.o' failed
make: *** [test.o] Error 1
但是,DescribeStreamOutcome 是在 DynamoDBStreamsClient.h 中定义的:
$ grep -i describestreamoutcome $SDK_SOURCE_DIR/aws-cpp-sdk-dynamodbstreams/include/aws/dynamodbstreams/DynamoDBStreamsClient.h | head -1
typedef Aws::Utils::Outcome<DescribeStreamResult, Aws::Client::AWSError<DynamoDBStreamsErrors>> DescribeStreamOutcome;
那你能帮帮我吗?谢谢。