[MacPorts] #37389: toluapp: Incorrect dylib path (was: Incorrect dylib path)

MacPorts noreply at macports.org
Tue Dec 25 23:39:33 PST 2012


#37389: toluapp: Incorrect dylib path
-------------------------------+--------------------------------
  Reporter:  brad.clemetson@…  |      Owner:  macports-tickets@…
      Type:  defect            |     Status:  new
  Priority:  Normal            |  Milestone:
 Component:  ports             |    Version:  2.1.2
Resolution:                    |   Keywords:  haspatch
      Port:  toluapp           |
-------------------------------+--------------------------------
Changes (by ryandesign@…):

 * cc: ryandesign@… (added)
 * keywords:  dylib => haspatch


Old description:

> It 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.
>
> BRMP:build brad$ ./stratagus
> dyld: Library not loaded: @executable_path/../lib/libtoluapp.dylib
>   Referenced from: /Users/brad/dev/strata/engine/build/./stratagus
>   Reason: image not found
> Trace/BPT trap: 5
>
> From 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?
> Thank You

New description:

 It 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.

 {{{
 BRMP:build brad$ ./stratagus
 dyld: Library not loaded: @executable_path/../lib/libtoluapp.dylib
   Referenced from: /Users/brad/dev/strata/engine/build/./stratagus
   Reason: image not found
 Trace/BPT trap: 5
 }}}

 From 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?
 Thank You

--

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.

-- 
Ticket URL: <https://trac.macports.org/ticket/37389#comment:1>
MacPorts <http://www.macports.org/>
Ports system for Mac OS


More information about the macports-tickets mailing list