tag:blogger.com,1999:blog-28094011729498956662024-03-13T14:55:44.502+03:00codea-devAlex Mordovinhttp://www.blogger.com/profile/15650498575162680504noreply@blogger.comBlogger1125tag:blogger.com,1999:blog-2809401172949895666.post-71702708929930143352010-12-15T14:02:00.001+03:002010-12-15T14:04:59.050+03:00Qmake, RPATH and evil $ORIGINThis is a quick guide how to deploy a set of private libraries with your Qt application on Linux using RPATH.<br />
<br />
Some will find LD_LIBRARY_PATH variable usefull, but it can become a real pain (e.g, if you need to elevate your process).<br />
<br />
A better and more reliable solution is to tell compiler about libraries locations at link time using -rpath key, like this: <br />
<blockquote>-Wl,-rpath,/some/path/to/lib</blockquote>There is also a way to set a path relative to a location of an executable by using $ORIGIN key-word.<br />
<blockquote>-Wl,-rpath,'$ORIGIN/../mylibs'</blockquote>You might think: "This is perfect!" but problems are not over yet. If you're using qmake pro file to build a project then you need to path $ORIGIN keyword all the way down to compiler arguments through: first qmake pro file processor and then Makefile processor. Use this solution to avoid the string being interpreted at any step.<br />
<blockquote>QMAKE_LFLAGS += '-Wl,-rpath,\'\$$ORIGIN/../mylibs\'' </blockquote>Qmake provides QMAKE_RPATHDIR variable for defining a set of pathes. But it won't work with a path containing $ORIGIN as it will resolve it no matter how far away you hide it. Use QMAKE_LFLAGS instead.Alex Mordovinhttp://www.blogger.com/profile/15650498575162680504noreply@blogger.com0