cthsieh2001 / google-glog

Automatically exported from code.google.com/p/google-glog
Other
0 stars 0 forks source link

Link error when compiled with libunwind and linking statically #207

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
On a system with libunwind usable, libglog depends on libunwind 
(HAVE_LIBUNWIND_H and friends are set).  However, the .pc file still does not 
reference it.

What steps will reproduce the problem?
1. Install usable libunwind (e.g. on recent Ubunut, apt-get install 
libunwind8-dev)
2. Run configure script for glog
3. Try to statically link glog with another program using the output of 
$(pkg-config --static --libs glog).

What is the expected output? What do you see instead?
pkg-config --static --libs glog should output '-L/usr/lib -lglog -lunwind', and 
the program should link successfully.

Instead, the output is '-L/usr/lib -lglog', and the program fails to link with 
errors like this:

Linking CXX executable protobufutil_test
/usr/bin/cmake -E cmake_link_script CMakeFiles/protobufutil_test.dir/link.txt 
--verbose=1
g++   -g --std=c++11 -Wall -Wextra -Werror -Wno-unused-parameter 
-Wno-unused-local-typedefs -Wno-unknown-warning-option -Wno-null-dereference 
-DGTEST_USE_OWN_TR1_TUPLE=1    
CMakeFiles/protobufutil_test.dir/src/message_stream_test.cc.o 
CMakeFiles/protobufutil_test.dir/src/protobufutil_test.cc.o 
CMakeFiles/protobufutil_test.dir/src/string_value_test.cc.o  -o 
protobufutil_test -rdynamic libprotobufutil.a vendor/src/gmock/libgmock.a 
vendor/src/gtest/libgtest.a vendor/lib/libglog.a vendor/lib/libgflags.a 
vendor/lib/libssl.a vendor/lib/libcrypto.a vendor/lib/libprotobuf.a -ldl 
-lpthread 
vendor/lib/libglog.a(libglog_la-utilities.o): In function 
`google::GetStackTrace(void**, int, int)':
/local/adp/unwind-compile-error/protobuf-util/vendor/src/glog-build/../glog/src/
stacktrace_libunwind-inl.h:65: undefined reference to `_Ux86_64_getcontext'
/local/adp/unwind-compile-error/protobuf-util/vendor/src/glog-build/../glog/src/
stacktrace_libunwind-inl.h:66: undefined reference to `_ULx86_64_init_local'
/local/adp/unwind-compile-error/protobuf-util/vendor/src/glog-build/../glog/src/
stacktrace_libunwind-inl.h:78: undefined reference to `_ULx86_64_step'
/local/adp/unwind-compile-error/protobuf-util/vendor/src/glog-build/../glog/src/
stacktrace_libunwind-inl.h:70: undefined reference to `_ULx86_64_get_reg'
collect2: error: ld returned 1 exit status
make[2]: *** [protobufutil_test] Error 1
make[2]: Leaving directory `/local/adp/unwind-compile-error/protobuf-util'
make[1]: *** [CMakeFiles/protobufutil_test.dir/all] Error 2
make[1]: Leaving directory `/local/adp/unwind-compile-error/protobuf-util'
make: *** [all] Error 2

What version of the product are you using? On what operating system?
Can be reproduced on head of trunk 

Path: .
URL: http://google-glog.googlecode.com/svn/trunk
Repository Root: http://google-glog.googlecode.com/svn
Repository UUID: eb4d4688-79bd-11dd-afb4-1d65580434c0
Revision: 142
Node Kind: directory
Schedule: normal
Last Changed Author: shinichiro.hamaji@gmail.com
Last Changed Rev: 142
Last Changed Date: 2014-03-05 05:20:24 +0000 (Wed, 05 Mar 2014)

I'm working on Ubuntu 13.10 64-bit.

Please provide any additional information below.

The attached patch fixes the problem.

Original issue reported on code.google.com by andrew.p...@gmail.com on 11 May 2014 at 7:42

Attachments:

GoogleCodeExporter commented 8 years ago
Ah, I didn't know pkg-config accepts --static flag. I'd like to use your patch, 
maybe with some modifications. I guess we might also want to have -lgflags when 
it is detected.

Could you sign our Contributor License Agreement, please? It
seems that we need to ask you to sign this to avoid any troubles. The
process is just submitting an HTML form, and it shouldn't take your
time so much.

http://code.google.com/legal/individual-cla-v1.0.html

Please note that these forms do not transfer copyright: the
contributor retains her ownership in the work. The CLA just grants
Google a "perpetual, non-exclusive, royalty-free, etc..." right to use
the work, sublicense it, and so on.

Original comment by ham...@chromium.org on 12 May 2014 at 3:04

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Thanks for your prompt response.  I have now signed the agreement.  Good point 
regarding gflags.

Original comment by andrew.p...@gmail.com on 12 May 2014 at 2:26