caffe icon indicating copy to clipboard operation
caffe copied to clipboard

Add cmake flags to avoid library path conflicts

Open futurely opened this issue 11 years ago • 19 comments

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

futurely avatar Jan 22 '15 14:01 futurely

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_PATH

The 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.

shelhamer avatar Jan 22 '15 16:01 shelhamer

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 avatar Jan 23 '15 02:01 futurely

@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 avatar Jun 25 '15 08:06 cuongduc

@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 avatar Jun 26 '15 02:06 futurely

@futurely I have done that, but the error still happened. Do I need to recompile Caffe again?

cuongduc avatar Jun 26 '15 07:06 cuongduc

Just do it.

futurely avatar Jun 26 '15 08:06 futurely

@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

cuongduc avatar Jun 27 '15 11:06 cuongduc

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'). "

xjpvincent avatar Jul 01 '15 15:07 xjpvincent

The error means that there're at least two gflags installed. Have you tried to delete one of them?

futurely avatar Jul 02 '15 03:07 futurely

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.

cuongduc avatar Jul 02 '15 08:07 cuongduc

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. “”

xjpvincent avatar Jul 02 '15 15:07 xjpvincent

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).

cuongduc avatar Jul 03 '15 01:07 cuongduc

If you can re-install the OS, RHEL 6 is OK and Ubuntu server might be better.

futurely avatar Jul 03 '15 02:07 futurely

@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 avatar Jul 24 '15 05:07 wanji

@wanji Thank you, wanji. That's really helpful. Besides,using the old version of gflags also can fix this problem.

xjpvincent avatar Jul 24 '15 05:07 xjpvincent

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.

yuxiang-wu avatar Oct 03 '15 09:10 yuxiang-wu

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

xjpvincent avatar Oct 07 '15 03:10 xjpvincent

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)

vikkamath avatar Oct 22 '15 13:10 vikkamath