0

我按照他们的 github https://github.com/openvinotoolkit/openvino上的说明在 macOS 上构建它,完成它,当我写一个小代码来检查是否全部清晰

#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;
}

当我用命令编译它时

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

它给了我错误

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)

然后我添加了 .a 库并运行了这个命令

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 

我得到了这个

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)

有没有人和我一样的问题,有没有人知道怎么解决?

4

1 回答 1

0

首先,只需要与您就您的工具包安装进行交叉检查。由于您已经尝试运行模型,我假设您已经正确设置它(仅供参考,最新版本是 2020.4):https ://docs.openvinotoolkit.org/latest/openvino_docs_install_guides_installing_openvino_macos.html

您收到的错误,架构 x86_64 的未定义符号是 Xcode 构建失败,表明您错过了推理引擎中的某些内容,或者您​​将模型与某些资源链接的方式不正确或其他一些原因。只要此错误仍然存​​在,您将无法编译代码。这就是为什么您的链接器命令失败,退出代码为 1。

大多数错误的发生是因为用户没有正确设置 OpenVINO 环境变量或配置模型优化器。这就是为什么运行验证脚本来验证安装和编译示例非常重要的原因。

在运行任何自定义模型之前,最好有一个稳定的 Openvino 环境,因此请帮助检查您是否可以运行默认模型,例如https://docs.openvinotoolkit.org/latest/openvino_docs_install_guides_installing_openvino_macos.html

默认情况下,如果您正确配置了工具包,您应该已经拥有预训练模型,包括开放动物园模型、模型优化器和推理引擎,这些都是可以使用的示例。这些应该已经位于您安装的工具包的目录中,您不必与其他资源分开安装。

请注意您需要: CMake 3.4 或更高版本、Python 3.5 或更高版本、Apple Xcode命令行工具*、(可选)Apple Xcode* IDE(OpenVINO 不需要,但对开发很有用),

并且支持的 MAC OS 是macOS 10.14.4 *

再次,请帮助交叉检查您在 Openvino 环境中拥有的内容以及您使用官方文档配置的步骤https://docs.openvinotoolkit.org/latest/openvino_docs_install_guides_installing_openvino_macos.html

谢谢!

于 2020-07-23T03:29:43.653 回答