tags:

views:

242

answers:

2

How can I compile and run Qt programs using Qwt on Mac OS X?

I always get an error telling me that it can't find libqwt.dylib. For what I have understood from my googling it won't help to set DYLD_LIBRARY_PATH in environment.plist since Apple has disabled that due to security reasons so how am I supposed to do it (without manually copying the lib to my .app for every recompile)?

I have tried both qmake -spec macx-g++ and qmake without any spec. The lib is in /usr/local/qwt/lib at the moment. Should I move it to some system path manually or is there a better way to do it (by using otool and install_name_tool magics)?

+2  A: 

I think it's bad idea to edit environment.plist or in any other way to change your profile settings to add such "non-standard" path to it.

I assumed you have something like this in you project *.pro file:

INCLUDEPATH += /usr/local/qwt-5.2.0/include

LIBS += -L/usr/local/qwt-5.2.0/lib \
    -lqwt

Or you try to run one of samples where all this additional path are included by:

include( ../examples.pri )

Anyway you get this message at program start:

dyld: Library not loaded: libqwt.5.dylib
Referenced from: /Users/kemiisto/Downloads/qwt-5.2.0/examples/histogram/histogram.app/Contents/MacOS/histogram
Reason: image not found
The program has unexpectedly finished.


Well, you can use solution from this blog post. I have tested it with Qt 4.6 and Qwt 5.2. It works.

After running qmake -spec macx-g++ in qwt sources distribution directory (already done by you), edit src/Makefile. Find the string with

-install_name libqwt.5.dylib

and make it looks like this (change to full path)

-install_name /usr/local/qwt-5.2.0/lib/libqwt.dylib

Now (re)build Qwt (make clean && make) and reinstall it (sudo make install).

kemiisto
A: 

Oki guess i have to do that then :). How come this isn't the default behavior on mac builds?

Buzzzz