Vcpkg: Errors building shared library due to Boost Log and PIC

Created on 19 Apr 2019  路  8Comments  路  Source: microsoft/vcpkg

Hi vcpkg developers,

Thanks very much for a great tool. I've bumped into a strange issue and I'm wondering what I'm doing wrong or if anyone has seen this before. Basically, I am using the vcpkg supplied Boost libraries, built statically, but I'd like to build my application itself with either static or shared libraries. CMake supports this through -DBUILD_SHARED_LIBS=ON.

The good news is that most of my code builds and links. Sadly, one of the libraries fails to link with the following error:

vcpkg/masd/installed/x64-linux/lib/libboost_log.a(core.o): relocation R_X86_64_PC32 against undefined hidden symbol `_ZTCN5boost10wrapexceptINS_9gregorian8bad_yearEEE0_NS_16exception_detail10clone_implINS4_19error_info_injectorIS2_EEEE' can not be used when making a shared object
/usr/bin/ld: vcpkg/masd/installed/x64-linux/lib/libboost_thread.a(thread.o): relocation R_X86_64_PC32 against undefined hidden symbol `_ZTCN5boost10wrapexceptINS_16bad_lexical_castEEE0_NS_16exception_detail10clone_implINS3_19error_info_injectorIS1_EEEE' can not be used when making a shared object
/usr/bin/ld: final link failed: nonrepresentable section on output

To the untrained eye, it is as if Boost Log was not built using PIC. I must say I don't fully grasp how boost-modular-build works, so I have the following questions:

  • is it possible to build Boost in both static library form and using PIC? e.g. something akin to CMake's CMAKE_POSITION_INDEPENDENT_CODE.
  • is Boost doing so in vcpkg by default at present?
  • if not, is it possible to convince it to do so?

I will continue to experiment but any ideas are appreciated.

Many thanks for your time.

Marco

port-bug

All 8 comments

Actually, I'm going to wait until vcpkg updates Boost to 1.70 and then re-test this with the new version. I'll try to get some information about how Boost.Log is being built as part of that exercise, to detect uses (or lack of) -fPIC.

@mcraveiro, thanks for posting this issue! We have PRs https://github.com/microsoft/vcpkg/pull/6141 to upgrade boost to 1.70.

@mcraveiro, the PR merged, boost upgrade to 1.70, you can re-test it with new version.

Excellent, thanks @PhoebeHui. Will test and report back. Cheers

Hi @mcraveiro, does this issue solved?

Hi, I'm afraid I haven't had the time to test it. I'm hoping to have a bit of time over the next month or so to check this.

@mcraveiro Okay, thanks.
This issue will remain open until it is resolved.

Please reopen this issue if it's still exists.

Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tzbo picture tzbo  路  3Comments

husseinalihazime picture husseinalihazime  路  3Comments

F0I0l0I0P picture F0I0l0I0P  路  3Comments

PhilLab picture PhilLab  路  3Comments

jasjuang picture jasjuang  路  3Comments