1

I'm having some troubles using AWS C++ SDK, due to a serious lack of documentation. However I managed to compile and install it on my computer.

I'm now trying hard to have a program working and resolved quite a lot of problems, but a (hopefully) last one remains that I cannot defeat alone...

Here is the code :

#include <aws/s3/model/GetObjectRequest.h>

int main()
{
     Aws::S3::Model::GetObjectRequest getObjectRequest;
}

I tried to have the simplest code for my example. That code doesn't compile, I've got the following error :

CMakeFiles/example.dir/example.cpp.o:(.rodata._ZTIN3Aws2S39S3RequestE[_ZTIN3Aws2S39S3RequestE]+0x10): undefined reference to `typeinfo for Aws::AmazonSerializableWebServiceRequest'

I don't get what the problem is. I tried checking in the source code of the library, and no pure virtual function remains in the GetObjectRequest class. I think I linked correctly the libraries. Here is my CMakeLists.txt :

project( TEST_AWS )
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
add_definitions ( -Wall -Wextra )

set(LIBAWSSDK_INCLUDE_DIR /usr/local/include/ CACHE STRING "aws SDK include directories")
set(LIBAWSSDK_CORE_LIB "-l:/usr/local/lib/libaws-cpp-sdk-core.so" CACHE STRING "aws SDK core link lib")
set(LIBAWSSDK_S3_LIB "-l:/usr/local/lib/libaws-cpp-sdk-s3.so" CACHE STRING "aws SDK S3 link lib")

set(target_external_libraries
    ${LIBAWSSDK_CORE_LIB}
    ${LIBAWSSDK_S3_LIB}
)

include_directories(
    ${LIBAWSSDK_INCLUDE_DIR}
)

add_executable( example example.cpp )
target_link_libraries( example ${target_external_libraries} )
target_compile_features(example PRIVATE cxx_lambdas)

I know the way I linked the library with cmake is a little bit dirty, but for the moment I just want the code to compile...

  • From what I see, your code compiles, it is linker that complains (as error is reported in `example.cpp.o` object file). – Zdeslav Vojkovic May 12 '16 at 09:52
  • Yes, I just considered linking as part of the compilation process. It's clearly a linking problem but I don't understand it as I linked the right libraries (I think). – Pierre Arquier May 12 '16 at 10:14
  • so, although you know that "the way I linked the library is not good at all", you still want it to build correctly? that's hard. I am not sure which toolset you are using, but as error points to missing typeinfo most likely the correct static library is not linked (and you need it to build the application) which contains the definitions for symbols declared in the code (e.g. http://stackoverflow.com/questions/307352/g-undefined-reference-to-typeinfo or http://stackoverflow.com/questions/8951884/undefined-reference-to-typeinfo-for-class). – Zdeslav Vojkovic May 12 '16 at 10:30
  • When I said my linking was "not good at all" I meant it's not the clean way to do it (absolute paths directly in CMakeLists.txt), I didn't mean it was not supposed to work. I think I linked the right static libraries, or if I'm wrong I don't see what is my error, hence this post. – Pierre Arquier May 12 '16 at 10:46
  • Ok, I see. I do c++ development on Windows, so can't help with details, but typically there is a tool which you can use to check if linked libs really contain the symbol (e.g. on win I use `dumpbin`). – Zdeslav Vojkovic May 12 '16 at 10:51
  • I edited this part to avoid further confusion. As I said it can't be a problem of a class beeing abstract, as this library is supposed to work, and GetObjectRequest isn't supposed to be abstract. As you said, I'm probably missing a static library to link, but I don't see which one, and maybe somebody knowing the SDK could know it better. – Pierre Arquier May 12 '16 at 10:51
  • Ok i didn't know about this kind of tools, I'll give it a look. Thank you! – Pierre Arquier May 12 '16 at 10:52
  • Just one thing: you mention static libs, but you actually link .so files, which is not considered a good practice AFAIK (but should work anyway). From what I find googling it seems that `Aws::AmazonSerializableWebServiceRequest` is indeed in `aws-cpp-sdk-core` – Zdeslav Vojkovic May 12 '16 at 10:59
  • typeinfo might also indicate that it is related to RTTI not being enabled. I found this on aws SDK github repo: `if(NOT PLATFORM_WINDOWS) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti")`. Or I might be completely clueless so I will stop now :) – Zdeslav Vojkovic May 12 '16 at 11:05
  • The -fno-rtti flag worked! I guess I didn't check enough topic about this kind of building errors, never saw that solution... Thanks a lot for your help and your patience! Have a nice day! – Pierre Arquier May 12 '16 at 12:20
  • @Zdeslav, see answer below start Very important, which discusses this rtti madness – blueether Jun 03 '16 at 11:51

2 Answers2

0

If you are using CMake, I recommend using the cmake export file from the SDK to avoid having to figure out what we are using. https://aws.amazon.com/blogs/developer/using-cmake-exports-with-the-aws-sdk-for-c/

The -fno-rtti flag will be removed and changed to an optional CMake flag.

If you use the CMake exports, it will properly generate your visual studio solution.

Update:

This has been fixed with the latest revision

Jonathan Henson
  • 8,076
  • 3
  • 28
  • 52
0
  • Very important: If you're compiling with RTTI (-frtti), make sure your dependent libraries are also compiled with it, and not -fno-rtti. Otherwise you will get the typeinfo error when you subclass a class compiled with -fno-rtti or use dynamic_cast. (C++: what are the causes of " undefined reference to 'typeinfo for [class name]' "other than virtual functions)

  • So, the -fno-rtti works only if you are compiling just the aws-sdk

  • Now, for most cases, there'll be many many other libraries that you will be compiling the aws-sdk with. Most libraries, opencv, etc are compiled with -frtti. If aws-sdk is compiled with -fno-rtti, then you will get the above typeinfo madness error

  • Solution: checkout the latest aws-sdk-cpp (as of June 1st). It uses the -frtti option..and then link against it, and Life is good

Community
  • 1
  • 1
blueether
  • 3,666
  • 4
  • 26
  • 32