glog icon indicating copy to clipboard operation
glog copied to clipboard

Link failed when WITH_THREADS is set to OFF

Open MrJia1997 opened this issue 3 years ago • 1 comments

Version: v0.6.0 (should be reproducible on master) Platform: macOS 12.6 Compiler: AppleClang 14.0.0

When WITH_THREADS options is set to OFF, linking glog will pop an linking error which says undef: __ZN6google24glog_internal_namespace_31IsFailureSignalHandlerInstalledEv

It looks like the symbol google::glog_internal_namespace_::IsFailureSignalHandlerInstalled() is defined in src/signalhandler.cc , https://github.com/google/glog/blob/05fbc65278db1aa545ca5cb743c31bc717a48d0f/src/signalhandler.cc#L367-L381

and the source file will not be included in the build target if WITH_THREADS is set to OFF. https://github.com/google/glog/blob/05fbc65278db1aa545ca5cb743c31bc717a48d0f/CMakeLists.txt#L530-L536 https://github.com/google/glog/blob/05fbc65278db1aa545ca5cb743c31bc717a48d0f/CMakeLists.txt#L621-L623

Is this an intended behavior? If not, I can help to fix this.

MrJia1997 avatar Sep 30 '22 03:09 MrJia1997

Any advice here?

MrJia1997 avatar Oct 14 '22 02:10 MrJia1997

Hi there, I just came to the same problem. Just comment the if condition line in the glog/CMakeLists.txt to fix.

#if (HAVE_PTHREAD OR WIN32 OR CYGWIN) 
list (APPEND GLOG_SRCS src/signalhandler.cc) 
#endif (HAVE_PTHREAD OR WIN32 OR CYGWIN)

And I tried some basic functions, like LOG(INFO), they worked. But not sure if there will be unknown issues, and I wonder if this is an intended behavior too. Wish this will help.

MrSome1 avatar Nov 24 '22 02:11 MrSome1