Add cmake flags to avoid library path conflicts
I encountered the error "flag 'tab_complete_word' was defined more than once (in files '/path/a/gflags_completions.cc' and '/path/b/gflags_completions.cc' " . It can be fixed by adding the following flags in find_path and find_library of FindGFlags.cmake or maybe all the cmake scripts. The desired path can be specified with the command line flag -DCMAKE_PREFIX_PATH.
NO_DEFAULT_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_CMAKE_PATH
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH
The available flags are explained here and an example is here
Is this still needed with #1667? That PR reforms the CMake build. On Thu, Jan 22, 2015 at 06:47 futurely [email protected] wrote:
I encountered an error "flag 'tab_complete_word' was defined more than once (in files '/path/a/gflags_completions.cc' and '/path/b/gflags_completions.cc' " . It can be fixed by adding the following flags in find_path and find_library of FindGFlags.cmake or maybe all the cmake scripts. The desired path can be specified with the command line flag -DCMAKE_PREFIX_PATH.
NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATHThe available flags are explained here http://www.cmake.org/cmake/help/v3.0/command/find_library.html and an example is here https://trac.e-technik.uni-rostock.de/svn/ws4d-gsoap/tags/release-0.7/cmake-modules/FindGSOAP.cmake
— Reply to this email directly or view it on GitHub https://github.com/BVLC/caffe/issues/1782.
It's awesome. But to get rid of this error quickly, I just used the command cmake -DCMAKE_PREFIX_PATH=$PREFIX and only two macros should be added.
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH
The working version is here FYI.
# - Try to find GFLAGS
#
# The following variables are optionally searched for defaults
# GFLAGS_ROOT_DIR: Base directory where all GFLAGS components are found
#
# The following are set after configuration is done:
# GFLAGS_FOUND
# GFLAGS_INCLUDE_DIRS
# GFLAGS_LIBRARIES
# GFLAGS_LIBRARYRARY_DIRS
include(FindPackageHandleStandardArgs)
set(GFLAGS_ROOT_DIR "" CACHE PATH "Folder contains Gflags")
# We are testing only a couple of files in the include directories
if(WIN32)
find_path(GFLAGS_INCLUDE_DIR gflags/gflags.h
PATHS ${GFLAGS_ROOT_DIR}/src/windows
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH)
else()
find_path(GFLAGS_INCLUDE_DIR gflags/gflags.h
PATHS ${GFLAGS_ROOT_DIR}
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH)
endif()
if(MSVC)
find_library(GFLAGS_LIBRARY_RELEASE
NAMES libgflags
PATHS ${GFLAGS_ROOT_DIR}
PATH_SUFFIXES Release
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH)
find_library(GFLAGS_LIBRARY_DEBUG
NAMES libgflags-debug
PATHS ${GFLAGS_ROOT_DIR}
PATH_SUFFIXES Debug
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH)
set(GFLAGS_LIBRARY optimized ${GFLAGS_LIBRARY_RELEASE} debug ${GFLAGS_LIBRARY_DEBUG})
else()
find_library(GFLAGS_LIBRARY gflags
PATHS ${GFLAGS_ROOT_DIR}
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH)
endif()
find_package_handle_standard_args(GFLAGS DEFAULT_MSG
GFLAGS_INCLUDE_DIR GFLAGS_LIBRARY)
if(GFLAGS_FOUND)
set(GFLAGS_INCLUDE_DIRS ${GFLAGS_INCLUDE_DIR})
set(GFLAGS_LIBRARIES ${GFLAGS_LIBRARY})
endif()
@futurely I have tried those steps, but the error still persisted.
It said that: ERROR: flag 'tab_completion_word' was defined more than once (in files 'src/gflags_completions.cc' and '/path/../src/gflags_completions.cc')
@cuongduc There're more than one gflags installations on your system. Find their paths with sudo find / -name gflags_completions.cc and remove all but one of the installations.
@futurely I have done that, but the error still happened. Do I need to recompile Caffe again?
Just do it.
@futurely I recompiled Caffe but nothing changed. I think that I need to remove completely gflags from my system and reinstall it. Hum, it's gonna be tricky as I am using a cluster with very little permission in my hand. Gonna see if there is any workaround that does not require reinstall. Thank you
I have done that, I also reinstall the gflags. the error still happened. what should i do in the next? It said,".build_release/tools/caffe ERROR: flag 'tab_completion_word' was defined more than once (in files 'src/gflags_completions.cc' and 'path/gflags/src/gflags_completions.cc'). "
The error means that there're at least two gflags installed. Have you tried to delete one of them?
recently, I tried the command you suggested sudo find / -name gflags_completions.cc and the system shows nothing (on a CentOS Cluster). However, I still cannot run caffe because of the error .build_release/tools/caffe ERROR: flag 'tab_completion_word' was defined more than once (in files 'src/gflags_completions.cc' and '/media/hd1/home/path/gflags-master/src/gflags_completions.cc'). make: *** [runtest] Error 1
The interesting here is there is no 'path/gflags-master/src/gflags_completions.cc' now as I deleted that file after gflags installtation finished.
I also tried to recompile caffe again and again but the problem stays strictly the same.
My system is CentOS 6.5. I met the same problem as you. I tried many methods to fix that, but the problem stays there. @cuongduc ‘’‘ recently, I tried the command you suggested sudo find / -name gflags_completions.cc and the system shows nothing (on a CentOS Cluster). However, I still cannot run caffe because of the error .build_release/tools/caffe ERROR: flag 'tab_completion_word' was defined more than once (in files 'src/gflags_completions.cc' and '/media/hd1/home/path/gflags-master/src/gflags_completions.cc'). make: *** [runtest] Error 1
The interesting here is there is now no 'path/gflags-master/src/gflags_completions.cc' now as I deleted that file after gflags installtation finished.
I also tried to recompile caffe again and again but the problem stays strictly the same. “”
Yep. It's really weird. Basically, I just stopped trying to run Caffe on the CentOS cluster and move to my personal PC running Ubuntu and every thing is fine (though the PC is much less powerful).
If you can re-install the OS, RHEL 6 is OK and Ubuntu server might be better.
@xjpvincent @cuongduc
I meet the same problem:
ERROR: something wrong with flag 'tab_completion_word' in file '/data/software/source/gflags-master/src/gflags_completions.cc'. One possibility: file '/data/software/source/gflags-master/src/gflags_completions.cc' is being linked both statically and dyn..
While searching tab_completion_word in the dependencies of build/tools/caffe, I got the following output:
caffe $ grep -rnw tab_completion_word `ldd build/tools/caffe | sed 's/.*=> //g' | sed 's/ (.*//g'`
Binary file /usr/local/lib/libglog.so.0 matches
Binary file /usr/local/lib/libgflags.so.2 matches
I think glog is linked to static libraries of gflags. After rebuild glog which link to shared libraries of gflags, the problem solved.
Hope this can help you (:
@wanji Thank you, wanji. That's really helpful. Besides,using the old version of gflags also can fix this problem.
I tried to manually compile gflags2.1.2 into my local directory for installing Caffe, and got the same problem as reported by @futurely. I tried all methods mentioned above but the problem still exists. :( I was desperate and removed all the files installed by gflags, and then suddenly it worked! I am pretty sure gflags is not installed globally.
I used the older glfags 2.1 version and the problem gone. Maybe you can try this way.
On Sat, Oct 3, 2015 at 5:53 PM, Jimmy Ng [email protected] wrote:
I tried to manually compile gflags2.1.2 into my local directory for installing Caffe, and got the same problem as reported by @futurely https://github.com/futurely. I tried all methods mentioned above but the problem still exists. :( I was desperate and removed all the files installed by gflags, and then suddenly it worked! I am pretty sure gflags is not installed globally.
— Reply to this email directly or view it on GitHub https://github.com/BVLC/caffe/issues/1782#issuecomment-145231437.
Sincerely,
Jingping.Xu State Key Laboratory of Cognitive Neuroscience and Learning, Beijing Normal University Add: No.19 Xinjiekouwai Street, Beijing, 100875, China, PR Tel: (+86)18101359781
I had the same problem. But on doing a 'find', I realized that there was another version of gflags installed on my system and that I had inadvertently built and installed glog before I had built and installed gflags. So if you're having the same problem, try and first build and install gflags first after which, build and install glog using the --with-gflags=/path/to/your/gflags/installation flag (when using configure to build glog)