分配 'half' 类型时出现 OpenEXR 链接器错误

OpenEXR linker error when 'half' type is assigned

我在为包含 OpenEXR 定义的半类型的 Imf::Rgba 结构赋值时遇到问题。似乎存在与从 float 到 half 的转换有关的链接器错误。

Linking CXX executable graphics-env
Undefined symbols for architecture x86_64:
  "half::_eLut", referenced from:
      half::half(float) in main.cpp.o
  "half::convert(int)", referenced from:
      half::half(float) in main.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [graphics-env] Error 1
make[1]: *** [CMakeFiles/graphics-env.dir/all] Error 2
make: *** [all] Error 2

我认为这是 windows 上的一个常见问题,需要定义 OPENEXR_DLL。但是,这不起作用,因为我正在 OS X 上编译。我尝试链接到 libIlmImf.dylib 和 libIlmImf.a,结果相同。使用的 OpenEXR 版本是 2.2.0 并使用 Homebrew 安装。

这些符号在 half.h 中定义,它是 IlmBase 的一部分。

你应该 link 到 libHalf.dylib