aws-c-common icon indicating copy to clipboard operation
aws-c-common copied to clipboard

Including AWS Common as an External Project

Open disa6302 opened this issue 3 years ago • 1 comments
trafficstars

I am trying to include aws-c-common as an external project in my CMake file and I am linking library as aws-c-common in target link libraries. This is the external project:

cmake_minimum_required(VERSION 3.6.3)

project(libawscommon-download NONE)
include(ExternalProject)

ExternalProject_Add(project_libawscommon
    GIT_REPOSITORY    https://github.com/awslabs/aws-c-common.git
    GIT_TAG                    v0.6.13
    CMAKE_ARGS        -DCMAKE_INSTALL_PREFIX=${OPEN_SRC_INSTALL_PREFIX}
)

The error I am seeing is this on MacOS Bigsur:

Undefined symbols for architecture x86_64:
  "_CFAllocatorCreate", referenced from:
      _aws_wrapped_cf_allocator_new in libaws-c-common.a(allocator.c.o)
  "_CFRelease", referenced from:
      _aws_wrapped_cf_allocator_destroy in libaws-c-common.a(allocator.c.o)
  "___CFConstantStringClassReference", referenced from:
      CFString in libaws-c-common.a(allocator.c.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I see a static library in the following path: ${OPEN_SRC_INSTALL_PREFIX}/lib/libaws-c-common.a

What could be going wrong here?

disa6302 avatar Feb 14 '22 21:02 disa6302

I got it working by adding "-framework CoreFoundation" in target-link-libraries. I see that this is being set here: https://github.com/awslabs/aws-c-common/blob/302686235944164866b1e386e37f72a72e006394/CMakeLists.txt#L92

Any reason why this might not be migrating to upstream CMake projects?

disa6302 avatar Feb 15 '22 00:02 disa6302

I'm not sure why this wouldn't be migrating to upstream CMake projects. But I'm glad that you where able to get it working. Please let know if you have any other problems with aws-c-common.

jmklix avatar Feb 07 '24 00:02 jmklix