0

I am trying to install fbtorch on linux. However, when I try to run luarocks install fbtorch I get the following error.

cmake -E make_directory build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="/home/user/torch/install/bin/.." -DCMAKE_INSTALL_PREFIX="/home/user/torch/install/lib/luarocks/rocks/fbtorch/scm-1"

fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Torch7 in /home/user/torch/install
CMake Error at /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
  REQUIRED_ARGS (missing: FOLLY_INCLUDE_DIR FOLLY_LIBRARIES)
Call Stack (most recent call first):
  /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
  cmake/FindFolly.cmake:23 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:12 (FIND_PACKAGE)


-- Configuring incomplete, errors occurred!
See also "/tmp/luarocks_fbtorch-scm-1-4920/fbtorch/build/CMakeFiles/CMakeOutput.log".

Now, to fix the REQUIRED_ARGS (missing: FOLLY_INCLUDE_DIR FOLLY_LIBRARIES) I changed the cmake command to:

cmake -E make_directory build && cd build && cmake .. -DFOLLY_LIBRARIES="/home/user/local/lib" -DFOLLY_INCLUDE_DIR="/home/user/local/include" -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$(LUA_BINDIR)/.." -DCMAKE_INSTALL_PREFIX="$(PREFIX)"

Kindly note that I have compiles and installed folly at /home/user/local/ in appropriate directories

This fixed the FOLLY_INCLUDE_DIR error but its still showing error for FOLLY_LIBRARIES like so:

CMake Error at /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
  REQUIRED_ARGS (missing: FOLLY_LIBRARIES)
Call Stack (most recent call first):
  /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
  cmake/FindFolly.cmake:23 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:12 (FIND_PACKAGE)

What am I missing here? Why did the cmake recognize the cache entry for FOLLY_INCLUDE_DIR but not for FOLLY_LIBRARIES?

Ashutosh Baheti
  • 410
  • 4
  • 20

2 Answers2

1

Variables listed in "missed" list in find_package() call are not required to be CACHE ones. So, setting cache variable with the same name may do not resolve the problem.

If searched package is actually installed into non-standard location, instead of blindly setting "missing" variables it is better to hint the "Find" script about that location.

Many "Find" scripts describe possible ways of parametrization at the beginning of their code. Aside from this, there are common ways for hinting "Find" scripts about actual location of the package; these ways works for most of scripts. E.g. you may add install location of the package into CMAKE_PREFIX_PATH variable (See that question).

Tsyvarev
  • 60,011
  • 17
  • 110
  • 153
  • Thanks for the suggestion. Adding the installation path in CMAKE_PREFIX_PATH helped and now the installation proceeded but then I received another make error `/usr/bin/ld: cannot find -lfolly`. Do you have any suggestions to overcome this? – Ashutosh Baheti Nov 22 '17 at 15:38
  • 1
    @AshutoshBaheti This is a bug in their build script. They call `TARGET_LINK_LIBRARIES(fbtorch_ext folly)`, when really they should be doing `target_link_libraries(fbtorch_ext ${FOLLY_LIBRARIES})`. Those build scripts are quite a mess, I wouldn't rely on anything in there working properly if I were you. – ComicSansMS Nov 22 '17 at 16:25
  • I will try to manually change that cmakelist and see if it works. Thanks for the suggestion! – Ashutosh Baheti Nov 22 '17 at 16:26
  • @ComicSansMS I tried setting -DTorch_INSTALL_LIB="path to library" since they have `LINK_DIRECTORIES("${Torch_INSTALL_LIB}")` but that didn't work. Can you think of a possible reason why that didn't work? – Ashutosh Baheti Nov 22 '17 at 16:28
  • @ComicSansMS wow your suggestion of changing the `target_link_libraries(fbtorch_ext ${FOLLY_LIBRARIES})` worked! I forked the repo, made changes to it and installed it from the forked version. Thanks for the help! – Ashutosh Baheti Nov 22 '17 at 16:41
-1

If you look at FindFolly.cmake you can see the line -

SET(FOLLY_LIBRARIES ${FOLLY_LIBRARY})

This means that FOLLY_LIBRARIES is being set but it needs FOLLY_LIBRARY.

So in your command line change -DFOLLY_LIBRARIES to -DFOLLY_LIBRARY

Ajay Brahmakshatriya
  • 8,993
  • 3
  • 26
  • 49
  • -1, there is a `find_library` call for `FOLLY_LIBRARY` just above that `set` you mention. Granted, the script should provide a customization point for the folly directory there (through the `HINTS` or `PATHS` parameter of that find call), but bypassing the find call completely should only be used as a very last resort. – ComicSansMS Nov 22 '17 at 09:20
  • @ComicSansMS: "Technology" described in this answer is useful when someone just needs to "make things work". It could be really needed, if "Find" script is wrong (and, according to comments to my answer, the script is actually wrong). Also, such "hack" can be useful when layout of the installed package differs from one expecting by "Find" script. But I agree with your phrase `... should only be used as a very last resort.` – Tsyvarev Nov 22 '17 at 18:32