Aws-sdk-cpp: Static libaws-checksums.a note usable for creating shared library due to -fPIC missing

Created on 17 Nov 2018  路  5Comments  路  Source: aws/aws-sdk-cpp

What platform/OS are you using?

CentOS Linux release 7.5.1804 (Core)

What compiler are you using? what version?

[root@dev-centos]# cmake3 --version
cmake3 version 3.12.2

What's your CMake arguments?

cmake3 -DCMAKE_BUILD_TYPE=Release -DBUILD_ONLY="core;sqs" -DBUILD_SHARED_LIBS="OFF" -DENABLE_TESTING="OFF"

Can you provide a TRACE level log? (sanitize any sensitive information)

/usr/bin/ld: /aws-sdk-cpp/.deps/install/lib/libaws-checksums.a(cpuid_generic.c.o): relocation R_X86_64_32 against .bss' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /aws-sdk-cpp/.deps/install/lib/libaws-checksums.a(crc.c.o): relocation R_X86_64_32S against symbolaws_checksums_crc32c_sw' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /aws-sdk-cpp/.deps/install/lib/libaws-checksums.a(crc_sw.c.o): relocation R_X86_64_32S against symbol `CRC32_TABLE' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status

Most helpful comment

A fix for this issue is on the way. Sorry about that.

All 5 comments

@efendizadeh: Did you ever manage to find a solution to this?

I am facing the same problem in my project which builds a shared library on Ubuntu 18.04 with gcc-8.

I am building the sdk as follows:

cmake -DBUILD_ONLY="s3;s3-encryption" -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release

I am yet to try older gcc versions. Just wondered if there was any known solutions before spending more time looking into it...

EDIT:

On further investigation, it looks like aws-checksums doesn't have any AwsCFlags configuration here:

https://github.com/awslabs/aws-checksums/tree/master/cmake

which do appear in the other dependencies:

https://github.com/awslabs/aws-c-common/tree/master/cmake

I'm not sure how to ensure that aws-checksums compiles with -fPIC which looks like it will solve it.

EDIT 2:

Edit .deps/build/src/AwsChecksums-build/CMakeFiles/aws-checksums.dir/flags.make in your build dir and add the -fPIC here:

C_FLAGS = -O3 -DNDEBUG -fPIC -std=gnu99

In directory .deps/build/src/AwsChecksums-build run make install and you will then be able to build your shared libraries. Works with gcc-7 and gcc-8 so far.

Not sure how to fix the cause of the problem, and I'm surprised no one else has come across this...

@pmcenery problem is actual for me, as a temporary solution i am using old commits from aws repo. I will try your method. And also I'm surprised no one has such kind of problem. Probably they are not creating shared library using aws sdk.

A fix for this issue is on the way. Sorry about that.

Thanks @marccomagdy.

This looks like the fix:

https://github.com/awslabs/aws-checksums/commit/b06b1f7294cc4bafb3a3b7c771f14ea426e2cda8

I guess the aws-sdk-cpp dep checkout just needs to pull anything newer than this (once tested).

Correct. It's just a little tricky when the newer dependencies don't build on some of the platforms that we support (e.g. Android). We have to submit patches and work through the problems until we get a stable set of versions that we can pin to. So, bear with us please.

Was this page helpful?
0 / 5 - 0 ratings