aws-sdk-cpp: unresolved symbols

荒凉一梦 提交于 2019-12-08 04:07:33

问题


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


回答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 $@


来源:https://stackoverflow.com/questions/43270210/aws-sdk-cpp-unresolved-symbols

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!