Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when building shared libs on Windows. #1942

Open
JenusL opened this issue Feb 4, 2024 · 1 comment
Open

Error when building shared libs on Windows. #1942

JenusL opened this issue Feb 4, 2024 · 1 comment
Labels
Build Issue Issues related to build or environment problems on any platform.

Comments

@JenusL
Copy link

JenusL commented Feb 4, 2024

Hi!
When building OCIO with shared libs on windows it fails to link correctly with Imath.
I get the following when building with Imath 3.1.10, OpenExr 3.2.1 and OpenColorIO 2.3.2

Lut1DOpData.obj : error LNK2001: unresolved external symbol imath_half_to_float_table
OpHelpers.obj : error LNK2001: unresolved external symbol imath_half_to_float_table
CPUProcessor.obj : error LNK2001: unresolved external symbol imath_half_to_float_table
FileFormatDiscreet1DL.obj : error LNK2001: unresolved external symbol imath_half_to_float_table
MathUtils.obj : error LNK2001: unresolved external symbol imath_half_to_float_table
Lut1DOpCPU.obj : error LNK2001: unresolved external symbol imath_half_to_float_table
..\vfxplatform_build\build\OpenColorIO\src\OpenColorIO\Release\OpenColorIO_2_3.dll : fatal error LNK1120: 1 unresolved externals

This seem to be a common issue with Imath and I think the solution is to define IMATH_DLL when needed, but I'm not sure where or with what logic it should be defined, but I guess only when building shared on Windows.
In my test to see if I could work around it I just added the define to FindImath.cmake and then it builds correctly.
More info in this Imath ticket AcademySoftwareFoundation/Imath#212 (comment)

@kmilos
Copy link

kmilos commented Feb 5, 2024

FYI, recent Imath ships with its own CMake config files which should already take care of adding the IMATH_DLL compile definition to the imported Imath::Imath target. E.g. on MinGW I have this in lib/cmake/Imath/ImathTargets.cmake:

set_target_properties(Imath::Imath PROPERTIES
  INTERFACE_COMPILE_DEFINITIONS "IMATH_DLL"
  INTERFACE_COMPILE_FEATURES "cxx_std_11"
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
  INTERFACE_LINK_LIBRARIES "Imath::ImathConfig;m"
)

So this could be MSVC specific, as there is no intervention needed to build OCIO w/ shared Imath on MinGW.

@carolalynn carolalynn added the Build Issue Issues related to build or environment problems on any platform. label Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build Issue Issues related to build or environment problems on any platform.
Projects
None yet
Development

No branches or pull requests

3 participants