Changes between Initial Version and Version 1 of Ticket #37389


Ignore:
Timestamp:
Dec 26, 2012, 7:39:33 AM (12 years ago)
Author:
ryandesign (Ryan Carsten Schmidt)
Comment:

So, looking at the files that the toluapp port installs:

$ port -q contents toluapp | xargs otool -L | grep -v "not an object"
/opt/local/bin/toluapp:
	@executable_path/../lib/libtoluapp.dylib (compatibility version 0.0.0, current version 0.0.0)
	/opt/local/lib/liblua.dylib (compatibility version 5.1.0, current version 5.1.4)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
/opt/local/lib/libtoluapp.dylib:
	@executable_path/../lib/libtoluapp.dylib (compatibility version 0.0.0, current version 0.0.0)
	/opt/local/lib/liblua.dylib (compatibility version 5.1.0, current version 5.1.4)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

So the libtoluapp.dylib library will work fine when referenced from the toluapp program, or any other program that is at the same relative directory location from the library. But if it is intended that other non-MacPorts software be able to use this library, then yes, you're right, its install_name should be an absolute path instead, as install_names typically are in MacPorts.

I see this port uses cmake, and I don't understand cmake well. But the relevant portion of the build system seems to be this:

$ grep @executable_path -r work/
work/toluapp-1.0.93/cmake/dist.cmake:  set ( CMAKE_INSTALL_NAME_DIR @executable_path/${UP_DIR}/${INSTALL_LIB}

This is part of a bigger block:

# RPath and relative linking
option ( USE_RPATH "Use relative linking." ON)
if ( USE_RPATH )
  string ( REGEX REPLACE "[^!/]+" ".." UP_DIR ${INSTALL_BIN} )
  set ( CMAKE_SKIP_BUILD_RPATH FALSE CACHE STRING "" FORCE )
  set ( CMAKE_BUILD_WITH_INSTALL_RPATH FALSE CACHE STRING "" FORCE )
  set ( CMAKE_INSTALL_RPATH $ORIGIN/${UP_DIR}/${INSTALL_LIB}
        CACHE STRING "" FORCE )
  set ( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE CACHE STRING "" FORCE )
  set ( CMAKE_INSTALL_NAME_DIR @executable_path/${UP_DIR}/${INSTALL_LIB}
        CACHE STRING "" FORCE )
endif ()

So it appears that if you tell cmake to not "USE_RPATH", then it won't do this undesirable relative path thing that it's doing. I've attached a patch to do this, and verified that it works:

$ port -q contents toluapp | xargs otool -L | grep -v "not an object"
/opt/local/bin/toluapp:
	/opt/local/lib/libtoluapp.dylib (compatibility version 0.0.0, current version 0.0.0)
	/opt/local/lib/liblua.dylib (compatibility version 5.1.0, current version 5.1.4)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
/opt/local/lib/libtoluapp.dylib:
	/opt/local/lib/libtoluapp.dylib (compatibility version 0.0.0, current version 0.0.0)
	/opt/local/lib/liblua.dylib (compatibility version 5.1.0, current version 5.1.4)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

Look good to you? If so I can commit it.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #37389

    • Property Keywords haspatch added; dylib removed
    • Property Cc ryandesign@… added
    • Property Summary changed from Incorrect dylib path to toluapp: Incorrect dylib path
  • Ticket #37389 – Description

    initial v1  
    11It seems that when I made the port I didn't set the dylib link path properly. So after you install the toluapp port, your application will be compiled and linked; but once you attempted to load the executable it produces the following error.
    22
     3{{{
    34BRMP:build brad$ ./stratagus
    45dyld: Library not loaded: @executable_path/../lib/libtoluapp.dylib
     
    67  Reason: image not found
    78Trace/BPT trap: 5
     9}}}
    810
    911From what I read online it is a change I need to make a change in the final link path during the installation of the library. Any suggestions on how I should do that?