2

I'm trying to build an executable which uses Qt as one of its dependencies and gyp as the build tool. My project builds correctly, but whenever I try to run the executable I see this error:

dyld: Library not loaded: @executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore
  Referenced from: /Users/abrarhu/Documents/KRF/build/Pegasus/Pegasus-1.0/RHEL5_64/DEV.STD.PTHREAD/build/bin/mac/./Pegasus
  Reason: image not found
Abort trap: 6

I decided to check which libraries are being used using otool -L, and this was the result:

/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.8)
@executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore (compatibility version 5.4.0, current version 5.4.2)
@executable_path/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.4.0, current version 5.4.2)
@executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui (compatibility version 5.4.0, current version 5.4.2)
@executable_path/../Frameworks/QtMacExtras.framework/Versions/5/QtMacExtras (compatibility version 5.4.0, current version 5.4.2)
@executable_path/../Frameworks/QtMultimedia.framework/Versions/5/QtMultimedia (compatibility version 5.4.0, current version 5.4.2)
@executable_path/../Frameworks/QtMultimediaWidgets.framework/Versions/5/QtMultimediaWidgets (compatibility version 5.4.0, current version 5.4.2) 
... other stuff

I tried using install_name_tool -change in order to change where the libraries are found, but this change is undone if I clean my project. Also, it's not practical because I have to run it on all of the Qt files that refer to each other (e.g., QtMacExtras refers to QtCore). Here are the relevant parts from my gyp file:

'xcode_settings': 
{   
  'VALID_ARCHS': ['i386'],
  'GCC_TREAT_WARNINGS_AS_ERRORS' : 'NO',
  'FRAMEWORK_SEARCH_PATHS': [ '<(kgyp_repo_dir)/dependency/lib/<(target_os)' ],
}, #xcode_settings

'link_settings': 
{   
  'library_dirs': 
  [   
    '<(kgyp_repo_dir)/dependency/lib/<(target_os)',
    '<(kgyp_repo_dir)/dependency/lib/<(target_os)/$(CONFIGURATION)',
  ],  

  ... 
  libraries : [
      'QtCore.framework',
      'QtWidgets.framework',
      ...
  ]

I also tried to set DYLD_LIBRARY_PATH both by exporting it and by including it in my xcode_settings, and neither of those options worked.

I saw this post post that talks about how to tell dyld where to find my libraries, but I don't think it quite works out (I'm confident all of the stuff there would be undone every time I do a clean). I'm looking for a way that I can fix this problem from gyp itself - which is generating all of my Xcode settings.

Community
  • 1
  • 1
abrarisme
  • 495
  • 1
  • 6
  • 14

0 Answers0