fbthrift: cannot import name frontend

When I was compiling th++ after installing folly and fbthrift, I encountered an error

[  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
/usr/bin/python: cannot import name frontend
CMakeFiles/thpp.dir/build.make:61: recipe for target 'thpp/if/gen-cpp2/Tensor_data.h' failed
make[2]: *** [thpp/if/gen-cpp2/Tensor_data.h] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/thpp.dir/all' failed
make[1]: *** [CMakeFiles/thpp.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2

I checked frontend.so under fbthrift, but I could find it. My question is How should I do to generate frontend.so? Many thanks in advance.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 18 (1 by maintainers)

Most upvoted comments

@engahmed1190 , I solved your problem, here is my operation. 1.modify CMakefile.txt 2.rebuild/reinstall fbthrift(must step) 3.run you command under /fbthrift/thrift/compiler/py

g++ -I /usr/include/python2.7 -I /tmp/fblualib-build.FSDy82/fbthrift -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

after this, you get your frontend.so successfully.

i have faced same problem on ubuntu16.04, and i solve it from related information. frontend.so can copile by script “g++ -I /usr/include/python2.7 -I ./fbthrift -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” . then faced another problem “relocation R_X86_64_32 against”, fix CMakefile.txt add “set(CMAKE_CXX_FLAGS “-fPIC”) set(CMAKE_C_FLAGS “-fPIC”)”, will be successed. good luck for you.

I just want to say FUCK! waste me lots of time

i have run this command under /fbthrift/thrift/compiler/py
g++ -I /usr/include/python2.7 -I /tmp/fblualib-build.FSDy82/fbthrift -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

and added at the beginning of CMakefile.txt


# Set the compiler directory
set(COMPILER_DIR ${CMAKE_CURRENT_SOURCE_DIR})

# Override default install path for `make install` step
set(CMAKE_INSTALL_PREFIX ${THRIFT_HOME})
set(CMAKE_CXX_FLAGS "-fPIC")
set(CMAKE_C_FLAGS "-fPIC")
# Compile Flex and Bison files and tie their dependencies 

still the same error

`

/usr/bin/ld: //usr/local/lib/libcompiler_base.a(common.cc.o): relocation R_X86_64_32 against `.rodata’ can not be used when making a shared object; recompile with -fPIC

`