Reputation: 1
I'm trying to install crnn which requires fblualib on Ubuntu 18.04 LTS. While building TH++, an error occured (Complete build print attached below):
[ 10%] Building CXX object CMakeFiles/thpp.dir/Storage.cpp.o
In file included from /home/huiji/Downloads/thpp-master/thpp/Storage.cpp:11:0:
/home/huiji/Downloads/thpp-master/thpp/../thpp/Storage.h:22:10: fatal error: thpp/if/gen-cpp2/Tensor_types.h: no such file or directory
#include **<thpp/if/gen-cpp2/Tensor_types.h>**
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If I build thpp without using fbthrift and folly by running THPP_NOFB=1 ./build.sh
in the thpp directory, the build would be successful (I have thpp files in torch/install/include and torch/install/lib). However, if I move on and build fblualib, an almost identical error occurs:
[ 20%] Building CXX object CMakeFiles/fblualib.dir/LuaUtils.cpp.o
In file included from
/home/huiji/torch/install/include/thpp/Tensor.h:20:0,
from /home/huiji/Downloads/fblualib-master/fblualib/../fblualib/LuaUtils.h:19,
from /home/huiji/Downloads/fblualib- master/fblualib/LuaUtils.cpp:11:
/home/huiji/torch/install/include/thpp/Storage.h:22:10: fatal error:
thpp/if/gen-cpp2/Tensor_types.h: no such file or directory
#include <thpp/if/gen-cpp2/Tensor_types.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I figure that there may be something wrong with my fbthrift. Then I tried the following commands under directory "thpp/if/". It seems that my fbthrift can't generate a cpp2-format file, but can generate a cpp/py file, awhile my python thrift_compiler can only generate an errored cpp2-format file.
$ thrift --gen cpp2 Tensor.thrift
[WARNING:/home/huiji/Downloads/thpp-master/thpp/if/Tensor.thrift:1] No generator named 'cpp2' could be found!
[WARNING:generation:1] Unable to get a generator for "cpp2".
# Nothing was generated in /thpp/if
$ thrift --gen cpp Tensor.thrift && ls gen-cpp
[WARNING:/home/huiji/Downloads/thpp-master/thpp/if/Tensor.thrift:3] No generator named 'cpp2' could be found!
Tensor_constants.cpp Tensor_constants.h Tensor_types.cpp Tensor_types.h
$ thrift --gen py Tensor.thrift && ls -R gen-py
[WARNING:/home/huiji/Downloads/thpp-master/thpp/if/Tensor.thrift:3] No generator named 'cpp2' could be found!
gen-py:
__init__.py Tensor
gen-py/Tensor:
constants.py __init__.py ttypes.py
$ python -m thrift_compiler.main --gen cpp2 Tensor.thrift && ls gen-cpp2
Tensor_fatal_all.h Tensor_fatal.h Tensor_fatal_types.h
Tensor_fatal_constant.h Tensor_fatal_service.h Tensor_fatal_union.h
Tensor_fatal_enum.h Tensor_fatal_struct.h
# A "gen-cpp2" directory was created, but in it there was no "Tensor_types.h"!
$ python -m thrift_compiler.main --gen cpp Tensor.thrift
('Argument Error:', ArgumentError('Language cpp not defined.',))
$ python -m thrift_compiler.main --gen py Tensor.thrift
('Argument Error:', ArgumentError('Language py not defined.',))
By the way, my fbthrift install seemed successful except the python package thrift_compiler was not installed correctly. I've followed GitHubGS's suggestion. That seem to have worked (I can now import thrift_compiler in python, below is what I did) but as you can see, it is not really working.
1.modify /thrift/compiler/CMakefile.txt by inserting these lines
set(CMAKE_CXX_FLAGS "-fPIC") set(CMAKE_C_FLAGS "-fPIC")
2.rebuild/reinstall fbthrift(must step)
3.run your command under /fbthrift/thrift/compiler/py
g++ -I /usr/include/python2.7 -I ../../.. -std=c++14 -fpic -shared -o frontend.so compiler.cc -lboost_python -lpython2.7 -L/build/lib -lcompiler_base -lcompiler_ast -lboost_system -lboost_filesystem -lssl -lcrypto
sudo cp frontend.so /usr/local/lib/python2.7/dist-packages/thrift_py-0.9.0-py2.7.egg/thrift_compiler
Any ideas/suggestions would be greatly appreciated.
=================
Complete message of thpp build:
huiji@NoBoDy:~/Downloads/thpp-master/thpp$ ./build.sh If you don't have folly or thrift installed, try doing THPP_NOFB=1 ./build.sh -- The C compiler identification is GNU 7.3.0 -- The CXX compiler identification is GNU 7.3.0 -- Check for working C compiler: /usr/local/bin/gcc -- Check for working C compiler: /usr/local/bin/gcc -- 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/local/bin/g++ -- Check for working CXX compiler: /usr/local/bin/g++ -- 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/huiji/torch/install -- Found Folly: /usr/local/include -- Found Thrift: /usr/local/include -- Performing Test HAS_NO_AS_NEEDED -- Performing Test HAS_NO_AS_NEEDED - Success -- Found Glog: /usr/include -- Found PythonInterp: /usr/bin/python (found version "2.7.15") -- Looking for pthread.h -- Looking for pthread.h - found -- Looking for pthread_create -- Looking for pthread_create - not found -- Looking for pthread_create in pthreads -- Looking for pthread_create in pthreads - not found -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - found -- Found Threads: TRUE -- Configuring done -- Generating done -- Build files have been written to: /home/huiji/Downloads/thpp-master/thpp/build [ 5%] Generating thpp/if/gen-cpp2/Tensor_data.h, thpp/if/gen-cpp2/Tensor_types.h, thpp/if/gen-cpp2/Tensor_types.tcc, thpp/if/gen-cpp2/Tensor_constants.h, thpp/if/gen-cpp2/Tensor_data.cpp, thpp/if/gen-cpp2/Tensor_types.cpp, thpp/if/gen-cpp2/Tensor_constants.cpp Scanning dependencies of target thpp [ 10%] Building CXX object CMakeFiles/thpp.dir/Storage.cpp.o In file included from /home/huiji/Downloads/thpp-master/thpp/Storage.cpp:11:0: /home/huiji/Downloads/thpp-master/thpp/../thpp/Storage.h:22:10: fatal error: thpp/if/gen-cpp2/Tensor_types.h: no such file or directory #include <thpp/if/gen-cpp2/Tensor_types.h> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated. CMakeFiles/thpp.dir/build.make:84: recipe for target 'CMakeFiles/thpp.dir/Storage.cpp.o' failed make[2]: *** [CMakeFiles/thpp.dir/Storage.cpp.o] Error 1 CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/thpp.dir/all' failed make[1]: *** [CMakeFiles/thpp.dir/all] Error 2 Makefile:140: recipe for target 'all' failed make: *** [all] Error 2
Complete message of fblualib build:
huiji@NoBoDy:~/Downloads/fblualib-master/fblualib$ ./build.sh -- The C compiler identification is GNU 7.3.0 -- The CXX compiler identification is GNU 7.3.0 -- Check for working C compiler: /usr/local/bin/gcc -- Check for working C compiler: /usr/local/bin/gcc -- 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/local/bin/g++ -- Check for working CXX compiler: /usr/local/bin/g++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found Folly: /usr/local/include -- Found Glog: /usr/include -- Found Torch7 in /home/huiji/torch/install -- Found Folly: /home/huiji/torch/install/include -- Configuring done WARNING: Target "fblualib" requests linking to directory "/home/huiji/torch/install/lib". Targets may link only to libraries. CMake is dropping the item. -- Generating done -- Build files have been written to: /home/huiji/Downloads/fblualib-master/fblualib/build Scanning dependencies of target fblualib [ 20%] Building CXX object CMakeFiles/fblualib.dir/LuaUtils.cpp.o In file included from /home/huiji/torch/install/include/thpp/Tensor.h:20:0, from /home/huiji/Downloads/fblualib-master/fblualib/../fblualib/LuaUtils.h:19, from /home/huiji/Downloads/fblualib-master/fblualib/LuaUtils.cpp:11: /home/huiji/torch/install/include/thpp/Storage.h:22:10: fatal error: thpp/if/gen-cpp2/Tensor_types.h: no such file or directory #include <thpp/if/gen-cpp2/Tensor_types.h> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated. CMakeFiles/fblualib.dir/build.make:62: recipe for target 'CMakeFiles/fblualib.dir/LuaUtils.cpp.o' failed make[2]: *** [CMakeFiles/fblualib.dir/LuaUtils.cpp.o] Error 1 CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/fblualib.dir/all' failed make[1]: *** [CMakeFiles/fblualib.dir/all] Error 2 Makefile:129: recipe for target 'all' failed make: *** [all] Error 2
Upvotes: 0
Views: 1407
Reputation: 198
As one of the above answer mentioned, after building fbthrift successfully, you get bin/thrift1
binary in your build folder. You can then use the output thrift1
with generator mstch_cpp2
.
./build/bin/thrift1 --gen mstch_cpp2 --templates ./thrift/compiler/generate/templates --out /tmp/ ./thrift/example/if/chatroom.thrift
Ref https://github.com/facebook/fbthrift/issues/303
Upvotes: 0
Reputation: 21
Use thrift1
and mstch_cpp2
instead. It works for me!
See https://github.com/facebook/fbthrift/issues/271 and $THRIFT_INCLUDE
is /usr/local/include/thrift/
in my system.
Upvotes: 2