View Issue Details

IDProjectCategoryView StatusLast Update
0002886FreeCADBugpublic2017-03-09 02:24
Reporterblacey Assigned Toblacey  
Status closedResolutionfixed 
PlatformAppleOSmacOSOS VersionAll
Product Version0.17 
Target Version0.17Fixed in Version0.17 
Summary0002886: loads libraries from /usr/local/ if they exist
DescriptionThe "relocatability" of the macOS bundle does not handle RPATHS that are set to the non-relocatable executable /usr/local/ correctly. This results in libraries being loaded from /usr/local/ if they exist and superseding libraries within the loader path causing unexpected results and crashes.
Steps To Reproduce1. Download the FreeCAD Qt5 build and install in /usr/local
2. Download the FreeCAD Qt4 build and place somewhere else
3. Launch the FreeCAD Qt4 app using the following:


4. This will cause a crash due to an unexpected executable
5. Use the following command to remove the invalid RPATH from the main executable

install_name_tool -delete_rpath '/usr/local/' FreeCAD

6. Launch again the following command:


7. Note that the app launches but it loads libraries from /usr/local/
8. Dump the RPATHS using the following command:

find <path>/ -name '*.dylib' -exec otool -l {} \; | grep -A3 RPATH | grep path | grep '/usr/local/FreeCAD'

9. Note that there are 9 occurrences of an RPATH pointing to the non-relocatable image /usr/local/ Offending libraries:

FreeCAD Information



2017-02-19 01:45

developer   ~0008354

The scope of this fix entails the following:

1. Remove existing LC_RPATHS from dependent libraries before adding new LC_RPATHS because the old paths point to the original /usr/local location and take precedence over the new paths because the new are added after the existing
2. After copying an external library into the bundle, change the LC_ID_DYLIB to a bundle-local name (i.e. replace the absolute path name)


2017-02-19 07:02

developer   ~0008360

I have implemented the aforementioned changes and added diagnostic information to the script using the python logging module. This will enable other developers to understand what the script does more quickly in case anyone needs make changes in the future. I will submit the changes in a PR once my Travis test build completes.


2017-02-19 14:39

administrator   ~0008367

Committed in FreeCAD master b52b94ae
(Resolving manually as MantisBT source-integration is not functioning correctly ATM.

Related Changesets

FreeCAD: master b52b94ae

2017-02-19 03:16:12


Details Diff
Packaging: Set macOS dynamic loader paths

* DYLD paths are set properly to prevent loading libraries external
to the bundle
a. LC_ID_DYLD is set to the basename of the library name (i.e.
not the absolute path) when it is copied into the bundle
b. Existing LC_RPATH entries in libraries are removed before adding
the bundle-relative RPATH
* Added configurable diagnostic logging to aid in debugging

Fixes 0002886
Affected Issues
mod - src/Tools/ Diff File
mod - CMakeLists.txt Diff File

Issue History

Date Modified Username Field Change
2017-02-03 00:05 blacey New Issue
2017-02-03 00:06 Kunda1 Tag Attached: MacOSX
2017-02-19 01:43 blacey Assigned To => blacey
2017-02-19 01:43 blacey Status new => assigned
2017-02-19 01:45 blacey Note Added: 0008354
2017-02-19 07:02 blacey Note Added: 0008360
2017-02-19 14:39 Kunda1 Status assigned => resolved
2017-02-19 14:39 Kunda1 Resolution open => fixed
2017-02-19 14:39 Kunda1 Fixed in Version => 0.17
2017-02-19 14:39 Kunda1 Note Added: 0008367
2017-03-09 02:24 Kunda1 Changeset attached => FreeCAD master b52b94ae
2017-03-09 02:24 Kunda1 Status resolved => closed
2020-11-13 14:08 Kunda1 Tag Renamed MacOSX => macOS