0

I have to use sftp to upload files when application is started with Run button from QT Creator it works fine.

What I found is that when run on its own application returns error 1 which is CURLE_UNSUPPORTED_PROTOCOL

Checking curl on my osx with curl -V shows that default curl does not list sftp.

However somehow QT creator runs app in some different context which uses curl that has support for sftp, because it uploads files without error.

So question is how do I make it so standalone application uses the same version of dylib as when ran from QT Creator?

JamesWebbTelescopeAlien
  • 3,547
  • 2
  • 30
  • 51
Mateusz
  • 2,287
  • 20
  • 28

1 Answers1

2

OPTION A) change lib path

  • Find the application running by using ps ax | grep <appname>
  • Do otool -L <full-path-of-app>, this will give you dylib your app resolves to
  • Change the dylib in your binary using install_name_tool. Check this answer for more details to point to dylib used by QT creator.

OPTION B) [un]/set RPATH

Another reason your app is using incorrect path could be RPATH on your dylib. You can check RPATH on your dylib using otool -l <full-path-of-your-app>. RPATH tells you the location binary will first pick up libraries from, if it is set in your application you can unset RPATH set by QT creator.

Check man page of dyld to find out how does RPATH work.

For example check RPATH set on Xcode app (your are looking for LC_RPATH field in dylib section).

$ otool -l /Applications/Xcode.app/Contents/MacOS/Xcode 
Load command 22
          cmd LC_RPATH
      cmdsize 48
         path @executable_path/../Frameworks (offset 12)
Load command 23
          cmd LC_RPATH
      cmdsize 56
         path @executable_path/../SharedFrameworks (offset 12)
Load command 24
          cmd LC_RPATH
      cmdsize 40
         path @executable_path/../PlugIns (offset 12)

To unset RPATH use install_name_tool -delete_rpath <RPATH-from-otool-l-output>

QT creator typically uses libraries shipped with its package and on your target system these are typically not present. Better thing to do would be compile curl and ship with your application

JamesWebbTelescopeAlien
  • 3,547
  • 2
  • 30
  • 51
  • Actually still don't know why it was behaving this way, because when inspected application ran by Qt creator was exactly the same I was running by clicking app icon. But pointing to otool and install_name_tool was enough of help so I was able to hack curl into the app that I could deliver. Building statically did not worked because I would have to build curl and its dependencies statically. – Mateusz Sep 14 '17 at 14:15
  • @Mateusz I updated the answer from what I suspect to be your case. – JamesWebbTelescopeAlien Sep 14 '17 at 16:22