chennqqi / server1

Automatically exported from code.google.com/p/server1
1 stars 0 forks source link

undefined reference to `fLI::FLAGS_v’ #1

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. On Ubuntu Linux or Snow Leopard, build and `make install' the required 
libraries and scons;
2. Build server1 by simply typing path/scons in the source dir.

What is the expected output? What do you see instead?

It complains 

  undefined reference to `fLI::FLAGS_v’

at everywhere VLOG() << was invoked.

What version of the product are you using? On what operating system?

On Ubuntu Linux or Snow Leopard.

Please provide any additional information below.

g++ -o build/base/allocator_test build/base/allocator_test.o -Wl,-Bdynamic 
-lpthread -Wl,-Bstatic -g -L/home/yiwang/3rd-party/boost/lib 
-L/home/yiwang/3rd-party/gflags/lib -L/home/yiwang/3rd-party/glog/lib 
-L/home/yiwang/3rd-party/protobuf/lib -L/home/yiwang/3rd-party/gtest/lib 
-Lbuild/base -Lbase -lbase -lglog -lprotobuf -lboost_thread -lboost_regex 
-lboost_graph -lboost_math_tr1 -lboost_signals -lboost_math_tr1f 
-lboost_filesystem -lboost_serialization -lboost_unit_test_framework 
-lboost_date_time -lboost_wserialization -lboost_math_c99 -lboost_system 
-lboost_program_options -lboost_math_c99f -lboost_test_exec_monitor 
-lboost_math_c99l -lboost_prg_exec_monitor -lboost_math_tr1l -lboost_random 
-lboost_wave -lgtest -lgflags -Wl,-Bdynamic
build/base/allocator_test.o: In function 
`AllocatorTest_Test1_Test::TestBody()’:
/home/yiwang/Projects/server1-read-only/base/allocator_test.cpp:22: undefined 
reference to `fLI::FLAGS_v’
build/base/allocator_test.o: In function `Allocator::Allocate(unsigned int)’:
/home/yiwang/Projects/server1-read-only/./base/allocator.hpp:19: undefined 
reference to `fLI::FLAGS_v’
build/base/allocator_test.o: In function `Allocator::Deallocate(void*)’:
/home/yiwang/Projects/server1-read-only/./base/allocator.hpp:25: undefined 
reference to `fLI::FLAGS_v’
build/base/allocator_test.o: In function `~Allocator’:
/home/yiwang/Projects/server1-read-only/./base/allocator.hpp:29: undefined 
reference to `fLI::FLAGS_v’
/home/yiwang/Projects/server1-read-only/./base/allocator.hpp:35: undefined 
reference to `fLI::FLAGS_v’
build/base/allocator_test.o:/home/yiwang/Projects/server1-read-only/./base/alloc
ator.hpp:41: more undefined references to `fLI::FLAGS_v’ follow

Original issue reported on code.google.com by Yi.Wang.2005 on 9 Oct 2010 at 12:45

GoogleCodeExporter commented 8 years ago
I got error messages when typing scons

scons
scons: Reading SConscript files ...

scons: warning: The env.Copy() method is deprecated; use the env.Clone() method 
instead.
File "/local/mnt/workspace/server1/src/Sconstruct", line 101, in Test
scons: done reading SConscript files.
scons: Building targets ...
g++ -o build/base/allocator_test.o -c -march=i486 -g -static -Ibuild -I. 
-I/local/mnt/workspace/server1/third_party/boost/boost 
-I/local/mnt/workspace/server1/third_party/gflags/include 
-I/local/mnt/workspace/server1/third_party/glog/include 
-I/local/mnt/workspace/server1/third_party/protobuf/include 
-I/local/mnt/workspace/server1/third_party/protobuf/include/google 
-I/local/mnt/workspace/server1/third_party/gtest/include base/allocator_test.cpp
base/allocator_test.cpp:1: error: CPU you selected does not support x86-64 
instruction set
base/allocator_test.cpp:1: error: CPU you selected does not support x86-64 
instruction set
scons: *** [build/base/allocator_test.o] Error 1
scons: building terminated because of errors.

Original comment by felixc...@gmail.com on 20 Nov 2010 at 12:10

GoogleCodeExporter commented 8 years ago
This is caused by linking gflags and glog in the wrong order on the linker 
commandline. Try linking with "-lgflags -lglog" instead of "-lglog -lgflags".

Original comment by k...@google.com on 12 Jun 2011 at 8:06

GoogleCodeExporter commented 8 years ago
I can't say why this happens, but in the glog code, when I build that, the 
namespace defined in src/base/commandlineflags.h when compiled into the 
libglog.so goes in as

namespace FLAG__namespace_do_not_use_directly_use_DECLARE_int32_instead { 
google::int32 FLAGS_v((!getenv("GLOG_" "v") ? (0) : strtol(getenv("GLOG_" "v"), 
__null, 10))); char FLAGS_nov; } using 
FLAG__namespace_do_not_use_directly_use_DECLARE_int32_instead::FLAGS_v;

and when I am trying to build the server1 RPC code, and the same code goes 
through the g++ when compiling the code there, I get the following:

namespace fLI { extern google::int32 FLAGS_v; } using fLI::FLAGS_v;

I played with compile options, I tried to use strace to see what g++ was doing 
etc, but I could not see why these two compiled differently.

Cheers

Original comment by jhalland...@gmail.com on 1 Dec 2011 at 12:05

GoogleCodeExporter commented 8 years ago
When I encoutered this problem it was due to the order in which glogs and 
gflags had been built. If you're using both, you need to build gflags first, 
then build glog. glog includes an IFDEF that will link in its own version of 
gflags if it's not found on the system. If you build with that, and then build 
gflags and run, you'll have issues.

Original comment by joel.me...@gmail.com on 7 Aug 2012 at 5:36

GoogleCodeExporter commented 8 years ago
I met the same error messages with yiwang(Yi.Wang.2005@gmail.com).

Original comment by ofandyw...@gmail.com on 29 Dec 2012 at 3:57