xunzhang / gflags

Automatically exported from code.google.com/p/gflags
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

compile problem #87

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Dear Sir:
  Really sorry to bother you,However,when I compile the gflags(2.1.1),I found a error occured. I have utilized the cmake ., make && make install comond to prepare the environment. it says like following:

Scanning dependencies of target gflags-static
[ 16%] Building CXX object CMakeFiles/gflags-static.dir/src/gflags.cc.o
[ 33%] Building CXX object 
CMakeFiles/gflags-static.dir/src/gflags_reporting.cc.o
[ 50%] Building CXX object 
CMakeFiles/gflags-static.dir/src/gflags_completions.cc.o
Linking CXX static library lib/libgflags.a
[ 50%] Built target gflags-static
Scanning dependencies of target gflags_nothreads-static
[ 66%] Building CXX object 
CMakeFiles/gflags_nothreads-static.dir/src/gflags.cc.o
[ 83%] Building CXX object 
CMakeFiles/gflags_nothreads-static.dir/src/gflags_reporting.cc.o
[100%] Building CXX object 
CMakeFiles/gflags_nothreads-static.dir/src/gflags_completions.cc.o
Linking CXX static library lib/libgflags_nothreads.a
[100%] Built target gflags_nothreads-static
root@hon:/home/hon/桌面/gflags-2.1.1# make install
[ 50%] Built target gflags-static
[100%] Built target gflags_nothreads-static
Install the project...
-- Install configuration: "Release"
-- Installing: /usr/local/lib/libgflags.a
-- Installing: /usr/local/lib/libgflags_nothreads.a
-- Installing: /usr/local/include/gflags/gflags.h
-- Installing: /usr/local/include/gflags/gflags_declare.h
-- Installing: /usr/local/include/gflags/gflags_completions.h
-- Installing: /usr/local/lib/cmake/gflags/gflags-config.cmake
-- Installing: /usr/local/lib/cmake/gflags/gflags-config-version.cmake
-- Installing: /usr/local/lib/cmake/gflags/gflags-export.cmake
-- Installing: /usr/local/lib/cmake/gflags/gflags-export-release.cmake
-- Installing: /usr/local/bin/gflags_completions.sh

Besides that, I wrote a simple code(named demo.c) to test that.The source code 
looks like following:

#include <iostream>
#include <gflags/gflags.h>

DEFINE_bool(isvip, false, "If Is VIP");
DEFINE_string(ip, "127.0.0.1", "connect ip");
DECLARE_int32(port);
DEFINE_int32(port, 80, "listen port");

int main(int argc, char** argv)
{
  google::ParseCommandLineFlags(&argc, &argv, true);
  std::cout<<"ip:"<<FLAGS_ip<<std::endl;
  std::cout<<"port:"<<FLAGS_port<<std::endl;
  if (FLAGS_isvip)
  {
      std::cout<<"isvip:"<<FLAGS_isvip<<std::endl;
  }
  google::ShutDownCommandLineFlags();
  return 0;
}

After that. I utilized the following command to compile :

g++ -o demo demo.c -L/home/hon/Desktop/gflags-2.1.0/lib -lgflags 
-I/home/hon/Desktop/gflags-2.1.0/include/

However, it says :

demo.c: In function ‘int main(int, char**)’:
demo.c:11:3: error: ‘google’ has not been declared
   google::ParseCommandLineFlags(&argc, &argv, true);
   ^
demo.c:18:3: error: ‘google’ has not been declared
   google::ShutDownCommandLineFlags();

could you give a favor and let me know what's wrong? Thank you very much. 

Original issue reported on code.google.com by crystalt...@gmail.com on 15 Oct 2014 at 1:55

GoogleCodeExporter commented 9 years ago
This error relates to the change of the default namespace from "google" to 
"gflags" with release of version 2.1. The problem will be fixed in the next 
release 2.1.2 (cf. issue 83).

Change "google::" in your demo.c to "gflags::" and try again.

Original comment by andreas....@gmail.com on 15 Oct 2014 at 2:12

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Really thank you for your favor! it has already worked

Original comment by paul.bb....@gmail.com on 16 Oct 2014 at 1:46

GoogleCodeExporter commented 9 years ago

Original comment by andreas....@gmail.com on 9 Nov 2014 at 9:00