Skip to content

OS X: Linker errors when using static library - Undefined symbols for architecture x86_64 #51

Closed
@triton3

Description

@triton3

Hi

I am getting linker errors "Undefined symbols for architecture x86_64: " when trying to use the static libraries (build steps I used are noted below), in an XCode C++ command line project. I included the static libraries (.a) in Xcode Build-phases -> Link binary with libraries, and added their location paths to Build-Settings -> Library Search Paths. Full error report below.

Is there anything else I need to add (linker flags, settings, etc.) to resolve this error? Any help would be greatly appreciated.

PS: The code works on Windows Visual Studio, so I am wondering if there is anything I missed when trying it on OS X.

Error Report:

Undefined symbols for architecture x86_64:
  "Aws::Auth::CognitoCachingAnonymousCredentialsProvider::CognitoCachingAnonymousCredentialsProvider(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::shared_ptr<Aws::CognitoIdentity::CognitoIdentityClient> const&)", referenced from:
      std::__1::shared_ptr<Aws::Auth::CognitoCachingAnonymousCredentialsProvider> std::__1::shared_ptr<Aws::Auth::CognitoCachingAnonymousCredentialsProvider>::allocate_shared<std::__1::allocator<Aws::Auth::CognitoCachingAnonymousCredentialsProvider>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&>(std::__1::allocator<Aws::Auth::CognitoCachingAnonymousCredentialsProvider> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&&&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&&&) in aws-cpp-experiments.o
  "Aws::Utils::Json::JsonValue::WithObject(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, Aws::Utils::Json::JsonValue const&)", referenced from:
      getCurrentUserAuthenticatedCredentials(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in aws-cpp-experiments.o
  "Aws::Utils::Json::JsonValue::WithString(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      getCurrentUserAuthenticatedCredentials(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in aws-cpp-experiments.o
  "Aws::Utils::Json::JsonValue::WithInt64(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, long long)", referenced from:
      getCurrentUserAuthenticatedCredentials(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in aws-cpp-experiments.o
  "Aws::Utils::Logging::DefaultLogSystem::DefaultLogSystem(Aws::Utils::Logging::LogLevel, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      std::__1::shared_ptr<Aws::Utils::Logging::DefaultLogSystem> std::__1::shared_ptr<Aws::Utils::Logging::DefaultLogSystem>::allocate_shared<std::__1::allocator<Aws::Utils::Logging::DefaultLogSystem>, Aws::Utils::Logging::LogLevel, char const (&) [9]>(std::__1::allocator<Aws::Utils::Logging::DefaultLogSystem> const&, Aws::Utils::Logging::LogLevel&&, char const (&&&) [9]) in aws-cpp-experiments.o
  "Aws::DynamoDB::Model::AttributeValue::SetS(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      Aws::DynamoDB::Model::AttributeValue::AttributeValue(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in aws-cpp-experiments.o
  "Aws::Utils::Json::JsonValue::GetInt64(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const", referenced from:
      isValidCredentials(Aws::Utils::Json::JsonValue) in aws-cpp-experiments.o
  "Aws::Utils::Json::JsonValue::GetString(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const", referenced from:
      isValidCredentials(Aws::Utils::Json::JsonValue) in aws-cpp-experiments.o
      getData1(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, Aws::Utils::Json::JsonValue) in aws-cpp-experiments.o
      getData2(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, Aws::Utils::Json::JsonValue) in aws-cpp-experiments.o
      isValidData(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, Aws::Utils::Json::JsonValue) in aws-cpp-experiments.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Build-Steps: I used the following to build the c++ sdk on Mac OS X (El Capitan).

  1. Added the following to CMakeLists.txt in the source folder (~/aws-sdk-cpp/CMakeLists.txt)
SET(STATIC_LINKING 1)
  1. Used following commands for creating XCode projects
cd "build-dir-path"
cmake -G Xcode "path-to-sdk-source-root"

Output of CMake:

-- TARGET_ARCH not specified; inferring host OS to be platform compilation target
-- Generating Mac OSX/IOS build config
-- Dynamic linking disabled
-- Custom memory management disabled
-- Http client: Curl
-- Encryption: CommonCrypto
-- The C compiler identification is AppleClang 7.0.0.7000176
-- The CXX compiler identification is AppleClang 7.0.0.7000176
-- Check for working C compiler using: Xcode
-- Check for working C compiler using: Xcode -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler using: Xcode
-- Check for working CXX compiler using: Xcode -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Install binary prefix: mac
-- Downloading client source from: 
-- Configuring done
-- Generating done
-- Build files have been written to: ~/build-dir
  1. From the created ~/build-dir/AWSNativeSDKAll.xcodeproj, I ran this to build the static libraries for all modules.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedWe are asking the community to submit a PR to resolve this issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions