When I try to run the following shell script at (https://github.com/renmengye/rec-attend-public):
TF_INC=$(python -c 'import tensorflow as tf; print(tf.sysconfig.get_include())')
g++ -std=c++11 -stdlib=libc++ -shared hungarian.cc -o hungarian.so -fPIC -I $TF_INC -D_GLIBCXX_USE_CXX11_ABI=0
I get the following errors:
11 warnings generated.
Undefined symbols for architecture x86_64:
"tensorflow::DEVICE_CPU", referenced from:
___cxx_global_var_init.7 in hungarian-8050bd.o
"tensorflow::TensorShape::DestructorOutOfLine()", referenced from:
tensorflow::TensorShape::~TensorShape() in hungarian-8050bd.o
"tensorflow::TensorShape::AddDim(long long)", referenced from:
HungarianOp::Compute(tensorflow::OpKernelContext*) in hungarian-8050bd.o
"tensorflow::TensorShape::TensorShape()", referenced from:
HungarianOp::Compute(tensorflow::OpKernelContext*) in hungarian-8050bd.o
"tensorflow::register_op::OpDefBuilderReceiver::OpDefBuilderReceiver(tensorflow::register_op::OpDefBuilderWrapper<true> const&)", referenced from:
___cxx_global_var_init in hungarian-8050bd.o
"tensorflow::OpDefBuilder::Input(tensorflow::StringPiece)", referenced from:
tensorflow::register_op::OpDefBuilderWrapper<true>::Input(tensorflow::StringPiece) in hungarian-8050bd.o
"tensorflow::OpDefBuilder::Output(tensorflow::StringPiece)", referenced from:
tensorflow::register_op::OpDefBuilderWrapper<true>::Output(tensorflow::StringPiece) in hungarian-8050bd.o
"tensorflow::OpDefBuilder::OpDefBuilder(tensorflow::StringPiece)", referenced from:
tensorflow::register_op::OpDefBuilderWrapper<true>::OpDefBuilderWrapper(char const*) in hungarian-8050bd.o
"tensorflow::kernel_factory::OpKernelRegistrar::InitInternal(tensorflow::KernelDef const*, tensorflow::StringPiece, tensorflow::OpKernel* (*)(tensorflow::OpKernelConstruction*))", referenced from:
tensorflow::kernel_factory::OpKernelRegistrar::OpKernelRegistrar(tensorflow::KernelDef const*, tensorflow::StringPiece, tensorflow::OpKernel* (*)(tensorflow::OpKernelConstruction*)) in hungarian-8050bd.o
"tensorflow::OpKernelContext::allocate_output(int, tensorflow::TensorShape const&, tensorflow::Tensor**)", referenced from:
HungarianOp::Compute(tensorflow::OpKernelContext*) in hungarian-8050bd.o
"tensorflow::OpKernelContext::CtxFailureWithWarning(tensorflow::Status)", referenced from:
HungarianOp::Compute(tensorflow::OpKernelContext*) in hungarian-8050bd.o
"tensorflow::OpKernelContext::input(int)", referenced from:
HungarianOp::Compute(tensorflow::OpKernelContext*) in hungarian-8050bd.o
"tensorflow::KernelDefBuilder::Device(char const*)", referenced from:
___cxx_global_var_init.7 in hungarian-8050bd.o
"tensorflow::KernelDefBuilder::KernelDefBuilder(char const*)", referenced from:
tensorflow::register_kernel::Name::Name(char const*) in hungarian-8050bd.o
"tensorflow::OpDef::~OpDef()", referenced from:
tensorflow::OpRegistrationData::~OpRegistrationData() in hungarian-8050bd.o
"tensorflow::OpKernel::OpKernel(tensorflow::OpKernelConstruction*)", referenced from:
HungarianOp::HungarianOp(tensorflow::OpKernelConstruction*) in hungarian-8050bd.o
"tensorflow::OpKernel::~OpKernel()", referenced from:
HungarianOp::~HungarianOp() in hungarian-8050bd.o
"tensorflow::internal::LogMessage::MinVLogLevel()", referenced from:
HungarianOp::MinWeightedBipartiteCover(Eigen::Matrix<float, -1, -1, 1, -1, -1> const&, Eigen::Matrix<float, -1, -1, 1, -1, -1>*, Eigen::Matrix<float, -1, -1, 1, -1, -1>*, Eigen::Matrix<float, -1, -1, 1, -1, -1>*) in hungarian-8050bd.o
HungarianOp::GetEqualityGraph(Eigen::Matrix<float, -1, -1, 1, -1, -1> const&, Eigen::Matrix<float, -1, -1, 1, -1, -1> const&, Eigen::Matrix<float, -1, -1, 1, -1, -1> const&) in hungarian-8050bd.o
HungarianOp::MaxBipartiteMatching(Eigen::Matrix<float, -1, -1, 1, -1, -1> const&, Eigen::Matrix<float, -1, -1, 1, -1, -1>*) in hungarian-8050bd.o
HungarianOp::Augment(Eigen::Matrix<float, -1, -1, 1, -1, -1> const&, Eigen::Matrix<float, -1, -1, 1, -1, -1>&, Eigen::Matrix<float, -1, -1, 1, -1, -1>&) in hungarian-8050bd.o
"tensorflow::internal::LogMessage::LogMessage(char const*, int, int)", referenced from:
HungarianOp::MinWeightedBipartiteCover(Eigen::Matrix<float, -1, -1, 1, -1, -1> const&, Eigen::Matrix<float, -1, -1, 1, -1, -1>*, Eigen::Matrix<float, -1, -1, 1, -1, -1>*, Eigen::Matrix<float, -1, -1, 1, -1, -1>*) in hungarian-8050bd.o
HungarianOp::GetEqualityGraph(Eigen::Matrix<float, -1, -1, 1, -1, -1> const&, Eigen::Matrix<float, -1, -1, 1, -1, -1> const&, Eigen::Matrix<float, -1, -1, 1, -1, -1> const&) in hungarian-8050bd.o
HungarianOp::MaxBipartiteMatching(Eigen::Matrix<float, -1, -1, 1, -1, -1> const&, Eigen::Matrix<float, -1, -1, 1, -1, -1>*) in hungarian-8050bd.o
HungarianOp::Augment(Eigen::Matrix<float, -1, -1, 1, -1, -1> const&, Eigen::Matrix<float, -1, -1, 1, -1, -1>&, Eigen::Matrix<float, -1, -1, 1, -1, -1>&) in hungarian-8050bd.o
"tensorflow::internal::LogMessage::~LogMessage()", referenced from:
HungarianOp::MinWeightedBipartiteCover(Eigen::Matrix<float, -1, -1, 1, -1, -1> const&, Eigen::Matrix<float, -1, -1, 1, -1, -1>*, Eigen::Matrix<float, -1, -1, 1, -1, -1>*, Eigen::Matrix<float, -1, -1, 1, -1, -1>*) in hungarian-8050bd.o
HungarianOp::GetEqualityGraph(Eigen::Matrix<float, -1, -1, 1, -1, -1> const&, Eigen::Matrix<float, -1, -1, 1, -1, -1> const&, Eigen::Matrix<float, -1, -1, 1, -1, -1> const&) in hungarian-8050bd.o
HungarianOp::MaxBipartiteMatching(Eigen::Matrix<float, -1, -1, 1, -1, -1> const&, Eigen::Matrix<float, -1, -1, 1, -1, -1>*) in hungarian-8050bd.o
HungarianOp::Augment(Eigen::Matrix<float, -1, -1, 1, -1, -1> const&, Eigen::Matrix<float, -1, -1, 1, -1, -1>&, Eigen::Matrix<float, -1, -1, 1, -1, -1>&) in hungarian-8050bd.o
"tensorflow::internal::LogMessageFatal::LogMessageFatal(char const*, int)", referenced from:
tensorflow::core::RefCounted::~RefCounted() in hungarian-8050bd.o
HungarianOp::Compute(tensorflow::OpKernelContext*) in hungarian-8050bd.o
tensorflow::TensorShape::dims() const in hungarian-8050bd.o
HungarianOp::MinWeightedBipartiteCover(Eigen::Matrix<float, -1, -1, 1, -1, -1> const&, Eigen::Matrix<float, -1, -1, 1, -1, -1>*, Eigen::Matrix<float, -1, -1, 1, -1, -1>*, Eigen::Matrix<float, -1, -1, 1, -1, -1>*) in hungarian-8050bd.o
HungarianOp::MaxFlow(Eigen::Matrix<float, -1, -1, 1, -1, -1> const&) in hungarian-8050bd.o
HungarianOp::Augment(Eigen::Matrix<float, -1, -1, 1, -1, -1> const&, Eigen::Matrix<float, -1, -1, 1, -1, -1>&, Eigen::Matrix<float, -1, -1, 1, -1, -1>&) in hungarian-8050bd.o
tensorflow::KernelDefBuilder::~KernelDefBuilder() in hungarian-8050bd.o
...
"tensorflow::internal::LogMessageFatal::~LogMessageFatal()", referenced from:
tensorflow::core::RefCounted::~RefCounted() in hungarian-8050bd.o
HungarianOp::Compute(tensorflow::OpKernelContext*) in hungarian-8050bd.o
tensorflow::TensorShape::dims() const in hungarian-8050bd.o
HungarianOp::MinWeightedBipartiteCover(Eigen::Matrix<float, -1, -1, 1, -1, -1> const&, Eigen::Matrix<float, -1, -1, 1, -1, -1>*, Eigen::Matrix<float, -1, -1, 1, -1, -1>*, Eigen::Matrix<float, -1, -1, 1, -1, -1>*) in hungarian-8050bd.o
HungarianOp::MaxFlow(Eigen::Matrix<float, -1, -1, 1, -1, -1> const&) in hungarian-8050bd.o
HungarianOp::Augment(Eigen::Matrix<float, -1, -1, 1, -1, -1> const&, Eigen::Matrix<float, -1, -1, 1, -1, -1>&, Eigen::Matrix<float, -1, -1, 1, -1, -1>&) in hungarian-8050bd.o
tensorflow::KernelDefBuilder::~KernelDefBuilder() in hungarian-8050bd.o
...
"tensorflow::internal::CheckOpMessageBuilder::ForVar2()", referenced from:
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* tensorflow::internal::MakeCheckOpString<int, int>(int const&, int const&, char const*) in hungarian-8050bd.o
"tensorflow::internal::CheckOpMessageBuilder::NewString()", referenced from:
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* tensorflow::internal::MakeCheckOpString<int, int>(int const&, int const&, char const*) in hungarian-8050bd.o
"tensorflow::internal::CheckOpMessageBuilder::CheckOpMessageBuilder(char const*)", referenced from:
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* tensorflow::internal::MakeCheckOpString<int, int>(int const&, int const&, char const*) in hungarian-8050bd.o
"tensorflow::internal::CheckOpMessageBuilder::~CheckOpMessageBuilder()", referenced from:
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >* tensorflow::internal::MakeCheckOpString<int, int>(int const&, int const&, char const*) in hungarian-8050bd.o
"tensorflow::TensorShape::CheckDimsEqual(int) const", referenced from:
Eigen::DSizes<long, 3> tensorflow::TensorShape::AsEigenDSizes<3>() const in hungarian-8050bd.o
Eigen::DSizes<long, 2> tensorflow::TensorShape::AsEigenDSizes<2>() const in hungarian-8050bd.o
"tensorflow::TensorShape::CheckDimsAtLeast(int) const", referenced from:
Eigen::DSizes<long, 3> tensorflow::TensorShape::AsEigenDSizesWithPadding<3>() const in hungarian-8050bd.o
Eigen::DSizes<long, 2> tensorflow::TensorShape::AsEigenDSizesWithPadding<2>() const in hungarian-8050bd.o
"tensorflow::TensorShape::dim_size(int) const", referenced from:
HungarianOp::Compute(tensorflow::OpKernelContext*) in hungarian-8050bd.o
HungarianOp::ComputeHungarianBatch(tensorflow::Tensor const&, tensorflow::Tensor*, tensorflow::Tensor*, tensorflow::Tensor*) in hungarian-8050bd.o
HungarianOp::ComputeHungarian(tensorflow::Tensor const&, tensorflow::Tensor*, tensorflow::Tensor*, tensorflow::Tensor*) in hungarian-8050bd.o
Eigen::DSizes<long, 3> tensorflow::TensorShape::AsEigenDSizesWithPadding<3>() const in hungarian-8050bd.o
HungarianOp::CopyInput(tensorflow::Tensor const&) in hungarian-8050bd.o
HungarianOp::CopyOutput(Eigen::Matrix<float, -1, -1, 1, -1, -1> const&, tensorflow::Tensor*) in hungarian-8050bd.o
Eigen::DSizes<long, 2> tensorflow::TensorShape::AsEigenDSizesWithPadding<2>() const in hungarian-8050bd.o
...
"tensorflow::Tensor::tensor_data() const", referenced from:
HungarianOp::CopyInput(tensorflow::Tensor const&) in hungarian-8050bd.o
"tensorflow::Tensor::CheckTypeAndIsAligned(tensorflow::DataType) const", referenced from:
tensorflow::TTypes<float, 3ul, long>::ConstTensor tensorflow::Tensor::tensor<float, 3ul>() const in hungarian-8050bd.o
tensorflow::TTypes<float, 3ul, long>::Tensor tensorflow::Tensor::tensor<float, 3ul>() in hungarian-8050bd.o
tensorflow::TTypes<float, 2ul, long>::Tensor tensorflow::Tensor::tensor<float, 2ul>() in hungarian-8050bd.o
"typeinfo for tensorflow::OpKernel", referenced from:
typeinfo for HungarianOp in hungarian-8050bd.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have looked into the following questions, nothing seems to work:
- When is it necessary to use use the flag -stdlib=libstdc++?
- https://mathematica.stackexchange.com/questions/34692/mathlink-linking-error-after-os-x-10-9-mavericks-upgrade
- C++ linking error after upgrading to Mac OS X 10.9 / Xcode 5.0.1
If I change it to libstdc++
:
TF_INC=$(python -c 'import tensorflow as tf; print(tf.sysconfig.get_include())')
g++ -std=c++11 -stdlib=libstdc++ -shared hungarian.cc -o hungarian.so -fPIC -I $TF_INC -D_GLIBCXX_USE_CXX11_ABI=0
I get the following error:
clang: warning: libstdc++ is deprecated; move to libc++ [-Wdeprecated]
In file included from hungarian.cc:15:
/Users/xyz/tensorflow012/lib/python2.7/site-packages/tensorflow/include/tensorflow/core/framework/op.h:20:10: fatal error: 'unordered_map' file not found
#include <unordered_map>
^
1 error generated.
Before downvoting/closing, please read the question in its entirety.