How to tell qmake copy third-party framework to DEST_DIR(.app/Contents/...) on OS X?
-
Hi and welcome to devnet,
Are you trying to deploy your app ? If so you have macdeployqt to help
-
Hi, thanks )
No, I'm not deploying yet (meaning I'm not trying to distribute it or anything, I might have a different understanding of what "deploying" means, English is not my first language).
I'm trying to build and run my app on my machine, so far I've only managed to build it. But I get the above mentioned errors when I try to run it.
In theory, I should add something to the pro file so that some other person on another machine can checkout my git branch, hit build and run and it would work.
So I (presumably) have to tell qmake to copy the CEF framework into my DEST_DIR.
But I can't even run it at this point. -
That or modify the CEF framework with install_name_tool to make it more usable while developing.
-
Right. But that other person would then have to do the same thing, right?
Also, I've found some tips about install_name_tool but I'm not sure how it works, or what it does, rather. -
Yes
install_name_tool, allows you to alter the paths of the dependencies of your application or library. That allows you to embed frameworks/libraries etc. in your bundle and make your application find them. e.g. @executable_path means that the dependency is found in the same folder as the executable.
-
Well, I kind of get it, but I can't get it to run even without playing with install_name_tool, so that's where my confusion comes from.
I built the app, and let's say it's in ../bin/myapp.app
the @executable_path is myapp.app/Contents/MacOS/
After getting that message on trying to run my app, I thought I'd just copy the CEF framework into the Contents/MacOS/ , and so I did.
But I still cannot run it with the same mistake. Is there any reason that could happen?
otool -L myapp gives:
@executable_path/Chromium Embedded Framework (compatibility version 31979.8.123, current version 31979.8.123)
otool -L Chromium\ Embedded\ Framework gives:
@executable_path/Chromium Embedded Framework (compatibility version 31979.8.123, current version 31979.8.123) -
Finally made it work by changing the path to C E F.framework/C E F (did not understand that I have to "go inside .framework" for a while) for myapp.app
Thanks for the help! )
Will try to figure out how to properly do it now. -
Usually macdeployqt would do that for you. You can also write your own script that call install_name_tool
-
Yeap, ended up writing the script for this. Have another question if you don't mind:
The script currently runs when qmake runs (which is not good), I wanted to add it to QMAKE_POST_LINK, and it worked great when I only needed the path to script, but then I had to pass my script an argument so I ended up using the system() function of qmake.
And it didn't work well, was giving me errors, but worked fine when I removed the QMAKE_POST_LINK +=
Anyway, do you have an idea of why something like
QMAKE_POST_LINK += system($$PATH_TO_SCRIPT $$SCRIPTARG)
wouldn't work and leaving onlysystem($$PATH_TO_SCRIPT $$SCRIPTARG)
does?[edit: added coding tags around pro file code SGaist]
-
You should use two $ signs when you want to get the content of a variable
-
Yes, I was doing that, I think when I posted my message the other ones were cut off. So it should work this way? I don't know what might be the problem. $$
-
Ok, just remembered: QMAKE_POST_LINK should contain command(s) for the shell in a similar way you would write in a Makefile. So is your script executable ?
-
Sorry, I'm not big on scripts and the terminology there, it's just a .sh script with a series of commands, like cd [folder] , install_name -change [bla-bla] etc.
To make it executable I should return some value at the end or ..?
The error I get is:
"/bin/sh: -c: line 0: syntax error near unexpected token `"path/to/script"'I also tried QMAKE_POST_LINK += system(sh $$ARG1 $$ARG2) to no avail
-
chmod +x name_of_your_script
to make it executable.QMAKE_POST_LINK += $$quote($$ARG1 $$ARG2)
should do the trick -
Thank you, turned out it could be done like this:
QMAKE_POST_LINK += $SCRIPT_PATH $ARG1 $ARG2
No need for system()