One of our internal projects incorporates a static build of OpenImageIO, 
which itself uses a static build of Boost (1.59.0)

In the process of updating 1.5.21 to 1.8.14 I get the build failure below.

The issue appeared to be incorrect ordering of the Boost libraries; 
boost_thread depends on boost_system, and so the order must respect this 
for static links.

I was able to adjust it with the following patch which I am submitting for 
inclusion; though perhaps someone who knows anything about cmake will want 
to review this with suspicion :)

I also noted that this line pre-dates even our previously-working 
OpenImageIO. I assume some additional Boost symbols are now used. 
Unfortunately I have not had time to investigate, but happy to receive any 
further guidance.

Thanks

-- 
Mark


---
We are building static OpenImageIO where constituent libaries are also
static, with the build failure seen below.

At link time, the following command is executed via cmake:

  ... libOpenImageIO_Util.a -Wl,-Bstatic -lboost_filesystem -lboost_system 
-lboost_thread ...

But the ordering is not correct, as boost_thread depends on
boost_system, it must precede it in the list of libraries for static
builds.

Transcript of the build failure, with Boost 1.59.0:

  [ 78%] Linking CXX executable thread_test
  cd 
/net/homes/mhills/scratch/tmp/oiiodist/src/oiio-1.8.14.framestore.1/build/linux64/src/libutil
 && /opt/toolchain-2016.1/bin/cmake -E cmake_link_script 
CMakeFiles/thread_test.dir/link.txt --verbose=1
  /opt/toolchain-2016.1/bin/clang++   -fPIC  -O3 -DNDEBUG   
-L/net/homes/mhills/scratch/tmp/oiiodist/lib64 
CMakeFiles/thread_test.dir/thread_test.cpp.o  -o thread_test -rdynamic 
libOpenImageIO_Util.a -Wl,-Bstatic -lboost_filesystem -lboost_system 
-lboost_thread -lboost_chrono -lboost_date_time -lboost_atomic -Wl,-Bdynamic 
-lrt -ldl -Wl,-Bstatic -lImath -lIex -lHalf -lIlmThread -Wl,-Bdynamic -lpthread
  /net/homes/mhills/scratch/tmp/oiiodist/lib64/libboost_thread.a(thread.o): In 
function `boost::(anonymous namespace)::thread_proxy(void*)':
  libs/thread/src/pthread/thread.cpp:(.text+0x7f5): undefined reference to 
`boost::system::system_category()'
  /net/homes/mhills/scratch/tmp/oiiodist/lib64/libboost_thread.a(thread.o): In 
function `boost::thread::join_noexcept()':
  libs/thread/src/pthread/thread.cpp:(.text+0xc53): undefined reference to 
`boost::system::system_category()'
  /net/homes/mhills/scratch/tmp/oiiodist/lib64/libboost_thread.a(thread.o): In 
function `boost::thread::do_try_join_until_noexcept(timespec const&, bool&)':
  libs/thread/src/pthread/thread.cpp:(.text+0xf4c): undefined reference to 
`boost::system::system_category()'
  /net/homes/mhills/scratch/tmp/oiiodist/lib64/libboost_thread.a(thread.o): In 
function `boost::thread::detach()':
  libs/thread/src/pthread/thread.cpp:(.text+0x1188): undefined reference to 
`boost::system::system_category()'
  /net/homes/mhills/scratch/tmp/oiiodist/lib64/libboost_thread.a(thread.o): In 
function `boost::thread::interrupt()':
  libs/thread/src/pthread/thread.cpp:(.text+0x231c): undefined reference to 
`boost::system::system_category()'
  
/net/homes/mhills/scratch/tmp/oiiodist/lib64/libboost_thread.a(thread.o):libs/thread/src/pthread/thread.cpp:(.text+0x24a8):
 more undefined references to `boost::system::system_category()' follow
  /net/homes/mhills/scratch/tmp/oiiodist/lib64/libboost_thread.a(thread.o): In 
function `_GLOBAL__sub_I_thread.cpp':
  libs/thread/src/pthread/thread.cpp:(.text.startup+0x2): undefined reference 
to `boost::system::generic_category()'
  libs/thread/src/pthread/thread.cpp:(.text.startup+0xe): undefined reference 
to `boost::system::generic_category()'
  libs/thread/src/pthread/thread.cpp:(.text.startup+0x1a): undefined reference 
to `boost::system::system_category()'
  clang-3.7: error: linker command failed with exit code 1 (use -v to see 
invocation)
  make[3]: *** [src/libutil/thread_test] Error 1
  make[3]: Leaving directory 
`/mnt/scratch/mhills/tmp/oiiodist/src/oiio-1.8.14.framestore.1/build/linux64'
  make[2]: *** [src/libutil/CMakeFiles/thread_test.dir/all] Error 2
  make[2]: Leaving directory 
`/mnt/scratch/mhills/tmp/oiiodist/src/oiio-1.8.14.framestore.1/build/linux64'
  make[1]: *** [all] Error 2
  make[1]: Leaving directory 
`/mnt/scratch/mhills/tmp/oiiodist/src/oiio-1.8.14.framestore.1/build/linux64'
  make: *** [cmake] Error 2
---
 src/cmake/externalpackages.cmake |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/cmake/externalpackages.cmake b/src/cmake/externalpackages.cmake
index e69638b..84b97aa 100644
--- a/src/cmake/externalpackages.cmake
+++ b/src/cmake/externalpackages.cmake
@@ -99,7 +99,7 @@ if (BOOST_CUSTOM)
     # N.B. For a custom version, the caller had better set up the variables
     # Boost_VERSION, Boost_INCLUDE_DIRS, Boost_LIBRARY_DIRS, Boost_LIBRARIES.
 else ()
-    set (Boost_COMPONENTS filesystem system thread)
+    set (Boost_COMPONENTS filesystem thread system)
     if (NOT USE_STD_REGEX)
         list (APPEND Boost_COMPONENTS regex)
     endif ()
-- 
1.7.1

_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to