[CMake] linking static libs into shared libs on Linux
Dan Kegel
dank at kegel.com
Tue Jul 7 17:04:28 EDT 2015
On Tue, Jul 7, 2015 at 12:36 PM, Steve Borho <steve at borho.org> wrote:
> /bin/ld: common/CMakeFiles/common.dir/x86/pixel-a.asm.o: relocation
> R_X86_64_PC32 against symbol `x265_pw_1' can not be used when making a
> shared object; recompile with -fPIC
> ...
> 2 - is there some invocation that will force cmake to build the static
> libraries such that they are still safe for linking into a shared
> library?
>
> I've already tried these unsuccessfully:
> set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
> set_target_properties(x265-static PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
> set_target_properties(x265-static PROPERTIES LINK_FLAGS "-fPIC")
>
> 3 - is there another intermediate format that cmake can output that
> preserves -fPIC, or some way to access the object libraries of the
> other external builds?
Try
set_target_properties(x265-static PROPERTIES COMPILE_FLAGS "-fPIC")
Alternately, something like
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
when compiling the files in question.
More information about the CMake
mailing list