2

I'm compiling openexr2.0.0 using visual studio 2012 x64 dll, I got this error:

ImfLut.obj : error LNK2001: unresolved external symbol "private: static union half::uif const * const half::_toFloat" (?_toFloat@half@@0QBTuif@1@B)

ImfRgbaYca.obj : error LNK2001: unresolved external symbol "private: static unsigned short const * const half::_eLut" (?_eLut@half@@0QBGB)

And I looked up in the half.lib using dumpbin /exports: half.lib

Another look up using dumpbin /exports on half.dll: half.dll

The two symbols are there. And interestingly, when I remove half.lib from dependency, VS complain convert is also unresolved. This shows that it could find convert but not _toFloat and _eLut. The differences are: _toFloat and _eLut are both static fields, convert is a static method.

    class half
    {
        ...
      public:

        union uif
        {
        unsigned int    i;
        float       f;
        };

      private:

        HALF_EXPORT static short                  convert (int i);

        HALF_EXPORT static const uif              _toFloat[1 << 16];
        HALF_EXPORT static const unsigned short   _eLut[1 << 9];
        ...
    };

My system is windows 8 x64. Does anyone know how to fix this problem?

Shen Yang
  • 477
  • 5
  • 10
  • Would seem the method `convert` is implemented in a .cpp file compiled into half.dll, while the variables `_toFloat` and `_eLut` aren't. – Joachim Isaksson May 03 '13 at 09:59
  • I updated question, using dumpbin on half.dll. The symbols are there. And I'm compling ilmimf.dll. I don't think it needs half.dll to compile a library. – Shen Yang May 03 '13 at 10:31
  • 1
    @Shen this is exactly the same error I'm facing with now. I was trying to compile alembic 1.5.8, How did you solve it in the end ? – Shuman Aug 24 '15 at 07:51

2 Answers2

3

You're trying to link against __declspec(dllexport)-ed symbols. This means you need to make sure you're __declspec(dllimport)-ing those symbols in your project file. Specifically to half - there's a #define you can add: OPENEXR_DLL that is being checked for appearance in halfExport.h and will do that for you.

Golan Ross
  • 113
  • 7
0

Step 14 in the following link solved the problem for me:

https://groups.google.com/forum/#!topic/openvdb-forum/-jFJQ2N4BGc

In your project, add OPENEXR_DLL to "Preprocessor Definitions" in "project properties->C/C++->Preprocessor"

Toke Nielsen
  • 129
  • 1
  • 4