You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the introduction of the new release 1.8.0 compilation runned fine but the linking failed.
System info:
Googletest 1.8.0
Debian 8 AMD64
GCC 4.9.2 (debian)
CMake 3.5.1
Error:
[ 44%] Linking CXX executable time
/usr/bin/ld: gtest-prefix/src/gtest-build/libgtest.a(gtest-all.cc.o): relocation R_X86_64_32S against `_ZTVN7testing8internal17TestEventRepeaterE' can not be used when making a shared object
; recompile with -fPIC
gtest-prefix/src/gtest-build/libgtest.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
tests/CMakeFiles/time.dir/build.make:97: recipe for target 'tests/time' failed
make[3]: *** [tests/time] Error 1
CMakeFiles/Makefile2:1672: recipe for target 'tests/CMakeFiles/time.dir/all' failed
make[2]: *** [tests/CMakeFiles/time.dir/all] Error 2
I patch the googletest CMakeLists.txt localy with (from here):
#-----------------------------------------------------------------------------
# Add needed flag for gnu on linux like enviroments to build static common libs
# suitable for linking with shared object libs.
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
if(NOT "${CMAKE_CXX_FLAGS}" MATCHES "-fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif()
if(NOT "${CMAKE_C_FLAGS}" MATCHES "-fPIC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
endif()
endif()
This seems to work but beter would be a option which is enabled by default like LLVM does:
LLVM_ENABLE_PIC:BOOL
Add the -fPIC flag to the compiler command-line, if the compiler supports this flag. Some systems, like Windows, do not need this flag. Defaults to ON.
option(gtest_enable_pic "Build with -fPIC flag"ON)
function(add_flag_or_print_warning flag name)
check_cxx_compiler_flag("-Werror ${flag}""CXX_SUPPORTS_${name}")
if (CXX_SUPPORTS_${name})
message(STATUS"Building with ${flag}")
set(CMAKE_CXX_FLAGS"${CMAKE_CXX_FLAGS}${flag}" PARENT_SCOPE)
else()
message(WARNING "${flag} is not supported.")
endif()
endfunction()
if( gtest_enable_pic )
if( XCODE )
# Xcode has -mdynamic-no-pic on by default, which overrides -fPIC. I don't# know how to disable this, so just force ENABLE_PIC off for now. message(WARNING "-fPIC not supported with Xcode.")
elseif( WIN32ORCYGWIN)
# On Windows all code is PIC. MinGW warns if -fPIC is used. else()
add_flag_or_print_warning("-fPIC" FPIC)
endif()
endif()
What do you think?
The text was updated successfully, but these errors were encountered:
With the introduction of the new release 1.8.0 compilation runned fine but the linking failed.
System info:
Error:
We use CMake
ExternalProject_Add
I patch the googletest CMakeLists.txt localy with (from here):
This seems to work but beter would be a option which is enabled by default like LLVM does:
Which will look like this (taken from LLVM):
What do you think?
The text was updated successfully, but these errors were encountered: