我正在尝试使用aws sdk cpp构建一个简单的示例。但我偶然发现了建设步骤。我正在链接libaws-cpp-sdk-s3.so库,它应该包含源文件中的所有符号。但链接器甚至找不到其中的几个。源文件是:
<Menu IsMainMenu="True" ItemsSource="{Binding TopMenuItems}">
<Menu.ItemContainerStyle>
<Style TargetType="{x:Type MenuItem}">
<Setter Property="Header" Value="{Binding Title}"/>
<Setter Property="ItemsSource" Value="{Binding Path=ChildMenuItems}"/>
</Style>
</Menu.ItemContainerStyle>
</Menu>
使用此Makefile:
#include <aws/core/Aws.h>
int main( int argc, char ** argv)
{
Aws::SDKOptions options;
Aws::InitAPI(options);
{
// make your SDK calls here.
}
Aws::ShutdownAPI(options);
return 0;
}
当我运行make时,我收到了此错误。但为什么?我建了
g ++ -g main.o -o ex1
main.o:在函数CC = g++
CFLAGS = -g -c -Wall -std=c++11
LDFLAGS = -g
EXECUTABLE = ex1
RM = rm -f
SOURCES = main.cpp
OBJS = $(SOURCES:.cpp=.o)
all: $(EXECUTABLE)
$(EXECUTABLE): main.o -laws-cpp-sdk-s3
$(CC) $(LDFLAGS) main.o -o $@
main.o: main.cpp
$(CC) $(CFLAGS) $^ -o $@
.PHONY: clean
clean:
$(RM) $(EXECUTABLE) $(OBJS) $(SOURCES:.cpp=.d)
Aws :: InitAPI(Aws :: SDKOptions const&amp;)'
/home/username/workspace/ex1/src/main.cpp:12:未定义的引用`Aws :: ShutdownAPI(Aws :: SDKOptions const&amp;)'
collect2:错误:ld返回1退出状态
Makefile:13:目标'ex1'的配方失败
make:*** [ex1]错误1
答案 0 :(得分:3)
我看不到你在哪里链接libaws-cpp-sdk-core
您可能需要:
$(EXECUTABLE): main.o -laws-cpp-sdk-s3 -laws-cpp-sdk-core
$(CC) $(LDFLAGS) main.o -o $@