aws-sdk-cpp:未解决的符号 [英] aws-sdk-cpp: unresolved symbols

查看:617
本文介绍了aws-sdk-cpp:未解决的符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用aws sdk cpp构建一个简单的例子。但我无意中遇到了一个建设步骤。我正在链接libaws-cpp-sdk-s3.so库,它应该包含源文件中的所有符号。但是链接器甚至找不到其中的几个。源文件是:

  #include< aws / core / Aws.h> 
int main(int argc,char ** argv)
{
Aws :: SDKOptions选项;
Aws :: InitAPI(options);

{
//在这里进行SDK调用。
}

Aws :: ShutdownAPI(options);
返回0;
}

通过使用这个Makefile:

  CC = g ++ 
CFLAGS = -g -c -Wall -std = c ++ 11
LDFLAGS = -g
EXECUTABLE = ex1
RM = rm -f

SOURCES = main.cpp
OBJS = $(SOURCES:.cpp = .o)

全部:$($ 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)

当我运行make时,出现此错误。但为什么?我建立了

g ++ -g main.o -o ex1
main.o:在函数 main'中:
/ home / username / workspace / ex1 / src / main.cpp:6:未定义的引用
Aws :: InitAPI(Aws :: SDKOptions const&)'
/ home / username / workspace / ex1 / src / main.cpp:12:未定义引用到`Aws :: ShutdownAPI(Aws :: SDKOptions const&)'
collect2:错误:ld返回1退出状态
Makefile:13:recipe for target'ex1'failed
make:*** [ex1] Error 1

解决方案

您正在链接libaws-cpp-sdk-core



您可能需要:

  $(EXECUTABLE):main.o -laws-cpp-sdk-s3 -laws-cpp-sdk-core 
$(CC)$(LDFLAGS)main.o -o $ @


I am trying to build a simple example using aws sdk cpp. But I am stumbled on a building step. I am linking libaws-cpp-sdk-s3.so library, which is supposed to have all symbols from the source file. But the linker cannot even find a couple of them. The source file is:

#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;
}

by using this Makefile:

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)

When I run make, I got this error. But why? I built

g++ -g main.o -o ex1 main.o: In function main': /home/username/workspace/ex1/src/main.cpp:6: undefined reference toAws::InitAPI(Aws::SDKOptions const&)' /home/username/workspace/ex1/src/main.cpp:12: undefined reference to `Aws::ShutdownAPI(Aws::SDKOptions const&)' collect2: error: ld returned 1 exit status Makefile:13: recipe for target 'ex1' failed make: *** [ex1] Error 1

解决方案

I don't see where you are linking libaws-cpp-sdk-core

You probably need:

$(EXECUTABLE): main.o -laws-cpp-sdk-s3 -laws-cpp-sdk-core
    $(CC) $(LDFLAGS) main.o -o $@

这篇关于aws-sdk-cpp:未解决的符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆