Opened 12 years ago

Closed 12 years ago

#37389 closed defect (fixed)

toluapp: Incorrect dylib path

Reported by: bradc6 (Bradley Clemetson) Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: ports Version: 2.1.2
Keywords: haspatch Cc: ryandesign (Ryan Carsten Schmidt)
Port: toluapp

Description (last modified by ryandesign (Ryan Carsten Schmidt))

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

Attachments (1)

toluapp.diff (511 bytes) - added by ryandesign (Ryan Carsten Schmidt) 12 years ago.
proposed patch

Download all attachments as: .zip

Change History (4)

comment:1 Changed 12 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: ryandesign@… added
Description: modified (diff)
Keywords: haspatch added; dylib removed
Summary: Incorrect dylib pathtoluapp: Incorrect dylib path

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.

Changed 12 years ago by ryandesign (Ryan Carsten Schmidt)

Attachment: toluapp.diff added

proposed patch

comment:2 Changed 12 years ago by bradc6 (Bradley Clemetson)

That has fixed it.

Thank You :)

comment:3 Changed 12 years ago by ryandesign (Ryan Carsten Schmidt)

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.