Wed 07 Oct 2015 02:17:13 PM UTC, original submission:
I do a CMake build of ilmbase with -DBUILD_SHARED_LIBS=OFF and install to a directory /ilmbase-INSTALL.
Then I configure OpenEXR with the following CMake command:
cmake -DCMAKE_INSTALL_PREFIX=/openexr-INSTALL -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DILMBASE_PACKAGE_PREFIX=/ilmbase-INSTALL -DZLIB_ROOT=/my_zlib_install ..
This will fail to link dwaLookups with the following error message:
/ilmbase-INSTALL/lib/libIlmThread-2_2.a(IlmThreadPosix.cpp.o): In function `IlmThread_2_2::Thread::start()':
IlmThreadPosix.cpp:(.text+0xb4): undefined reference to `Iex_2_2::throwErrnoExc(std::string const&, int)'
/ilmbase-INSTALL/lib/libIlmThread-2_2.a(IlmThreadSemaphorePosix.cpp.o): In function `IlmThread_2_2::Semaphore::Semaphore(unsigned int)':
IlmThreadSemaphorePosix.cpp:(.text+0x72): undefined reference to `Iex_2_2::throwErrnoExc(std::string const&)'
/ilmbase-INSTALL/lib/libIlmThread-2_2.a(IlmThreadSemaphorePosix.cpp.o): In function `IlmThread_2_2::Semaphore::post()':
IlmThreadSemaphorePosix.cpp:(.text+0x16a): undefined reference to `Iex_2_2::throwErrnoExc(std::string const&)'
/ilmbase-INSTALL/lib/libIlmThread-2_2.a(IlmThreadSemaphorePosix.cpp.o): In function `IlmThread_2_2::Semaphore::value() const':
IlmThreadSemaphorePosix.cpp:(.text+0x212): undefined reference to `Iex_2_2::throwErrnoExc(std::string const&)'
collect2: error: ld returned 1 exit status
Inspecting the command line by running VERBOSE=1 make reveals the source of the error:
/usr/local/bin/g++48 -O3 -DNDEBUG CMakeFiles/dwaLookups.dir/dwaLookups.cpp.o -o dwaLookups -L/ilmbase-INSTALL/lib -rdynamic -lHalf -lIex-2_2 -lIlmThread-2_2 -lpthread -Wl,-rpath,/ilmbase-INSTALL/lib
The order in which the ilmbase libraries are specified is wrong. IlmThread depends on symbols from Iex, so they need to be swapped. Changing the command line to
/usr/local/bin/g++48 -O3 -DNDEBUG CMakeFiles/dwaLookups.dir/dwaLookups.cpp.o -o dwaLookups -L/ilmbase-INSTALL/lib -rdynamic -lHalf -lIlmThread-2_2 -lIex-2_2 -lpthread -Wl,-rpath,/ilmbase-INSTALL/lib
makes the error goes away. Once dwaLookups has been built manually this way, calling make again will complete the remaining build without further errors.
Reproduced on a CentOS 5 Linux with gcc 4.8 and CMake 3.3.
|