我从github克隆了aws-sdk-cpp,我设法构建它没有问题(测试也通过了)。我没有做" make install"。我想独家编译SDK的dynamodbstreams部分,所以我添加了-DBUILD_ONLY =" dynamodbstreams"到cmake参数。我编写了一个小的测试代码,但由于DescribeStreamOutcome类型被报告为未定义("不完整类型"),因此无法编译。但是,它存在于头文件中应该是。
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;
你能帮我解决一下吗?感谢。
答案 0 :(得分:0)
语句“DescribeStreamOutcome在DynamoDBStreamsClient.h中定义”不正确。 DynamoDBStreamsClient.h中的那一行定义了Outcome实例化的别名。
clang给出了一个更简洁的错误消息:
meow.cpp:12:26: error: implicit instantiation of undefined template 'Aws::Utils::Outcome<Aws::DynamoDBStreams::Model::DescribeStreamResult,
Aws::Client::AWSError<Aws::DynamoDBStreams::DynamoDBStreamsErrors> >'
auto result = client.DescribeStream(request);
^
/usr/local/include/aws/dynamodbstreams/DynamoDBStreamsClient.h:44:43: note: template is declared here
template< typename R, typename E> class Outcome;
^
您需要#include "aws/core/utils/Outcome.h"
也许aws/dynamodbstreams/DynamoDBStreamsClient.h
应该包含Outcome.h
,尽管使用DynamoDBStreamsClient的代码在没有它的情况下进行编译,只要您不调用任何Outcome-returns方法。