microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
23.41k stars 6.47k forks source link

Not linked with dependency of OpenImageIO on linux #8049

Closed harokyang closed 4 years ago

harokyang commented 5 years ago

find_package(OpenImageIO) report failure There is no vcpkg-cmake-wrapper.cmake and FindOpenImageIO.cmake under vcpkg/installed/x64-linux/share/openimageio

Also OpenImageIO is built as static library on linux instead of shared library(on Windows) Manually link with this library will also require manually link with other dependent static libraries(OpenEXR and more)

JackBoosY commented 5 years ago

Sorry, I cannot repro this issue.

Command cmake CMakeLists.txt -DCMAKE_TOOLCHAIN_FILE=/home/vcpkg/scripts/buildsystems/vcpkg.cmake result:

root@usr:/home/test# cmake CMakeLists.txt -DCMAKE_TOOLCHAIN_FILE=/home/vcpkg/scripts/buildsystems/vcpkg.cmake
-- OPENIMAGEIO_ROOT_DIR =
-- OpenImageIO includes     = /home/vcpkg/installed/x64-linux/include
-- OpenImageIO libraries    = /home/vcpkg/installed/x64-linux/debug/lib/libOpenImageIO.a
-- OpenImageIO library_dirs = /home/vcpkg/installed/x64-linux/debug/lib
-- OpenImageIO oiiotool     = OIIOTOOL_BIN-NOTFOUND
-- Configuring done
-- Generating done
-- Build files have been written to: /home/test

CMakelists.txt :

cmake_minimum_required(VERSION 3.10)
project(testprj)

add_executable(testprj test.cpp)

find_package(OpenImageIO)

Use the command .\vcpkg integrate install and add the cmake parameter -DCMAKE_TOOLCHAIN_FILE=/YOUR-VCPKG-INSTALL-PATH/scripts/buildsystems/vcpkg.cmake to the cmake command line.

Thanks.

harokyang commented 5 years ago

Well, the find_package() issue is gone, perhaps some issues on my side But the link issue still existed (edited the title)

On Windows, OpenImageIO was built as dll, You only need to link with OpenImageIO.dll All the other dependency dlls are managed and copied by vcpkg

On linux, OpenImageIO was built as static library without internally linked with its dependent libraries I got bunch of link error like:

undefined reference to Imf_2_3::TypedAttribute<std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >::staticTypeName()' undefined reference toImf_2_3::TimeCode::minutes() const' undefined reference to openvdb::v5_1::io::MappedFile::createBuffer() const' undefined reference topng_get_valid' undefined reference to jpeg_write_coefficients' undefined reference toTIFFSetDirectory' undefined reference to Imf_2_3::InputPart::setFrameBuffer(Imf_2_3::FrameBuffer const&)' undefined reference toopenvdb::v5_1::uninitialize()' undefined reference to Imf_2_3::TypedAttribute<Imf_2_3::Envmap>::readValueFrom(Imf_2_3::IStream&, int, int)' undefined reference toboost::filesystem::detail::copy(boost::filesystem::path const&, boost::filesystem::path const&, boost::system::error_code*)' undefined reference to Imf_2_3::Header::dataWindow() const' undefined reference toImf_2_3::Header::type[abi:cxx11]() cons and more...

I have to manually link my project with all the libraries OpenImageIO depend on

OpenImageIO should be built as a shared library by default, and only a static one if installed as OpenImageIO:x64-linux-static

JackBoosY commented 5 years ago

@harokyang Now we just support static build on Linux. And according to #1589, can you try to install ilmbase first and then rebuild openimageio? If it's successful, I will confirm this issue.

Thanks.

harokyang commented 5 years ago

@JackBoosY I tried, still got the same link failure

JackBoosY commented 5 years ago

It seems that cmake can't find the correct OpenEXR library. Can you add message("OpenExr Lib: ${OPENEXR_ILMIMF_LIBRARY_DEBUG} ${OPENEXR_ILMIMF_LIBRARY_RELEASE}") in VCPKG_PATH\buildtrees\openimageio\src\SOME_HASH\src\cmake\modules\FindOpenEXR.cmake, rebuild openimageio and provide the following configure logs?

Thanks.

harokyang commented 5 years ago

how can I kick a package rebuild in vcpkg?

harokyang commented 5 years ago

Got it

config-x64-linux-dbg-err.log config-x64-linux-dbg-out.log config-x64-linux-rel-err.log config-x64-linux-rel-out.log

JackBoosY commented 5 years ago

Log shows: OpenExr Lib: OPENEXR_ILMIMF_LIBRARY_DEBUG-NOTFOUND /home/harok/git/vcpkg/installed/x64-linux/debug/lib/libIlmImf-2_3.so

Got it! Openexr that builds the debug library does not contain the debug suffix _d, but uses the suffix to find it in src/cmake/modules/FindOpenEXR.cmake.

JackBoosY commented 5 years ago

@harokyang Please update vcpkg and rebuild openimageio.

Thanks.

harokyang commented 5 years ago

still failed here is a test project

All symbols belong to oiio's dependencies can't be resolved

harokyang commented 5 years ago

OK, it's the triplet of linux which set VCPKG_LIBRARY_LINKAGE as static by default By forcing oiio built as shared library solved the problem

But the issue of static oiio still exist, you have to resolve all those symbols manually by linking with OpenEXR libtiff libpng tbb openvdb...more and more......all yourself, which rendered the static oiio almost unusable

harokyang commented 5 years ago

I added a custom triplet file with VCPKG_LIBRARY_LINKAGE=dynamic, and build oiio with it But the dependent libraries are also switched to this new triplet, and OpenEXR failed on that dynamic triplet setting

Seems the only solution now is to force oiio build as dynamic in profile.cmake by ignoring the set BUILDSTATIC and LINKSTATIC part

JackBoosY commented 5 years ago

@harokyang Could you provide the error logs?

Thanks.

harokyang commented 5 years ago

build log from the test project above build.log

Thanks

JackBoosY commented 5 years ago

Confirmed. vcpkg-cmake-wrapper.cmake doesn't work in linux.

fabiencastan commented 4 years ago

@JackBoosY I'm facing the same issue as described here. You are saying that the problem is on a generic vcpkg file and not on the openimageio cmake files. Could you explain what is the problem?

JackBoosY commented 4 years ago

@fabiencastan What can be confirmed now is that share/openimageio/vcpkg-cmake-wrapper.cmake did not play the expected role, causing this issue.

JackBoosY commented 4 years ago

Hi everyone, can anyone test my PR #12592?

Thanks.