openvinotoolkit / openvino

OpenVINO™ is an open-source toolkit for optimizing and deploying AI inference
https://docs.openvino.ai
Apache License 2.0
6.79k stars 2.16k forks source link

openvino on macOS g++ undefined symbols x86_64 #1203

Closed navacar closed 4 years ago

navacar commented 4 years ago

I followed the instruction on your github https://github.com/openvinotoolkit/openvino to build it on macOS, done it and when i wrote a small code to check was all clear or not

#include <string>
#include <iostream>
#include <dlfcn.h>
#include <fstream>

#define USE_STATIC_IE

#define _CRT_SECURE_NO_WARNINGS

#include <ie_core.hpp>

using namespace :: std;

int main(){
    dlopen("/Users/nk/Documents/HZ/openvino/inference-engine/temp/tbb/lib/libtbb.dylib", RTLD_LAZY);
    dlopen("/Users/nk/Documents/HZ/openvino/bin/intel64/Release/lib/libngraph.dylib", RTLD_LAZY);
    dlopen("/Users/nk/Documents/HZ/openvino/bin/intel64/Release/lib/libinference_engine_transformations.dylib", RTLD_LAZY);
    dlopen("/Users/nk/Documents/HZ/openvino/bin/intel64/Release/lib/libinference_engine_legacy.dylib", RTLD_LAZY);
    dlopen("/Users/nk/Documents/HZ/openvino/bin/intel64/Release/lib/libinference_engine.dylib", RTLD_LAZY);
    dlopen("/Users/nk/Documents/HZ/openvino/bin/intel64/Release/lib/libinference_engine_lp_transformations.dylib", RTLD_LAZY);
    dlopen("/Users/nk/Documents/HZ/openvino/bin/intel64/Release/lib/libMKLDNNPlugin.dylib", RTLD_LAZY);

    const std::string pluginsFilePath = "/Users/nk/Documents/HZ/openvino/bin/intel64/Release/lib/plugins.xml";
    InferenceEngine::Core ie(pluginsFilePath);
    const auto info = ie.GetVersions("CPU");

    if(!info.empty())
        cout << "Yes";

    return 0;
}

when i compile it with command

g++ -std=c++11 -I/Users/nk/Documents/HZ/openvino/inference-engine/include testdll.cpp -o testdll && "/Users/nk/Documents/FelenaSoft/"testdll`

it gave me the error

Undefined symbols for architecture x86_64:
  "InferenceEngine::Core::Core(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      _main in testdll-788073.o
  "InferenceEngine::Core::GetVersions(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const", referenced from:
      _main in testdll-788073.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

then i added .a libs and ran this command

g++ -std=c++11 -L/Users/nk/Documents/HZ/openvino/bin/intel64/Release/lib -lmkldnn -lpugixml -linference_engine_s -I/Users/nk/Documents/HZ/openvino/inference-engine/include testdll.cpp -o testdll && "/Users/nk/Documents/FelenaSoft/"testdll 

and i got this

Undefined symbols for architecture x86_64:
  "ngraph::as_output_vector(std::__1::vector<std::__1::shared_ptr<ngraph::Node>, std::__1::allocator<std::__1::shared_ptr<ngraph::Node> > > const&)", referenced from:
      ngraph::Node::generate_adjoints(ngraph::autodiff::Adjoints&, std::__1::vector<std::__1::shared_ptr<ngraph::Node>, std::__1::allocator<std::__1::shared_ptr<ngraph::Node> > > const&) in libinference_engine_s.a(ie_rtti.cpp.o)
  "ngraph::Node::match_node(ngraph::pattern::Matcher*, ngraph::Output<ngraph::Node> const&)", referenced from:
      vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
  "ngraph::Node::match_value(ngraph::pattern::Matcher*, ngraph::Output<ngraph::Node> const&, ngraph::Output<ngraph::Node> const&)", referenced from:
      vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
  "ngraph::Node::constant_fold(std::__1::vector<ngraph::Output<ngraph::Node>, std::__1::allocator<ngraph::Output<ngraph::Node> > >&, std::__1::vector<ngraph::Output<ngraph::Node>, std::__1::allocator<ngraph::Output<ngraph::Node> > > const&)", referenced from:
      vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
  "ngraph::Node::set_arguments(std::__1::vector<ngraph::Output<ngraph::Node>, std::__1::allocator<ngraph::Output<ngraph::Node> > > const&)", referenced from:
      ExecGraphInfoSerialization::ExecutionNode::clone_with_new_inputs(std::__1::vector<ngraph::Output<ngraph::Node>, std::__1::allocator<ngraph::Output<ngraph::Node> > > const&) const in libinference_engine_s.a(ie_rtti.cpp.o)
  "ngraph::Node::set_output_type(unsigned long, ngraph::element::Type const&, ngraph::PartialShape const&)", referenced from:
      ExecGraphInfoSerialization::ExecutionNode::clone_with_new_inputs(std::__1::vector<ngraph::Output<ngraph::Node>, std::__1::allocator<ngraph::Output<ngraph::Node> > > const&) const in libinference_engine_s.a(ie_rtti.cpp.o)
  "ngraph::Node::m_next_instance_id", referenced from:
      std::__1::shared_ptr<ExecGraphInfoSerialization::ExecutionNode> std::__1::shared_ptr<ExecGraphInfoSerialization::ExecutionNode>::make_shared<>() in libinference_engine_s.a(ie_rtti.cpp.o)
  "ngraph::Node::validate_and_infer_types()", referenced from:
      vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
  "ngraph::Node::evaluate(std::__1::vector<std::__1::shared_ptr<ngraph::runtime::HostTensor>, std::__1::allocator<std::__1::shared_ptr<ngraph::runtime::HostTensor> > > const&, std::__1::vector<std::__1::shared_ptr<ngraph::runtime::HostTensor>, std::__1::allocator<std::__1::shared_ptr<ngraph::runtime::HostTensor> > > const&)", referenced from:
      vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
  "ngraph::Node::~Node()", referenced from:
      ExecGraphInfoSerialization::ExecutionNode::~ExecutionNode() in libinference_engine_s.a(ie_rtti.cpp.o)
      ExecGraphInfoSerialization::ExecutionNode::~ExecutionNode() in libinference_engine_s.a(ie_rtti.cpp.o)
      std::__1::__shared_ptr_emplace<ExecGraphInfoSerialization::ExecutionNode, std::__1::allocator<ExecGraphInfoSerialization::ExecutionNode> >::~__shared_ptr_emplace() in libinference_engine_s.a(ie_rtti.cpp.o)
      std::__1::__shared_ptr_emplace<ExecGraphInfoSerialization::ExecutionNode, std::__1::allocator<ExecGraphInfoSerialization::ExecutionNode> >::~__shared_ptr_emplace() in libinference_engine_s.a(ie_rtti.cpp.o)
  "ngraph::Node::is_dynamic() const", referenced from:
      vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
  "ngraph::Node::description() const", referenced from:
      vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
  "ngraph::Node::is_constant() const", referenced from:
      vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
  "ngraph::Node::get_arguments() const", referenced from:
      vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
  "ngraph::Node::get_output_size() const", referenced from:
      ExecGraphInfoSerialization::ExecutionNode::clone_with_new_inputs(std::__1::vector<ngraph::Output<ngraph::Node>, std::__1::allocator<ngraph::Output<ngraph::Node> > > const&) const in libinference_engine_s.a(ie_rtti.cpp.o)
  "ngraph::Node::write_description(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, unsigned int) const", referenced from:
      vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
  "ngraph::Node::copy_with_new_args(std::__1::vector<std::__1::shared_ptr<ngraph::Node>, std::__1::allocator<std::__1::shared_ptr<ngraph::Node> > > const&) const", referenced from:
      vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
  "ngraph::Node::get_output_element_type(unsigned long) const", referenced from:
      ExecGraphInfoSerialization::ExecutionNode::clone_with_new_inputs(std::__1::vector<ngraph::Output<ngraph::Node>, std::__1::allocator<ngraph::Output<ngraph::Node> > > const&) const in libinference_engine_s.a(ie_rtti.cpp.o)
  "ngraph::Node::get_default_output_index() const", referenced from:
      vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
  "ngraph::Node::get_output_partial_shape(unsigned long) const", referenced from:
      ExecGraphInfoSerialization::ExecutionNode::clone_with_new_inputs(std::__1::vector<ngraph::Output<ngraph::Node>, std::__1::allocator<ngraph::Output<ngraph::Node> > > const&) const in libinference_engine_s.a(ie_rtti.cpp.o)
  "ngraph::Node::get_autob() const", referenced from:
      vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
  "ngraph::Node::is_output() const", referenced from:
      vtable for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
  "typeinfo for ngraph::Node", referenced from:
      typeinfo for ExecGraphInfoSerialization::ExecutionNode in libinference_engine_s.a(ie_rtti.cpp.o)
  "vtable for ngraph::Node", referenced from:
      std::__1::shared_ptr<ExecGraphInfoSerialization::ExecutionNode> std::__1::shared_ptr<ExecGraphInfoSerialization::ExecutionNode>::make_shared<>() in libinference_engine_s.a(ie_rtti.cpp.o)
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Did anyone had the same problem as me, and did anyone know how to fix it?

alalek commented 4 years ago

define USE_STATIC_IE

I believe it is a source of the problem.

navacar commented 4 years ago

source

I just tried to remove it but the the same thing happened

navacar commented 4 years ago

it was because i didn't add -lngraph in g++ comand