PDA

View Full Version : Running QWT Examples in Mac OS X



lynchkp
23rd December 2010, 16:53
Hello everyone,

I'm trying to run the Qwt examples. I've downloaded qwt-6.0.0-rc5 and ran:

qmake -spec macx-g++
make
make install

The compliation had no errors and built all the examples. However, when I go to the examples/bin directory and try opening any of the examples, I get an error "sinusplot cannot be opened because of a problem...". I made no modifications of the qwtconfig.pri file. I am using Mac OS X with the Qt binary SDK.

Any help would be greatly appreciated, I'm not too familiar with the Mac OS X build and linking environment.

lynchkp
24th December 2010, 00:20
Just more information from the Problem Report:

Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000002, 0x0000000000000000
Crashed Thread: 0

Dyld Error Message:
Library not loaded: qwt.framework/Versions/6/qwt
Referenced from: /Users/lynchkp/Desktop/qwt-6.0.0-rc5/examples/bin/radio.app/Contents/MacOS/radio
Reason: image not found

Are the libraries being incorrectly installed?

mariposa
24th December 2010, 02:02
No, they are correctly installed, they should be in /usr/local/qwt-6.0.0-rc5/lib. But this directory is not in your PATH, therefore the library cannot be loaded on startup of the application. One possibilty is to add this directory to your PATH variable, or you make a softlink:

sudo ln -s /usr/local/qwt-6.0.0-rc5/lib/qwt.framework/qwt /usr/lib/qwt

lynchkp
24th December 2010, 05:23
Works like a dream! Thanks so much!

Uwe
24th December 2010, 11:28
One possibilty is to add this directory to your PATH variable ...
AFAIK on the Mac it is the DYLD_LIBRARY_PATH variable, but who knows - I have never seen a Mac myself.

Uwe

lynchkp
25th December 2010, 16:36
Thanks for the help Uwe, I have another question if you dont mind.

I'm having the same trouble as many other people on this forum have mentioned, I'm not very familiar with dynamic libraries (my background is aerospace engineering not computer programming). I've been able to build my programs using the FFTW and ALGLIB libraries just fine by placing their *.h files in /usr/local/include and including them in my programs. Is this also a valid approach with Qwt, where I can move the header files to that directory as well?

I've read a few articles about dynamic linking but I've been more confused after reading them. If you have any pertinent advice or a good website regarding it (man ld didn't provide much insight), I'd greatly appreciate it. Once I get it all working, I'll try to put together a consise writeup so people using OS X can jump into it a bit easier.

Thanks!

mariposa
27th December 2010, 10:55
I am not an expert whith respect to dynamic linking, but as far as I know, it is not a good idea to copy all the include files to /usr/local/include, because you will have to repeat that step each time you update them. You should rather specify the path to the include files of the concerning libraries by adding it to the INCLUDEPATH variable in your .pro file:

INCLUDEPATH *= /path/to/the/headers/of/library1 /path/to/the/headers/of/library2

You probably also will have to tell the linker to link against the library by adding this line:

LIBS += -lgsl\
-lgslcblas

Here I used the GNU Scientific Library (GSL) as an example. The linker options for your libraries will of course differ.

To add the Qwt libraries you can use the "CONFIG" variable in your .pro file:

CONFIG += qwt

Furthermore you have to tell qmake where the .pri file of qwt is:

qmake -set QMAKEFEATURES /usr/local/qwt-6.0.0-rc5/features

These two steps should be sufficient for using qwt.

ypeels
7th November 2012, 22:46
Not sure if I'm making any sloppy mistakes here, but this basic procedure worked for me (Qt 4.7.3, Qwt 6.0.2 svn 1225, examples/curvdemo1), gleaned from http://doc.qt.digia.com/stable/deployment-mac.html.

Step 1: add Qt libraries as "private frameworks"

/Developers/Tools/Qt/macdeployqt examples/bin/curvdemo1.app

Step 2: add qwt to the app bundle (I think the curvdemo1 binary's dependencies get migrated correctly - i.e., you don't have to run install_name_tool on curvdemo1 - but you can always run this before Step 1 to be sure)

cp -R lib/qwt.framework examples/bin/curvdemo1.app/Contents/Frameworks

Step 3: fix qwt's dependencies (determine by using "otool -L" on qwt)


install_name_tool -id @executable_path/../Frameworks/qwt.framework/Versions/6/qwt examples/bin/curvdemo1.app/Contents/Frameworks/qwt.framework/Versions/6/qwt
install_name_tool -change QtSvg.framework/Versions/4/QtSvg @executable_path/../QtSvg.framework/Versions/4/QtSvg examples/bin/curvdemo1.app/Contents/Frameworks/qwt.framework/Versions/6/qwt
# and repeat "install_name_tool -change" line for QtCore and QtGui


Expected result: user can double click on curvdemo1.app without installing anything on a clean computer