paratrooper
paratrooper

Reputation: 61

aws-sdk-cpp: unresolved symbols

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

Upvotes: 1

Views: 2737

Answers (1)

Jonathan Henson
Jonathan Henson

Reputation: 8206

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

Upvotes: 4

Related Questions