我从github克隆了aws-sdk-cpp,并设法顺利地构建了它(测试也通过了)。我没有做"make install“。我想以独占方式编译SDK的dynamodbstreams部分,所以我在cmake参数中添加了-DBUILD_ONLY="dynamodbstreams“。我写了一个小的测试代码,但它无法编译,因为报告的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;你能帮帮我吗?谢谢。
发布于 2017-12-04 22:12:02
语句"DescribeStreamOutcome is defined in DynamoDBStreamsClient.h“不正确。DynamoDBStreamsClient.h中的那一行定义了结果实例化的别名。
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的代码就可以在没有它的情况下编译。
https://stackoverflow.com/questions/46630288
复制相似问题