conan
conan copied to clipboard
[question] Linking issue while try to create package dependent of other package
Hi, I've tried to create package for OpenVINO project( https://github.com/openvinotoolkit/openvino )
I've made conanfile.py in OpenVINO:
from conans import ConanFile, CMake
class OpenvinoConan(ConanFile):
name = "openvino"
version = "2022.1"
license = "<Put the package license here>"
author = "<Put your name here> <And your email here>"
url = "<Package recipe repository url here, for issues about the package>"
description = "<Description of Openvino here>"
topics = ("<Put some tag here>", "<here>", "<and here>")
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "fPIC": True}
generators = ["cmake", "CMakeToolchain", "CMakeDeps", "cmake_paths"]
exports_sources = ["cmake/*", "ngraph/*", "scripts/*", "src/*", "thirdparty/*", "tools/*", "CMakeLists.txt"]
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
def requirements(self):
self.requires("onnx/1.11.0")
def configure_cmake(self):
self.cmake = CMake(self)
self.cmake.verbose = True
self.cmake.definitions["ENABLE_INTEL_CPU"] = "ON"
self.cmake.definitions["ENABLE_INTEL_CPU"]="ON"
self.cmake.definitions["ENABLE_INTEL_GPU"]="OFF"
self.cmake.definitions["ENABLE_INTEL_GNA"]="OFF"
self.cmake.definitions["ENABLE_INTEL_MYRIAD"]="OFF"
self.cmake.definitions["ENABLE_OPENCV"]="OFF"
self.cmake.definitions["ENABLE_TESTS"]="OFF"
self.cmake.definitions["ENABLE_BEH_TESTS"]="OFF"
self.cmake.definitions["ENABLE_FUNCTIONAL_TESTS"]="OFF"
self.cmake.definitions["ENABLE_PROFILING_ITT"]="OFF"
self.cmake.definitions["ENABLE_SAMPLES"]="OFF"
self.cmake.definitions["ENABLE_PYTHON"]="OFF"
self.cmake.definitions["PYTHON_EXECUTABLE"] ="/usr/bin/python3"
self.cmake.definitions["ENABLE_CPPLINT"]="OFF"
self.cmake.definitions["ENABLE_NCC_STYLE"]="OFF"
self.cmake.definitions["ENABLE_OV_PADDLE_FRONTEND"]="OFF"
self.cmake.definitions["ENABLE_OV_TF_FRONTEND"]="OFF"
self.cmake.definitions["ENABLE_TESTS"]="OFF"
self.cmake.definitions["CMAKE_EXPORT_NO_PACKAGE_REGISTRY"] = "OFF"
self.cmake.definitions["ENABLE_TEMPLATE"] = "OFF"
self.cmake.definitions["ENABLE_INTEL_MYRIAD_COMMON"] = "OFF"
self.cmake.definitions["CMAKE_CXX_FLAGS"] = "-Wno-error=undef -Wno-error=suggest-override"
self.cmake.definitions["CMAKE_C_FLAGS"] = "-Wno-error=undef -Wno-error=suggest-override"
self.cmake.configure()
def build(self):
self.configure_cmake()
self.cmake.build()
def package(self):
self.cmake.install()
def package_info(self):
self.cpp_info.libs = ["openvino"]
self.cpp_info.build_modules["cmake_find_package"].append("cmake/Findopenvino.cmake")
self.cpp_info.includedirs = ["runtime/include", "runtime/include/ie", "runtime/include/ngraph", "runtime/include/openvino"]
self.cpp_info.libdirs = ["runtime/lib/intel64", "runtime/3rdparty/tbb_bind_2_5/lib"]
OpenVINO has structure that the external libraries are used as a submodules to create package. I've changed that ONNX and Protobuf are taken from conan packages (conancenter)
The package has been created correctly.
akulikow@akulikow-ubuntu20 ~/projects/openvino/build (conan*?) $ conan search
Existing package recipes:
onnx/1.11.0
openvino/2022.1
protobuf/3.17.1
zlib/1.2.11
Additionally I've created small project which use created package CMakeLists.txt
cmake_minimum_required(VERSION 3.20)
project(testApp)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
set(SOURCE ${CMAKE_SOURCE_DIR}/src/main.cpp)
add_executable(${PROJECT_NAME} ${SOURCE})
find_package(openvino)
target_link_libraries(${PROJECT_NAME} PUBLIC openvino::openvino)
conanfile.py
from conans import ConanFile, CMake, tools
class ConanexampleConan(ConanFile):
name = "conanexample"
version = "0.1"
license = "<Put the package license here>"
author = "<Put your name here> <And your email here>"
url = "<Package recipe repository url here, for issues about the package>"
description = "<Description of Conanexample here>"
topics = ("<Put some tag here>", "<here>", "<and here>")
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "fPIC": True}
generators = ["cmake", "CMakeToolchain", "CMakeDeps"]
exports_sources = ["src/*", "CMakeLists.txt"]
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
def requirements(self):
self.requires("openvino/2022.1")
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def imports(self):
self.copy("*.dll", dst="bin", src="bin")
self.copy("*.dylib*", dst="bin", src="lib")
self.copy('*.so*', dst='bin', src='lib')
def package(self):
self.copy("*.h", dst="include", src="src")
self.copy("*hello.lib", dst="lib", keep_path=False)
self.copy("*.dll", dst="bin", keep_path=False)
self.copy("*.so", dst="lib", keep_path=False)
self.copy("*.dylib", dst="lib", keep_path=False)
self.copy("*.a", dst="lib", keep_path=False)
def package_info(self):
self.cpp_info.libs = ["testapp"]
main.cpp
#include "openvino/openvino.hpp"
int main() {
ov::Core core;
return 0;
}
When I try to make package by: conan create . I see a lot of linking errors.
Part of output of creating package:
Exporting package recipe
conanexample/0.1 exports_sources: Copied 1 '.cpp' file: main.cpp
conanexample/0.1 exports_sources: Copied 1 '.txt' file: CMakeLists.txt
conanexample/0.1: The stored package has not changed
conanexample/0.1: Exported revision: 8b9602c0dfcb12853fe3a7e2c7961b99
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++
compiler.version=9
os=Linux
os_build=Linux
[options]
[build_requires]
[env]
conanexample/0.1: Forced build from source
Installing package: conanexample/0.1
Requirements
conanexample/0.1 from local cache - Cache
onnx/1.11.0 from 'conancenter' - Cache
openvino/2022.1 from local cache - Cache
protobuf/3.17.1 from 'conancenter' - Cache
zlib/1.2.11 from 'conancenter' - Cache
Packages
conanexample/0.1:abcefe982f9f165589b73acce478e033970f75f7 - Build
onnx/1.11.0:4336b64591025595c27a62d8ffedf1b08096ebeb - Cache
openvino/2022.1:05efaa477688a30b0e70009e5e54cf9af21893e5 - Cache
protobuf/3.17.1:645a1e1c64ed36f82391f6d395fec125f43abcdd - Cache
zlib/1.2.11:6af9cc7cb931c5ad942174fd7838eb655717c709 - Cache
Installing (downloading, building) binaries...
zlib/1.2.11: Already installed!
protobuf/3.17.1: Already installed!
protobuf/3.17.1: Appending PATH environment variable: /home/akulikow/.conan/data/protobuf/3.17.1/_/_/package/645a1e1c64ed36f82391f6d395fec125f43abcdd/bin
onnx/1.11.0: Already installed!
openvino/2022.1: Already installed!
conanexample/0.1: Copying sources to build folder
conanexample/0.1: Building your package in /home/akulikow/.conan/data/conanexample/0.1/_/_/build/abcefe982f9f165589b73acce478e033970f75f7
conanexample/0.1: Generator 'CMakeToolchain' calling 'generate()'
conanexample/0.1: Generator cmake created conanbuildinfo.cmake
conanexample/0.1: Generator 'CMakeDeps' calling 'generate()'
conanexample/0.1: Aggregating env generators
conanexample/0.1 imports(): Copied 2 '.so' files: libonnxifi_dummy.so, libonnxifi.so
conanexample/0.1: Calling build()
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: called by CMake conan helper
-- Conan: called inside local cache
-- Conan: Adjusting output directories
-- Conan: Using cmake global configuration
-- Conan: Adjusting default RPATHs Conan policies
-- Conan: Adjusting language standard
-- Conan: Adjusting fPIC flag (ON)
-- Conan: Compiler GCC>=5, checking major version 9
-- Conan: Checking correct version: 9
-- Conan: C++ stdlib: libstdc++
-- Conan: Target declared 'openvino::openvino'
-- Conan: Component target declared 'onnx_proto'
-- Conan: Component target declared 'onnxifi'
-- Conan: Component target declared 'onnxifi_dummy'
-- Conan: Component target declared 'onnxifi_loader'
-- Conan: Component target declared 'onnxifi_wrapper'
-- Conan: Component target declared 'onnx'
-- Conan: Target declared 'onnx::onnx'
-- Conan: Component target declared 'protobuf::libprotobuf'
-- Conan: Component target declared 'protobuf::libprotoc'
-- Conan: Target declared 'protobuf::protobuf'
-- Conan: Target declared 'ZLIB::ZLIB'
-- Conan: Including build module from '/home/akulikow/.conan/data/protobuf/3.17.1/_/_/package/645a1e1c64ed36f82391f6d395fec125f43abcdd/lib/cmake/protobuf/protobuf-generate.cmake'
-- Conan: Including build module from '/home/akulikow/.conan/data/protobuf/3.17.1/_/_/package/645a1e1c64ed36f82391f6d395fec125f43abcdd/lib/cmake/protobuf/protobuf-module.cmake'
-- Conan: Including build module from '/home/akulikow/.conan/data/protobuf/3.17.1/_/_/package/645a1e1c64ed36f82391f6d395fec125f43abcdd/lib/cmake/protobuf/protobuf-options.cmake'
-- Configuring done
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
CMAKE_EXPORT_NO_PACKAGE_REGISTRY
CMAKE_INSTALL_BINDIR
CMAKE_INSTALL_DATAROOTDIR
CMAKE_INSTALL_INCLUDEDIR
CMAKE_INSTALL_LIBDIR
CMAKE_INSTALL_LIBEXECDIR
CMAKE_INSTALL_OLDINCLUDEDIR
CMAKE_INSTALL_SBINDIR
-- Build files have been written to: /home/akulikow/.conan/data/conanexample/0.1/_/_/build/abcefe982f9f165589b73acce478e033970f75f7
[ 50%] Building CXX object CMakeFiles/testApp.dir/src/main.cpp.o
[100%] Linking CXX executable bin/testApp
/usr/bin/ld: /home/akulikow/.conan/data/openvino/2022.1/_/_/package/05efaa477688a30b0e70009e5e54cf9af21893e5/runtime/lib/intel64/libopenvino.a(ie_core.cpp.o): in function `InferenceEngine::Core::ReadNetwork(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&) const':
ie_core.cpp:(.text._ZNK15InferenceEngine4Core11ReadNetworkERKSbIwSt11char_traitsIwESaIwEES6_+0x3a): undefined reference to `ov::util::wstring_to_string(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&)'
/usr/bin/ld: ie_core.cpp:(.text._ZNK15InferenceEngine4Core11ReadNetworkERKSbIwSt11char_traitsIwESaIwEES6_+0x45): undefined reference to `ov::util::wstring_to_string(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&)'
/usr/bin/ld: /home/akulikow/.conan/data/openvino/2022.1/_/_/package/05efaa477688a30b0e70009e5e54cf9af21893e5/runtime/lib/intel64/libopenvino.a(ie_core.cpp.o): in function `std::unique_ptr<pugi::xml_document, std::default_delete<pugi::xml_document> >::~unique_ptr()':
ie_core.cpp:(.text._ZNSt10unique_ptrIN4pugi12xml_documentESt14default_deleteIS1_EED2Ev[_ZNSt10unique_ptrIN4pugi12xml_documentESt14default_deleteIS1_EED5Ev]+0x11): undefined reference to `pugi::xml_document::~xml_document()'
/usr/bin/ld: /home/akulikow/.conan/data/openvino/2022.1/_/_/package/05efaa477688a30b0e70009e5e54cf9af21893e5/runtime/lib/intel64/libopenvino.a(ie_core.cpp.o): in function `ov::Core::read_model(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&) const':
ie_core.cpp:(.text._ZNK2ov4Core10read_modelERKSbIwSt11char_traitsIwESaIwEES6_+0x48): undefined reference to `ov::util::wstring_to_string(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&)'
/usr/bin/ld: ie_core.cpp:(.text._ZNK2ov4Core10read_modelERKSbIwSt11char_traitsIwESaIwEES6_+0x58): undefined reference to `ov::util::wstring_to_string(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&)'
/usr/bin/ld: /home/akulikow/.conan/data/openvino/2022.1/_/_/package/05efaa477688a30b0e70009e5e54cf9af21893e5/runtime/lib/intel64/libopenvino.a(ie_core.cpp.o): in function `ov::detail::load_extensions(std::string const&)':
ie_core.cpp:(.text._ZN2ov6detail15load_extensionsERKSs[_ZN2ov6detail15load_extensionsERKSs]+0x31): undefined reference to `ov::util::load_shared_object(char const*)'
/usr/bin/ld: ie_core.cpp:(.text._ZN2ov6detail15load_extensionsERKSs[_ZN2ov6detail15load_extensionsERKSs]+0x5c): undefined reference to `ov::util::get_symbol(std::shared_ptr<void> const&, char const*)'
/usr/bin/ld: /home/akulikow/.conan/data/openvino/2022.1/_/_/package/05efaa477688a30b0e70009e5e54cf9af21893e5/runtime/lib/intel64/libopenvino.a(ie_core.cpp.o): in function `ov::Core::add_extension(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&)':
ie_core.cpp:(.text._ZN2ov4Core13add_extensionERKSbIwSt11char_traitsIwESaIwEE+0x2c): undefined reference to `ov::util::wstring_to_string(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&)'
/usr/bin/ld: /home/akulikow/.conan/data/openvino/2022.1/_/_/package/05efaa477688a30b0e70009e5e54cf9af21893e5/runtime/lib/intel64/libopenvino.a(ie_core.cpp.o): in function `ParseXml(char const*)':
ie_core.cpp:(.text._Z8ParseXmlPKc[_Z8ParseXmlPKc]+0x4f): undefined reference to `ov::util::string_to_wstring(std::string const&)'
/usr/bin/ld: ie_core.cpp:(.text._Z8ParseXmlPKc[_Z8ParseXmlPKc]+0x82): undefined reference to `pugi::xml_document::xml_document()'
/usr/bin/ld: ie_core.cpp:(.text._Z8ParseXmlPKc[_Z8ParseXmlPKc]+0x9d): undefined reference to `pugi::xml_document::load_file(wchar_t const*, unsigned int, pugi::xml_encoding)'
/usr/bin/ld: ie_core.cpp:(.text._Z8ParseXmlPKc[_Z8ParseXmlPKc]+0x3d6): undefined reference to `pugi::xml_parse_result::description() const'
/usr/bin/ld: ie_core.cpp:(.text._Z8ParseXmlPKc[_Z8ParseXmlPKc]+0x50a): undefined reference to `pugi::xml_document::~xml_document()'
/usr/bin/ld: /home/akulikow/.conan/data/openvino/2022.1/_/_/package/05efaa477688a30b0e70009e5e54cf9af21893e5/runtime/lib/intel64/libopenvino.a(ie_core.cpp.o): in function `(anonymous namespace)::getStaticPluginsRegistry()':
ie_core.cpp:(.text._ZN12_GLOBAL__N_124getStaticPluginsRegistryEv+0x117): undefined reference to `CreatePluginEngineHETERO'
/usr/bin/ld: ie_core.cpp:(.text._ZN12_GLOBAL__N_124getStaticPluginsRegistryEv+0x1fb): undefined reference to `CreatePluginEngineCPU'
/usr/bin/ld: ie_core.cpp:(.text._ZN12_GLOBAL__N_124getStaticPluginsRegistryEv+0x224): undefined reference to `CreateExtensionSharedCPU'
/usr/bin/ld: ie_core.cpp:(.text._ZN12_GLOBAL__N_124getStaticPluginsRegistryEv+0x2f9): undefined reference to `CreatePluginEngineMULTI'
/usr/bin/ld: ie_core.cpp:(.text._ZN12_GLOBAL__N_124getStaticPluginsRegistryEv+0x5bc): undefined reference to `CreatePluginEngineBATCH'
/usr/bin/ld: /home/akulikow/.conan/data/openvino/2022.1/_/_/package/05efaa477688a30b0e70009e5e54cf9af21893e5/runtime/lib/intel64/libopenvino.a(ie_core.cpp.o): in function `ov::CoreImpl::RegisterPluginsInRegistry(std::string const&)':
ie_core.cpp:(.text._ZN2ov8CoreImpl25RegisterPluginsInRegistryERKSs[_ZN2ov8CoreImpl25RegisterPluginsInRegistryERKSs]+0x8d): undefined reference to `pugi::xml_document::document_element() const'
...
It looks that it has some problem with linking libraries inside OpenVINO. Do you know what can cause that kind of issue? Maybe should I somehow export internal libraries to the package?
thanks in advance for your help :)
Hi @artkuli
Maybe you want to try with only the modern integrations, not the legacy ones. Use conan new hello/0.1 --template=cmake_lib to get a working starting point.
It seems that you are mixing the legacy CMake with the new ones, from from conans import ConanFile, CMake, and the generators = "cmake". You shouldn't be mixing those, but use the from conan.tools.cmake import CMake one together with the CMakeToolchain and CMakeDeps.
That might be causing issues.
Hi @memsharded Thanks for your quick response! According to your reply I will use only modern integrations. It looks that I have to learn a lot about Conan :) I will let you know that it helps or not :) Thanks a lot!
@memsharded looks like conan decided to build OpenVINO as a static library as far as I can see from:
default_options = {"shared": False, "fPIC": True}
Then it tried to wrap libopenvino.a to a cmake target openvino::openvino? Or it's an OpenVINO target?
In OpenVINO, in case of static build we had a great number of other static libs which are private dependencies for libopenvino.a, looks like they are missed here for some reason.
Any reason why conan has shared=false to be a default?
Sorry for miss click
Any reason why conan has shared=false to be a default?
Yes, it is generally simpler for users, more robust builds, less moving pieces... Many open source libraries default builds are also static, not shared. They also require less re-builds in general.
I don't know if this is a Conan issue or maybe just an openvino recipe issue. The recipe above was using the legacy integration, so it would be good to see a modernized version, or maybe reduce the case to simpler recipes that help to reproduce the use case and issues.