我正在尝试在{strong> Ubuntu 18.04 LTS 上安装crnn的软件。构建fblualib时发生错误(下面附有完整的构建打印):
[ 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>**
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
如果在thpp目录中运行THPP_NOFB=1 ./build.sh
而不使用fbthrift和folly来构建thpp,则构建将成功(我在torch / install / include和torch / install / lib中有thpp文件)。但是,如果我继续构建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>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
我认为TH++可能有问题。然后,我在目录“ thpp / if /”下尝试了以下命令。看来我的fbthrift无法生成cpp2格式的文件,但可以生成cpp / py文件,而我的python thrift_compiler只能生成错误的cpp2格式的文件。
$ 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
('参数错误:',ArgumentError('未定义语言py。',))
顺便说一句,我的fbthrift安装似乎成功,除了未正确安装python软件包thrift_compiler之外。我关注了fbthrift。这似乎可行(我现在可以在python中导入thrift_compiler,下面是我所做的),但是如您所见,它实际上并没有工作。
1。通过插入以下行来修改/thrift/compiler/CMakefile.txt
set(CMAKE_CXX_FLAGS“ -fPIC”) 设置(CMAKE_C_FLAGS“ -fPIC”)
2.rebuild / reinstall fbthrift(必须执行步骤)
3。在/ fbthrift / thrift / compiler / py下运行命令
g ++ -I /usr/include/python2.7 -I ../../。-std = c ++ 14 -fpic -shared -o frontend.so编译器.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
任何想法/建议都将不胜感激。
=================
thpp 版本的完整消息:
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
fblualib 构建的完整消息:
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
答案 0 :(得分:1)
请改用thrift1
和mstch_cpp2
。这个对我有用!
请参见https://github.com/facebook/fbthrift/issues/271,并且$THRIFT_INCLUDE
在我的系统中是/usr/local/include/thrift/
。
答案 1 :(得分:0)
您现在解决问题了吗?
$ 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/下载/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 cpp Tensor.thrift && ls gen-cpp
您真的拥有以下文件:Tensor_constants.cpp Tensor_constants.h Tensor_types.cpp Tensor_types.h
答案 2 :(得分:0)
作为上述答案之一,在成功构建fbthrift之后,您会在构建文件夹中获得bin/thrift1
二进制文件。然后,您可以将输出thrift1
与生成器mstch_cpp2
一起使用。
./build/bin/thrift1 --gen mstch_cpp2 --templates ./thrift/compiler/generate/templates --out /tmp/ ./thrift/example/if/chatroom.thrift