[QBS] Internal libraries, RPATH and Qt Creator

Jake Petroules jake.petroules at petroules.com
Thu Apr 30 04:48:51 CEST 2015

Hi Christian,

Generally when using rpath you'll want to set it to @loader_path/../lib or @loader_path/../Frameworks on OS X, and $ORIGIN/../lib on Linux. If you install your binaries and libraries in a standard structure like:

- «install-root»/
-- bin/
---- myapp
-- lib/
---- libfoo.so

Then everything should "just work" with `qbs run`. There's even some environment variable magic baked into the cpp module on OS X (and Linux, I think?) so that your applications will run using `qbs run` even if you don't set an rpath.

You mentioned wanting to do this "without installing files" but Qbs has a feature that "installs" your outputs into a subdirectory of your build directory, a process which happens by default. I'm assuming that by "install" you meant at the system level, which is of course not necessary to be able to use `qbs run`. Here's a small sample project demonstrating Qbs installation and the proper use of rpaths:

Just cd to the directory and type `qbs run` -- that's all.

> On Apr 29, 2015, at 5:48 PM, Christian Gagneraud <chgans at gna.org> wrote:
> Hi there,
> I recently decided that it was time for me to give a go at using Qbs 
> (I've been using Qtc w/ qmake from day 1). My project has a typical 
> layout/structure:
> .
> ├── doc
> ├── share
> ├── src
> │   ├── app
> │   ├── libs
> │   └── plugins
> └── tests
> As I didn't really know how to get started, I decided to have a look at 
> Qtc's own Qbs code, and to my surprise, it's quite simple and straight 
> forward.
> So I ended up writing 4 custom items:
> - LedaProduct (common base item)
> - LedaApplication
> - LedaLibrary
> - LedaPlugin
> I'm not using the plugin stuff yet (I haven't written the loader), so 
> for now my plugins are based on LedaLibrary, and the app includes the 
> plugins header, link against the fake plugins and do all the setup 
> "manually".
> Anyway, all build fine, but I'm having problems resolving the library 
> loader path at runtime (using qtcreator).
> I have tried to use "cpp.rpaths: [project.buildDirectory + "/" + 
> project.leda_library_path]" in LedaApplication, but it screws up the 
> linking of my app (there's a -l/fullpath/.socopy/libfoo.so that appears 
> on the command line).
> So my question is how do I set up my Qbs files so that I can run my app 
> (without installing files) using the Qt Creator "run" command? (note: of 
> course I still want too to be able to do a local or system install and 
> run the app from there)
> My question concerns both app/libs dependencies but as well lib/lib and 
> plugin/lib ones too.
> It would be nice if someone could shed some light on this, or point me 
> to an example or documentation.
> Thanks, and long live qbs!
> Krys
> _______________________________________________
> QBS mailing list
> QBS at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qbs

Jake Petroules - jake.petroules at petroules.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qbs/attachments/20150429/0a9d70e5/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sample.zip
Type: application/zip
Size: 1101 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/qbs/attachments/20150429/0a9d70e5/attachment.zip>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qbs/attachments/20150429/0a9d70e5/attachment-0001.html>

More information about the Qbs mailing list