Imath
Imath copied to clipboard
imath_half_to_float_table not properly exported from DLL
I'm building your library to be used as input to OpenEXR
library, and I get unresolved external symbol imath_half_to_float_table
I have defined both IMATH_DLL
and IMATH_EXPORTS
After running DUMPBIN /EXPORTS Imath.dll
I get following export and can't figure out why
58 39 00096000 imath_half_to_float_table = imath_half_to_float_table
Expected output should be:
imath_half_to_float_table = imath_half_to_float_table_data
A workaround was to define IMATH_HALF_NO_LOOKUP_TABLE
in OpenEXR
project but I would prefer to use lookup table.
Do you have any idea what's wrong?
EDIT: Btw. I see inconsistence of macro used to export symbol:
half.h
IMATH_EXPORT const imath_half_uif_t* imath_half_to_float_table;
half.cpp
EXPORT_CONST const imath_half_uif_t *imath_half_to_float_table = imath_half_to_float_table_data;
Yeah, in both places, they should be IMATH_EXPORT_CONST. If that fixes your issue could you let us know, and either submit a PR, or we can patch it.
Thanks!
Following up on this briefly, I don't think there's actually a linkage inconsistency here, although the macros are confusing and possibly inconsistent themselves. The declaration of imath_half_to_float_table
picks up the extern
from the extern "C"
in the earlier part of the #if.
Sorry, closed by accident. I'm not sure what the issue might be, but I don't think we've had similar reports.
We have seen cases of unresolved imath_half_to_float
when accidentally linking against an older version of the Imath library (pre v.3.1), since the symbol is new in v3.1. Can you confirm that's not the case?
@meshula I'm sorry but I no longer use the library directly and can't test out your suggestion.
No worries. If you come back to it and encounter the issue again please feel free to continue the conversation here.
@cary-ilm : I can confirm I have the same issue using v3.1. I get: error LNK2001: unresolved external symbol imath_half_to_float_table
I am very new to this. I am using Imath (v3.1.1-rc1) as a dependency to OpenEXR (RB-3.1) which I am using to read an exr image file. (I had the same issue when using only openEXR and let it do Imath automatically) I am missing IMATH_DLL and IMATH_EXPORTS where swhould be defined though. Can you help please?
how did you build and/or install Imath? how are you building OpenEXR? I'm asking in terms of, what was your command line?
Hello @meshula
many thanks for the help!
C:\Source\IMath
and C:\Source\OpenEXR
are the repo locations
cd C:\IMath\Build
cmake C:\Source\IMath
cmake . -DCMAKE_INSTALL_PREFIX=C:\IMath\Release
cmake --build . --target install --config Release
cmake . -DCMAKE_INSTALL_PREFIX=C:\IMath\Debug
cmake --build . --target install --config Debug
cd C:\OpenEXR\Build
cmake C:\Source\OpenEXR
cmake . -DImath_DIR:STRING="C:\IMath\Release\lib\cmake\Imath"
cmake . -DCMAKE_INSTALL_PREFIX=C:\OpenEXR\Release
cmake --build . --target install --config Release
cmake . -DImath_DIR:STRING="C:\IMath\Debug\lib\cmake\Imath"
cmake . -DCMAKE_INSTALL_PREFIX=C:\OpenEXR\Debug
cmake --build . --target install --config Debug
By the way for openEXR I have to build Release first otherwise Debug complains about zlib
. The name expects is missing letter d
Thanks for the steps! Good catch on the zlib naming, that needs attention in our build script for sure.
Following up on this, @meshula were you able to determine what to do here?
My apologies, it looks like I didn't post my results.
[Edit] this halfLimits problem has been repaired.
Note that there's a new issue ~ I'm not sure why CI didn't catch it.
ImfConvert.cpp
C:\IMath\Release\include\Imath\halfLimits.h(16,1): fatal error C1021: invalid preprocessor command 'warning' [C:\Projects\Lucasfilm\OpenEXR-build\s
rc\lib\OpenEXR\OpenEXR.vcxproj]
#warning
isn't msvc compatible.
[End edit]
I was able to build but had to modify @nickolasm's recipe:
cd C:\IMath\Build
cmake C:\Source\IMath
cmake . -DCMAKE_INSTALL_PREFIX=C:\IMath\Release
cmake --build . --target install --config Release
cmake . -DCMAKE_INSTALL_PREFIX=C:\IMath\Debug
cmake --build . --target install --config Debug
cd C:\OpenEXR\Build
cmake C:\Source\OpenEXR -DImath_DIR:STRING="C:\IMath\Release\lib\cmake\Imath"
cmake . -DCMAKE_INSTALL_PREFIX=C:\OpenEXR\Release
cmake --build . --target install --config Release
cmake . -DImath_DIR:STRING="C:\IMath\Debug\lib\cmake\Imath" . -DCMAKE_INSTALL_PREFIX=C:\OpenEXR\Debug
cmake --build . --target install --config Debug
Configuring in two steps as in @nickolasm's recipe causes an extra copy of Imath to be installed, and the desired Imath ignored. So I combined the configuration and setting of the Imath directory into a single step.
The recipe then succeeds for both Debug and Release.
Also, I didn't encounter an issue with zlib, so maybe that's been sorted out since then.
I'm running into this exact linking error for the unresolved Imath lookup table on windows in visual studio. Is the solution to turn off the lookup table or change a line in halfLimits.h?
I can't reproduce the problem with linking the look up table here.
[Edit: this problem has been resolved] Removing that line in halfLimits.h is necessary if you pull Imath today and try to build from top of tree.
It is unrelated to linking the lookup table.
If you pull both Imath and OpenEXR fresh, from top of tree, you should not see any unresolved lookup table errors.
If you do still get problems, please capture your steps, and the resulting error report and attach it here, maybe there will be more clues.
I patched halfLimits.h, so now you can ignore that problem.
I followed those steps and it compiles smoothly with no errors but unfortunately I am still getting this linker error when converting pixels in my project.
Error LNK2001 unresolved external symbol imath_half_to_float_table exrtester C:\Users\%USERNAME%\source\repos\exrtester\exrtester\exrtester.obj 1
Error LNK1120 1 unresolved externals exrtester C:\Users\%USERNAME%\source\repos\exrtester\x64\Debug\exrtester.exe 1
Visual Studio Project environment settings
Additional Include directories = C:\Imath\Release\include\Imath;C:\OpenEXR\Release\include\OpenEXR; AdditionalLibraryDirectories = C:\OpenEXR\Release\lib;C:\Imath\Release\lib; AdditionalDependencies = Imath-3_2.lib;OpenEXR-3_1.lib;
The .dlls have all been copied into the exrtester project root.
The Cmake commands
cd C:/
git clone https://github.com/AcademySoftwareFoundation/Imath
git clone https://github.com/AcademySoftwareFoundation/OpenEXR
cd C:/IMath
cmake . -DCMAKE_INSTALL_PREFIX="C:/IMath/Release"
cmake --build . --target install --config Release
cmake . -DCMAKE_INSTALL_PREFIX="C:/IMath/Debug"
cmake --build . --target install --config Debug
cd C:/OpenEXR
cmake . -DImath_DIR:STRING="C:/IMath/Release/lib/cmake/Imath"
cmake . -DCMAKE_INSTALL_PREFIX="C:/OpenEXR/Release"
cmake --build . --target install --config Release
cmake . -DImath_DIR:STRING="C:/IMath/Release/lib/cmake/Imath"
cmake . -DCMAKE_INSTALL_PREFIX="C:/OpenEXR/Debug"
cmake --build . --target install --config Debug
This is the point of failure in the code. If I remove the float conversion it compiles and runs all the other operations fine.
Imf::Array<Imf::Rgba> pixels;
// load pixels from "C:/OpenEXR/src/test/OpenEXRTest/comp_dwaa_v1.exr"
// pixel test conversion failure.
float pixel = pixels[0].r;
Thank you for your help I appreciate it and let me know if I should provide additional information. CMake 3.23.0 VisualStudio x64 2017 C++14
I also encountered the same issue when tried to do the similar assignment from Imf::Rgba
to float
on VisualStudio. The issue is temporarily fixed by adding # define IMATH_HALF_NO_LOOKUP_TABLE
before include the OpenEXR header files. Not sure if there is a better way to fix that.
Sorry it's taken me a long time to understand the issue. The problem is not building OpenEXR, the problem is linking OpenEXR to your own projects. I can keep investigating.
I'd like to bump that I'm also running into this issue. I'm working with OpenVDB which uses OpenEXR and IMath, and I get the same error. I'm using the temporary #define fix from @etudemin for now but I'd love to see a permanent solution
@kdt3rd Do we export the preprocessor directive IMATH_HALF_NO_LOOKUP_TABLE
in our config.cmake file? Perhaps that's the missing piece of the puzzle
I ran into this today when building a project that uses Imath 3.1.7, built as a shared library. Defining the preprocessor directive IMATH_DLL
in my code (not Imath or OpenEXR) fixed the linking problem for me.
Perhaps that's the same thing tripping you up @wilkesreid?
There's two preprocessor directives that need to be matched, IMATH_DLL indicating a shared library, and also IMATH_HALF_NO_LOOKUP_TABLE indicated whether the table will be used, or whether the no-table function will be used to do conversions.
hey, i am using imath library to run openvdb, but after configuring it, its showing the following error: Error LNK2001 unresolved external symbol imath_half_to_float_table
so do i need to change the config file or halg.h? if yes, then what should i change to make it run?
I think the configuration at the OpenVdb end of things might need some attention. Could you ask the question in that repo, and link here so we can see what the OpenVdb authors think?
vdb is still embedding their own copy of half. They appear to be using the same #defines as imath however, which could cause confusion if mixing both? https://github.com/AcademySoftwareFoundation/openvdb/blob/b77fc2b7d4656226af820719cf0b19403d552a35/openvdb/openvdb/math/Half.h#L210
Ah good catch, that's definitely an omission. Just up in the file from there they've taken care to namespace things.
I'm getting the same error when building OpenColorIO on Windows.
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
Just building Imath 3.1.10, OpenExr 3.2.1 and then OpenColorIO 2.3.2 with default cmake settings. Any news on fixing this?
@JenusL Have you reported this issue at OCIO? The issue is with OCIO configuration of Imath.
@JenusL Have you reported this issue at OCIO? The issue is with OCIO configuration of Imath.
No I haven't as I thought this is an Imath issue. But I'll do that. Thanks!