Closed SefaZeng closed 2 years ago
@SefaZeng Could you please check the tested build configurations where it is recommended to use Python version 3.7-3.9
for TF v2.7.0
? Please let us know if it helps?Thank you!
@SefaZeng Could you please check the tested build configurations where it is recommended to use Python version
3.7-3.9
for TF v2.7.0
? Please let us know if it helps?Thank you!
Thank you for your reply. I just found updating the gcc version solved this problem.
BTW, is there a example for how to use the shared library to inference the tflite model in c++? I found the example for static library but not for shared library.
Thx in advance!
After update the gcc version, I can successfully build the libtensorflowlite.so with the changes mentioned in #52113 . I also want to build the select ops for my model. I change the tensorflow/lite/BUILD with dependency like this:
tflite_cc_shared_object(
name = "tensorflowlite",
# Until we have more granular symbol export for the C++ API on Windows,
# export all symbols.
features = ["windows_export_all_symbols"],
linkopts = select({
"//tensorflow:macos": [
"-Wl,-exported_symbols_list,$(location //tensorflow/lite:tflite_exported_symbols.lds)",
],
"//tensorflow:windows": [],
"//conditions:default": [
"-Wl,-z,defs",
"-Wl,--version-script,$(location //tensorflow/lite:tflite_version_script.lds)",
],
}),
per_os_targets = True,
deps = [
":framework",
":tflite_exported_symbols.lds",
":tflite_version_script.lds",
#"//tensorflow/lite/kernels:builtin_ops_all_linked",
"//tensorflow/lite/kernels:builtin_ops",
"//tensorflow/lite/delegates/flex:delegate"
],
)
And the build command is:
bazel build -c opt --cxxopt=--std=c++14 --config=monolithic //tensorflow/lite:libtensorflowlite.so
But when I try to use this shared library libtensorflowlite.so, it raise errors like this:
[ 50%] Building CXX object CMakeFiles/nmt.dir/nmt.cpp.o
[100%] Linking CXX executable nmt
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::find(char const*, unsigned long) const@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `VTT for std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::rfind(char const*, unsigned long, unsigned long) const@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::logic_error::logic_error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::thread::_State::~_State()@GLIBCXX_3.4.22'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `__cxa_init_primary_exception@CXXABI_1.3.11'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::logic_error::logic_error(std::logic_error const&)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::reserve(unsigned long)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::find_last_of(char const*, unsigned long, unsigned long) const@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::range_error::range_error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::length_error::length_error(char const*)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::find_first_of(char const*, unsigned long) const@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::out_of_range::out_of_range(char const*)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::resize(unsigned long, char)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `vtable for std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_erase(unsigned long, unsigned long)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::logic_error::logic_error(char const*)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::overflow_error::overflow_error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::find_first_not_of(char const*, unsigned long, unsigned long) const@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::_V2::error_category::default_error_condition(int) const@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy_chars(char*, char const*, char const*)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::_V2::error_category::equivalent(std::error_code const&, int) const@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::invalid_argument::invalid_argument(char const*)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::resize(unsigned long, wchar_t)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)@GLIBCXX_3.4.20'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::out_of_range::out_of_range(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >::basic_stringstream(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::_Ios_Openmode)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::push_back(char)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::_V2::error_category::equivalent(int, std::error_condition const&) const@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::find_last_not_of(char, unsigned long) const@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `typeinfo for std::thread::_State@GLIBCXX_3.4.22'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::find(char, unsigned long) const@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >::~basic_stringstream()@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::runtime_error::runtime_error(char const*)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct(unsigned long, char)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::_V2::error_category::~error_category()@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())@GLIBCXX_3.4.22'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::assign(char const*)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::logic_error::logic_error(std::logic_error const&)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `__cxa_throw_bad_array_new_length@CXXABI_1.3.8'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::runtime_error::runtime_error(std::runtime_error const&)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `vtable for std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__atomic_futex_unsigned_base::_M_futex_notify_all(unsigned int*)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::overflow_error::overflow_error(char const*)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `vtable for std::__cxx11::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::compare(unsigned long, unsigned long, char const*, unsigned long) const@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::compare(unsigned long, unsigned long, char const*) const@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::range_error::range_error(char const*)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::runtime_error::runtime_error(std::runtime_error const&)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::domain_error::domain_error(char const*)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::length_error::length_error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace_aux(unsigned long, unsigned long, unsigned long, char)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::basic_istream<char, std::char_traits<char> >& std::getline<char, std::char_traits<char>, std::allocator<char> >(std::basic_istream<char, std::char_traits<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, char)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::append(char const*)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `typeinfo for std::_V2::error_category@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::_M_sync(char*, unsigned long, unsigned long)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `operator delete[](void*, unsigned long)@CXXABI_1.3.9'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::basic_istream<char, std::char_traits<char> >& std::operator>><char, std::char_traits<char>, std::allocator<char> >(std::basic_istream<char, std::char_traits<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::~basic_ostringstream()@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `vtable for std::__cxx11::basic_istringstream<char, std::char_traits<char>, std::allocator<char> >@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::compare(char const*) const@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::str() const@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::swap(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::domain_error::domain_error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::find_first_of(char const*, unsigned long, unsigned long) const@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `VTT for std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_istringstream<char, std::char_traits<char>, std::allocator<char> >::~basic_istringstream()@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::random_device::_M_init(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `VTT for std::__cxx11::basic_istringstream<char, std::char_traits<char>, std::allocator<char> >@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >::basic_stringstream()@GLIBCXX_3.4.26'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator=(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_mutate(unsigned long, unsigned long, char const*, unsigned long)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::logic_error::logic_error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__atomic_futex_unsigned_base::_M_futex_wait_until(unsigned int*, unsigned int, bool, std::chrono::duration<long, std::ratio<1l, 1l> >, std::chrono::duration<long, std::ratio<1l, 1000000000l> >)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::underflow_error::underflow_error(char const*)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::rfind(char const*, unsigned long) const@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `operator delete(void*, unsigned long)@CXXABI_1.3.9'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::_V2::system_category()@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace(unsigned long, unsigned long, char const*, unsigned long)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::_V2::error_category::_M_message[abi:cxx11](int) const@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::compare(unsigned long, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::underflow_error::underflow_error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::invalid_argument::invalid_argument(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::find(char const*, unsigned long, unsigned long) const@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `typeinfo for std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::runtime_error::runtime_error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_dispose()@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__exception_ptr::exception_ptr::exception_ptr(void*)@CXXABI_1.3.11'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::_V2::generic_category()@GLIBCXX_3.4.21'
/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::rfind(char, unsigned long) const@GLIBCXX_3.4.21'
collect2: error: ld returned 1 exit status
make[2]: *** [nmt] Error 1
make[1]: *** [CMakeFiles/nmt.dir/all] Error 2
make: *** [all] Error 2
And the CMakeLists.txt is:
cmake_minimum_required(VERSION 3.16)
project(nmt C CXX)
ADD_LIBRARY(tensorflowlite SHARED IMPORTED)
set_property(TARGET tensorflowlite PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/lib/libtensorflowlite.so)
INCLUDE_DIRECTORIES("/data/nmt3/tensorflow_src_2/tensorflow/lite")
INCLUDE_DIRECTORIES("/data/nmt3/tensorflow_src_2/tensorflow")
INCLUDE_DIRECTORIES("/data/nmt3/temp/external")
INCLUDE_DIRECTORIES("/data/nmt3/tensorflow_src_2")
INCLUDE_DIRECTORIES("/data/nmt3/tensorflow_src_2/bazel-bin")
INCLUDE_DIRECTORIES("/data/nmt3/tensorflow_src_2/bazel-out")
INCLUDE_DIRECTORIES("/data/nmt3/tensorflow_src_2/bazel-tensorflow_src_2")
INCLUDE_DIRECTORIES("/data/nmt3/flatbuffers/include")
INCLUDE_DIRECTORIES("/data/nmt3/temp")
INCLUDE_DIRECTORIES("/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite")
link_directories("/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite")
SET(CMAKE_CXX_FLAGS "-std=c++11 -O3")
add_executable(nmt nmt.cpp)
target_link_libraries(nmt libtensorflowlite.so)
I can't find anything useful about this error. Any helps?
After update the gcc version, I can successfully build the libtensorflowlite.so with the changes mentioned in #52113 . I also want to build the select ops for my model. I change the tensorflow/lite/BUILD with dependency like this:
tflite_cc_shared_object( name = "tensorflowlite", # Until we have more granular symbol export for the C++ API on Windows, # export all symbols. features = ["windows_export_all_symbols"], linkopts = select({ "//tensorflow:macos": [ "-Wl,-exported_symbols_list,$(location //tensorflow/lite:tflite_exported_symbols.lds)", ], "//tensorflow:windows": [], "//conditions:default": [ "-Wl,-z,defs", "-Wl,--version-script,$(location //tensorflow/lite:tflite_version_script.lds)", ], }), per_os_targets = True, deps = [ ":framework", ":tflite_exported_symbols.lds", ":tflite_version_script.lds", #"//tensorflow/lite/kernels:builtin_ops_all_linked", "//tensorflow/lite/kernels:builtin_ops", "//tensorflow/lite/delegates/flex:delegate" ], )
And the build command is:
bazel build -c opt --cxxopt=--std=c++14 --config=monolithic //tensorflow/lite:libtensorflowlite.so
But when I try to use this shared library libtensorflowlite.so, it raise errors like this:[ 50%] Building CXX object CMakeFiles/nmt.dir/nmt.cpp.o [100%] Linking CXX executable nmt /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::find(char const*, unsigned long) const@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `VTT for std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::rfind(char const*, unsigned long, unsigned long) const@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::logic_error::logic_error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::thread::_State::~_State()@GLIBCXX_3.4.22' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `__cxa_init_primary_exception@CXXABI_1.3.11' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::logic_error::logic_error(std::logic_error const&)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::reserve(unsigned long)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::find_last_of(char const*, unsigned long, unsigned long) const@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::range_error::range_error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::length_error::length_error(char const*)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::find_first_of(char const*, unsigned long) const@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::out_of_range::out_of_range(char const*)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::resize(unsigned long, char)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `vtable for std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_erase(unsigned long, unsigned long)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::logic_error::logic_error(char const*)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::overflow_error::overflow_error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::find_first_not_of(char const*, unsigned long, unsigned long) const@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::_V2::error_category::default_error_condition(int) const@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy_chars(char*, char const*, char const*)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::_V2::error_category::equivalent(std::error_code const&, int) const@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::invalid_argument::invalid_argument(char const*)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::resize(unsigned long, wchar_t)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)@GLIBCXX_3.4.20' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::out_of_range::out_of_range(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >::basic_stringstream(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::_Ios_Openmode)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::push_back(char)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::_V2::error_category::equivalent(int, std::error_condition const&) const@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::find_last_not_of(char, unsigned long) const@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `typeinfo for std::thread::_State@GLIBCXX_3.4.22' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::find(char, unsigned long) const@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >::~basic_stringstream()@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::runtime_error::runtime_error(char const*)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct(unsigned long, char)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::_V2::error_category::~error_category()@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())@GLIBCXX_3.4.22' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::assign(char const*)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::logic_error::logic_error(std::logic_error const&)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `__cxa_throw_bad_array_new_length@CXXABI_1.3.8' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::runtime_error::runtime_error(std::runtime_error const&)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `vtable for std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__atomic_futex_unsigned_base::_M_futex_notify_all(unsigned int*)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::overflow_error::overflow_error(char const*)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `vtable for std::__cxx11::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::compare(unsigned long, unsigned long, char const*, unsigned long) const@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::compare(unsigned long, unsigned long, char const*) const@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::range_error::range_error(char const*)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::runtime_error::runtime_error(std::runtime_error const&)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::domain_error::domain_error(char const*)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::length_error::length_error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace_aux(unsigned long, unsigned long, unsigned long, char)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::basic_istream<char, std::char_traits<char> >& std::getline<char, std::char_traits<char>, std::allocator<char> >(std::basic_istream<char, std::char_traits<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, char)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::append(char const*)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `typeinfo for std::_V2::error_category@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::_M_sync(char*, unsigned long, unsigned long)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `operator delete[](void*, unsigned long)@CXXABI_1.3.9' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::basic_istream<char, std::char_traits<char> >& std::operator>><char, std::char_traits<char>, std::allocator<char> >(std::basic_istream<char, std::char_traits<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::~basic_ostringstream()@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `vtable for std::__cxx11::basic_istringstream<char, std::char_traits<char>, std::allocator<char> >@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::compare(char const*) const@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::str() const@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::swap(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::domain_error::domain_error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::find_first_of(char const*, unsigned long, unsigned long) const@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `VTT for std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_istringstream<char, std::char_traits<char>, std::allocator<char> >::~basic_istringstream()@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::random_device::_M_init(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `VTT for std::__cxx11::basic_istringstream<char, std::char_traits<char>, std::allocator<char> >@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >::basic_stringstream()@GLIBCXX_3.4.26' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator=(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_mutate(unsigned long, unsigned long, char const*, unsigned long)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::logic_error::logic_error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__atomic_futex_unsigned_base::_M_futex_wait_until(unsigned int*, unsigned int, bool, std::chrono::duration<long, std::ratio<1l, 1l> >, std::chrono::duration<long, std::ratio<1l, 1000000000l> >)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::underflow_error::underflow_error(char const*)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::rfind(char const*, unsigned long) const@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `operator delete(void*, unsigned long)@CXXABI_1.3.9' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::_V2::system_category()@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace(unsigned long, unsigned long, char const*, unsigned long)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::_V2::error_category::_M_message[abi:cxx11](int) const@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::compare(unsigned long, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::underflow_error::underflow_error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::invalid_argument::invalid_argument(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::find(char const*, unsigned long, unsigned long) const@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `typeinfo for std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::runtime_error::runtime_error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_dispose()@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__exception_ptr::exception_ptr::exception_ptr(void*)@CXXABI_1.3.11' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::_V2::generic_category()@GLIBCXX_3.4.21' /data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite/libtensorflowlite.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::rfind(char, unsigned long) const@GLIBCXX_3.4.21' collect2: error: ld returned 1 exit status make[2]: *** [nmt] Error 1 make[1]: *** [CMakeFiles/nmt.dir/all] Error 2 make: *** [all] Error 2
And the CMakeLists.txt is:
cmake_minimum_required(VERSION 3.16) project(nmt C CXX) ADD_LIBRARY(tensorflowlite SHARED IMPORTED) set_property(TARGET tensorflowlite PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/lib/libtensorflowlite.so) INCLUDE_DIRECTORIES("/data/nmt3/tensorflow_src_2/tensorflow/lite") INCLUDE_DIRECTORIES("/data/nmt3/tensorflow_src_2/tensorflow") INCLUDE_DIRECTORIES("/data/nmt3/temp/external") INCLUDE_DIRECTORIES("/data/nmt3/tensorflow_src_2") INCLUDE_DIRECTORIES("/data/nmt3/tensorflow_src_2/bazel-bin") INCLUDE_DIRECTORIES("/data/nmt3/tensorflow_src_2/bazel-out") INCLUDE_DIRECTORIES("/data/nmt3/tensorflow_src_2/bazel-tensorflow_src_2") INCLUDE_DIRECTORIES("/data/nmt3/flatbuffers/include") INCLUDE_DIRECTORIES("/data/nmt3/temp") INCLUDE_DIRECTORIES("/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite") link_directories("/data/nmt3/tensorflow_src_2/bazel-bin/tensorflow/lite") SET(CMAKE_CXX_FLAGS "-std=c++11 -O3") add_executable(nmt nmt.cpp) target_link_libraries(nmt libtensorflowlite.so)
I can't find anything useful about this error. Any helps?
This is mainly caused by the confusion of my local GCC environment, which has multiple versions of GCC. Now I can run the demo codes, but all the returned result is 0. Still debugging.
Please make sure that this is a bug. As per our GitHub Policy, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:bug_template
System information
Describe the current behavior I followed the example here https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/g3doc/guide/reduce_binary_size.md to build a tflite library with selected tf ops. The BUILD file is:
Here is the build command:
And here is the full log:
Describe the expected behavior
Contributing
Standalone code to reproduce the issue Provide a reproducible test case that is the bare minimum necessary to generate the problem. If possible, please share a link to Colab/Jupyter/any notebook.
Other info / logs Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.