Here’s a little report on my progress.

First of all, I added some debug statements to the CMakeLists and confirmed
that the static libraries were correct just before they were passed to
TARGET_LINK_LIBRARIES. The basic problem, I believe, is that cmake ignores
TARGET_LINK_LIBRARIES when the target is a static library. It issues an ar
command the bundles the .o files, but it does not bring in any objects from
other static libraries. The Boost symbols I was seeing were from .hpp files
while those missing were from .a files, because those static libraries were
completely ignored.

So, I decided to change tactics, and instead of creating a static library,
I went about creating a dynamic library that statically links against most
of its dependencies (openexr, ilmbase, jpeg, tiff, png… basically anything
that might conflict with libraries in Maya, Nuke, etc).

This mostly worked.

There is still one major mystery. My new dynamic library is missing symbols
from libIlmThread.a. It’s really baffling. Cmake prints out the link
statement and libIlmThread.a is there along with all the others, but for
some reason it is the only library whose symbols remain undefined in
libOpenImage.so. I should not that all symbols are visible (hiding them
caused an error). So, for now, anything that links against libOpenImage.so
must also link against libIlmThread.a. Any idea what could be causing this?

here’s the cmake command I’m using:

cmake
        -D CMAKE_INSTALL_PREFIX=${REZ_INSTALL_PREFIX}
        -D EMBEDPLUGINS:BOOL=TRUE
        -D CMAKE_BUILD_TYPE=Release
        -D CMAKE_CXX_FLAGS:STRING=-fPIC
        -D CMAKE_EXE_LINKER_FLAGS:STRING=-fPIC
        -D HIDE_SYMBOLS:BOOL=FALSE
        -D BUILD_SHARED_LIBS:BOOL=TRUE
        -D BUILDSTATIC:BOOL=FALSE
        -D LINKSTATIC:BOOL=TRUE
        -D OIIO_BUILD_TOOLS:BOOL=TRUE

        -D Boost_USE_STATIC_LIBS:BOOL=TRUE

        -D TIFF_INCLUDE_DIR=${tiff_INCLUDE_DIRS}
        -D PNG_PNG_INCLUDE_DIR=${png_INCLUDE_DIRS}
        -D JPEG_INCLUDE_DIR=${jpeg_INCLUDE_DIRS}

        -D TIFF_LIBRARY=${tiff_libtiff_STATIC_LIBRARY}
        -D PNG_LIBRARY=${png_libpng15_STATIC_LIBRARY}
        -D JPEG_LIBRARY=${jpeg_libjpeg_STATIC_LIBRARY}

        -D ILMBASE_USE_STATIC_LIBS:BOOL=TRUE
        -D ILMBASE_HOME=${REZ_ILMBASE_ROOT}

        -D OPENEXR_USE_STATIC_LIBS:BOOL=TRUE
        -D OPENEXR_HOME=${REZ_OPENEXR_ROOT}

        -D USE_OCIO:BOOL=FALSE
        -D OCIO_PATH=$ENV{REZ_OPENCOLORIO_ROOT}

        -D USE_PYTHON:BOOL=TRUE
        -D 
Python_ADDITIONAL_VERSIONS=${PYTHON_MAJOR_VERSION}.${PYTHON_MINOR_VERSION}

        -D USE_QT:BOOL=FALSE
        -D USE_OPENCV:BOOL=FALSE
        -D STOP_ON_WARNING:BOOL=FALSE
        -D USE_OPENJPEG:BOOL=FALSE
        -G "Unix Makefiles"
        ${REZ_SOURCE_DIR}

I should mention that in order to link against static versions of ilmbase
and openexr, I had to patch FindIlmBase.cmake and FindOpenEXR.cmake:

--- a/src/cmake/modules/FindIlmBase.cmake    2014-08-12
18:00:59.301710371 -0700+++ b/src/cmake/modules/FindIlmBase.cmake
2014-08-12 17:59:37.461717824 -0700@@ -26,6 +26,15 @@
 include (SelectLibraryConfigurations)

+if( ILMBASE_USE_STATIC_LIBS )+  set(
_ilmbase_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES
${CMAKE_FIND_LIBRARY_SUFFIXES})+  if(WIN32)+
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a
${CMAKE_FIND_LIBRARY_SUFFIXES})+  else()+
set(CMAKE_FIND_LIBRARY_SUFFIXES .a )+  endif()+endif()+
 # Macro to assemble a helper state variable
 macro (SET_STATE_VAR varname)
   set (tmp_ilmbaselibs ${ILMBASE_CUSTOM_LIBRARIES})@@ -233,6 +242,11 @@
   endif ()
 endif ()
+# Restore the original find library ordering+if(
ILMBASE_USE_STATIC_LIBS )+  set(CMAKE_FIND_LIBRARY_SUFFIXES
${_ilmbase_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})+endif()+
 # Unset the helper variables to avoid pollution
 unset (ILMBASE_CURRENT_STATE)
 unset (IlmBase_include_paths)

--- a/src/cmake/modules/FindOpenEXR.cmake    2014-08-12
18:01:03.635815904 -0700+++ b/src/cmake/modules/FindOpenEXR.cmake
2014-08-12 17:59:42.766846975 -0700@@ -26,6 +26,14 @@
 include (FindPackageHandleStandardArgs)
 include (FindPackageMessage)
+if( OPENEXR_USE_STATIC_LIBS )+  set(
_openexr_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES
${CMAKE_FIND_LIBRARY_SUFFIXES})+  if(WIN32)+
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a
${CMAKE_FIND_LIBRARY_SUFFIXES})+  else()+
set(CMAKE_FIND_LIBRARY_SUFFIXES .a )+  endif()+endif()

 # Macro to assemble a helper state variable
 macro (SET_STATE_VAR varname)@@ -218,6 +226,11 @@
   endif ()
 endif ()
+# Restore the original find library ordering+if(
OPENEXR_USE_STATIC_LIBS )+  set(CMAKE_FIND_LIBRARY_SUFFIXES
${_openexr_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})+endif()+
 # Unset the helper variables to avoid pollution
 unset (OPENEXR_CURRENT_STATE)
 unset (OpenEXR_include_paths)

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

Reply via email to