SerialPlot

SerialPlot – a Qt adventure on OS X

TL;DR

To save yourself a lot of pain, the pain that I went through, just read Compiling Qt SerialPlot (for OS X), which is a compact summary and HOW-TO of the details below.


Preamble

This is probably going to be one of those projects that never ever gets properly finished, but that teaches a lot along the way. [Edit – I managed to actually finish it!]

First some background: Whilst following Paul McWhorter’s IMU BNO055 course, I had a requirement for a serial plotter application, one that was better than the paltry offering built into the Arduino IDE (it autoscales too much and isn’t particularly configurable). In the video course, SerialPlot (/serialplot) is used, a nicely functional Qt based Windows and Linux application, but there is no OS X port (typical!). [Edit – there is now an OS X port, /serialplot_OS_X_port. See also Porting serialplot to OS X]

I had previously found (/RealtimePlotter), which is a nice Processing based plotter but… well, maybe I was being overly fussy, but I really wanted a native application.

Now, porting the fully functional SerialPlot from Linux to OS X could be a direction to go, but… meh…

Then, after more searching, I found a Github repository for another serial plotter, confusingly with the same name, /SerialPlot, for OSX that is also, ironically, Qt based. However, the last commit was in 2011, so it is not being actively maintained.

Knowing nothing about Qt, I thought I’d have a go at getting /SerialPlot working… on an old 2010 MBP running High Sierra (10.13.6), with Xcode 9.4.

WIP Status

Project builds and application is created. Frameworks bundled.

See also

Links

Required software

Stack Exchange links

Installing

Building/Linking

Additional Stack Exchange links

Additional links

Wikipedia

Errata

  • I incorrectly refer to the .o file (qextserialport.o) as a static library, when of course it is an object file.

Development Environment

Bearing in mind that the last commit was 2011 and looking at Wikipedia articles for Xcode and OS X:

  • Likewise Xcode 4.2 was released Oct 2011, so either Xcode 3.2.6 or 4.0 (most likely as released June 2010) through to 4.2 was probably used,
  • Running on OS X Leopard (10.5) or Snow Leopard (10.6) (most likely as released on August 28, 2009) to Lion (released July 20 2011) (10.8.5)

I have no idea if Xcode is actually required. The command line tools fo Xcode are almost certainly required.

Versions of supporting software

  • From Sourceforge – qwt, it is worth bearing in mind that 2014-10-09, two years after the last commit to SerialPlot, the current version of qwt was version 0.2h. So, this might account for some of the issues seen later, during the build, as version 6.0.1 and 6.2.0 were used…  compatibility issues?

However, from https://qwt.sourceforge.io/#installonmainpage:

Platforms

Qwt 6.2 might be usable in all environments where you find Qt. It is compatible with Qt 4.8 and all Qt5 versions.

and under Downloads

Active development will happen in the develop branch supporting Qt >= 5.6 and relying on at least C++11. However all versions >= Qt 4.8 will actively be supported in the 6.x branches.

First of all

A little housekeeping is required:

  1. Create a directory ~/Qt-code to place the Qt source/projects into.
  2. Move the SerialPlot-master into ~/Qt-code.

Initial Qt investigation

What software and which version

Starting at Qt for macOS, it became clear that the current Qt5 probably wasn’t going to run, on my MBP, because even though 10.13 is supported, Xcode 9.4 is not (11 being the minimum), and 9.4 is the last version that will run on 10.13.6 (so that is a bit of a weird disparity):

Qt5 Dev reqs

Also, from Getting Started with Qt, Qt5 looks a right pain in the arse to install, let alone use. Licenses, and login accounts are required, for online/offline installation. Man, these folks are full of themselves… Building from source seems even more fun… see Qt for macOS – Building from Source.

So… what was the current/contemporary version of Qt, back in 2010/2011? From History of Qt, it appears that it would have been 4.5. Qt5 wasn’t released until 19 December 2012.

Downloading and opening QtCreator

Ok, so Qt4.5 is available here: https://download.qt.io/official_releases/qtcreator/4.5/4.5.0/

I downloaded and installed qt-creator-opensource-mac-x86_64-4.5.0.dmg

To my amazement, it actually ran on High Sierra, and I was able to open the project. However, in the Configure Project dialog, I got a message stating “No valid kits found”:

Qt4.5 Creator - No valid kits found

Finding qt library

Stack Overflow:

This didn’t work

brew install qt4.5

this was more useful

$ brew install qt4
Warning: No available formula or cask with the name "qt4". Did you mean qt or qt@5?
==> Searching for similarly named formulae...
These similarly named formulae were found:
qt ✔                                     qt@5 ✔
To install one of them, run (for example):
  brew install qt ✔
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching taps on GitHub...
Error: No formulae found in taps.
$

From this answer to How to install qt4 with home-brew:

brew tap cartr/qt4
brew tap-pin cartr/qt4
brew install qt@4

So…

$ brew tap cartr/qt4
Updating Homebrew...
==> Tapping cartr/qt4
Cloning into '/usr/local/Homebrew/Library/Taps/cartr/homebrew-qt4'...
remote: Enumerating objects: 462, done.
remote: Counting objects: 100% (63/63), done.
remote: Compressing objects: 100% (53/53), done.
remote: Total 462 (delta 24), reused 21 (delta 10), pack-reused 399
Receiving objects: 100% (462/462), 140.17 KiB | 322.00 KiB/s, done.
Resolving deltas: 100% (276/276), done.
Tapped 23 formulae (42 files, 222.9KB).
$ brew tap-pin cartr/qt4
Error: Unknown command: tap-pin
$

Hmmm… it didn’t like tap-pin… Nevertheless, soldiering on regardless…

$ brew install qt@4
Warning: You are using macOS 10.13.
We (and Apple) do not provide support for this old version.
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Twitter or any other official channels. You are responsible for resolving
any issues you experience while you are running this
old version.

==> Installing qt@4 from cartr/qt4
==> Downloading https://github.com/cartr/homebrew-qt4-bottles/releases/download/
==> Downloading from https://github-releases.githubusercontent.com/357806838/9c9
######################################################################## 100.0%
==> Downloading https://github.com/cartr/homebrew-qt4-bottles/releases/download/
==> Downloading from https://github-releases.githubusercontent.com/357806838/1ed
######################################################################## 100.0%
==> Installing dependencies for cartr/qt4/qt@4: openssl@1.0
==> Installing cartr/qt4/qt@4 dependency: openssl@1.0
==> Pouring openssl
🍺  /usr/local/Cellar/openssl@1.0/1.0.2t: 1,796 files, 12.4MB
==> Installing cartr/qt4/qt@4
==> Pouring qt
==> Caveats
          We agreed to the Qt opensource license for you.
          If this is unacceptable you should uninstall.
      
          Phonon is not supported on macOS Sierra or with Xcode 8.
          
          WebKit is no longer included for security reasons. If you absolutely
          need it, it can be installed with `brew install qt-webkit@2.3`.
==> Summary
🍺  /usr/local/Cellar/qt@4/4.8.7_6: 2,971 files, 80.6MB

Then it went on a mad clean up…

==> `brew cleanup` has not been run in 30 days, running now...
Removing: /Users/macbook/Library/Caches/Homebrew/atkmm@2.28--2.28.1.tar.xz... (672.8KB)

...

Removing: /Users/macbook/Library/Logs/Homebrew/zstd... (6 files, 357KB)
Pruned 2 symbolic links and 55 directories from /usr/local
==> No outdated dependents to upgrade!
==> Checking for dependents of upgraded formulae...
==> Reinstalling 1 broken dependent from source:
cartr/qt4/qt@4
==> Caveats
==> qt@4
          We agreed to the Qt opensource license for you.
          If this is unacceptable you should uninstall.
      
          Phonon is not supported on macOS Sierra or with Xcode 8.
          
          WebKit is no longer included for security reasons. If you absolutely
          need it, it can be installed with `brew install qt-webkit@2.3`.
$

However, the qt4 install seemed successful. There is another answer (to How to install qt4 with home-brew), which I didn’t try:

brew install cartr/qt4/pyqt@4

Time for a rest, before the qmake paths have to be tackled (which is alluded to in Get Qt5 up and running on a new Mac).

qmake paths

Now we need to get QtCreator to see the qt library.

Click the options link, and in the Build & Run options dialog, of QtCreator, on the Qt versions tab, hit Cmd+shift+G and enter /usr/local/Cellar/qt@4/4.8.7_6, which (for some reason) became /usr/local/Cellar/qt@4/4.8.7_6_reinstall. Then in bin select qmake.

The Qt 4.5 library is then detected, although I got a “ABI detection failed: Make sure to use a matching compiler when building” warning, plus “No qmlviewer installed”.

Regardless, then in the Kits tab, now select under the popup menu for Qt version the newly installed Qt.

Then hit OK.

Then back in the Configure Project dialog, check the Desktop checkbox and click the Configure Project button.

The project window then opens up! However, there are a number of warnings/errors:

Could not find qmake spec 'default'.
Error while parsing file /Users/macbook/Qt-code/SerialPlot-master (OSX)/SerialPlot.pro. Giving up.
Cannot read /usr/local/etc/qt4/mkspecs/default/qmake.conf: No such file or directory
Could not read qmake configuration file /usr/local/etc/qt4/mkspecs/default/qmake.conf.
Could not find qmake spec 'default'.
Error while parsing file /Users/macbook/Qt-code/SerialPlot-master (OSX)/SerialPlot.pro. Giving up.

You are able to browse the project, even though only the .pro file is shown – there is no sign of the .cpp or .h files.

Tackling the qmake.conf errors:

  • A link is required from /usr/local/etc/qt4 to /usr/local/Cellar/qt@4/4.8.7_6_reinstall/etc/qt4.
  • For completeness, but not strictly required, my etc/qt4/mkspecs/default pointed to etc/qt4/mkspecs/macx-clang-libc++.
ln -s /usr/local/Cellar/qt@4/4.8.7_6_reinstall/etc/qt4 /usr/local/etc/qt4

Closing the project, and QtCreator, and then reopening, I got less errors

Cannot read /usr/local/etc/qt4/mkspecs/default/qmake.conf: No such file or directory
Could not read qmake configuration file /usr/local/etc/qt4/mkspecs/default/qmake.conf.
Could not find qmake spec 'default'.
Error while parsing file /Users/macbook/Qt-code/SerialPlot-master (OSX)/SerialPlot.pro. Giving up.

After re-checking the linked path in the terminal, and then actually linking the path correctly, that is to say using .reinstall and not _reinstall:

ln -s /usr/local/Cellar/qt@4/4.8.7_6.reinstall/etc/qt4 /usr/local/etc/qt4

caused a triumph…

Qt4.5 Creator - Project window - Success

Now all of the files are visible. Finally!

Side note: Looking at the Forms (i.e the Windows/GUI), in the project, the UI seemed pretty tidy at first glance.

Attempting a build

Trying to hit run, I then got

:-1: error: [ui_mainwindow.h] Error 2

This ui_mainwindow.h file is autogenerated, from the mainwindow.ui file. See ‘ui_mainwindow.h’ file not found. However, after checking the directory (as well as the downloaded  and unzipped master zip from Github), there already is a ui_mainwindow.h file.

Checking the “error 2”, see Recieving [main.o] error 2 in Qt creator. However, I could see no errors in the .pro file.


Side note

As an aside, whilst browsing the SerialPlot.pro file I saw in the INCLUDEPATH and DEPENDPATH as well as the CONFIG conditional for qwt

qwt-6.0.1

Would there be a version mismatch with Qt4? From this answer to Install Qt library(qwt-6.0.1) in windows 7:

Qwt from SVN trunk ( aka 6.1 ) works with Qt 4 and 5.


This error 2 is also seen on Qt5, from [ui_MainWindow.h] Error 2 #4, so it hopefully isn’t related to the qt4.5 that I’m using.

The full output of the error is, after right clicking the message and selecting “Show Output”:

00:42:43: Running steps for project SerialPlot...
00:42:43: Configuration unchanged, skipping qmake step.
00:42:43: Starting: "/usr/bin/make" 
/usr/local/bin/uic ../SerialPlot-master\ (OSX)/mainwindow.ui -o ui_mainwindow.h
/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `/usr/local/bin/uic ../SerialPlot-master\ (OSX)/mainwindow.ui -o ui_mainwindow.h'
make: *** [ui_mainwindow.h] Error 2
00:42:43: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project SerialPlot (kit: Desktop)
When executing step "Make"
00:42:43: Elapsed time: 00:00.

Note the line

/bin/sh: -c: line 0: syntax error near unexpected token `('

After a red herring of Error in shell script, and then noticing the path in the line below ../SerialPlot-mater\ (OSX)/mainwindow.ui, I thought that it could possibly be due to the directory name SerialPlot-master (OSX), so I changed the directory name to SerialPlot. [Note: I had added the (OSX) myself, in order to differentiate the directory for the OSX application from the Windows/Linux application of the same name].

That seemed to fix it, and then after closing and reopening QtCreator, and reopening the project (by selecting the .pro file), then running, I then got:

:-1: error: /usr/local/bin/uic: No such file or directory

in full (via right clicking and selecting Show Output):

01:10:19: Running steps for project SerialPlot...
01:10:19: Starting: "/usr/local/Cellar/qt@4/4.8.7_6.reinstall/bin/qmake" /Users/macbook/Qt-code/SerialPlot/SerialPlot.pro -r -spec macx-g++ CONFIG+=debug CONFIG+=x86_64
01:10:19: The process "/usr/local/Cellar/qt@4/4.8.7_6.reinstall/bin/qmake" exited normally.
01:10:19: Starting: "/usr/bin/make" 
/usr/local/bin/uic ../SerialPlot/mainwindow.ui -o ui_mainwindow.h
make: /usr/local/bin/uic: No such file or directory
make: *** [ui_mainwindow.h] Error 1
01:10:19: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project SerialPlot (kit: Desktop)
When executing step "Make"
01:10:19: Elapsed time: 00:01.

Fixing this with

ln -s /usr/local/Cellar/qt@4/4.8.7_6.reinstall/bin/uic /usr/local/bin/uic

Then re-running, a new error:

/Users/macbook/Qt-code/SerialPlot/main.cpp:1: error: 'QtGui/QApplication' file not found

in full:

01:15:54: Running steps for project SerialPlot...
01:15:54: Configuration unchanged, skipping qmake step.
01:15:54: Starting: "/usr/bin/make" 
g++ -c -pipe -g -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/etc/qt4/mkspecs/macx-g++ -I../SerialPlot -I/usr/local/include/QtCore -I/usr/local/include/QtGui -I/usr/local/include -I/Users/macbook/Qt-code/SerialPlot/../qwt-6.0.1/src -I/Users/macbook/Qt-code/SerialPlot/../qextserialport/src -I. -I. -I../SerialPlot -I. -F/usr/local/lib -o main.o ../SerialPlot/main.cpp
../SerialPlot/main.cpp:1:10: fatal error: 'QtGui/QApplication' file not found
#include <QtGui/QApplication>
         ^~~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [main.o] Error 1
01:15:54: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project SerialPlot (kit: Desktop)
When executing step "Make"
01:15:54: Elapsed time: 00:00.

So,  after reading this, fatal error: QtGui/QApplication: No such file or directory, and thinking that the path was still missing something, I went fishing around into the project settings and added

/usr/local/Cellar/qt@4/4.8.7_6.reinstall/bin

to the PATH:

Qt4.5 Creator - Build environment - PATH

I should have just done this at the very beginning, instead of the symlinks.

However, upon hitting run, the issue persisted… Time for a break!

The issue is this line, in main.cpp

#include <QtGui/QApplication>

which is in

/usr/local/Cellar/qt@4/4.8.7_6.reinstall/include/QtGui/QApplication

which suggests that the library paths are incorrect. Delving into the project settings again, it would seem that most (if not all) of these paths need changing:

Qt4.5 Creator - Desktop environment - more paths

QT_INSTALL_HEADERS looks like a good candidate. However, clicking on the link merely opens the directory in the Finder. I couldn’t find a way to edit them, see Patch Qmake to use specifics ( and relative) paths, so I added a symlink in /usr/local/include for QtGui:

ln -s /usr/local/Cellar/qt@4/4.8.7_6.reinstall/include/QtGui /usr/local/include/QtGui

Also for QtCore

ln -s /usr/local/Cellar/qt@4/4.8.7_6.reinstall/include/QtCore /usr/local/include/QtCore

Then I got

/Users/macbook/Qt-code/SerialPlot/mainwindow.h:5: error: 'qextserialport.h' file not found

In full

02:14:25: Running steps for project SerialPlot...
02:14:25: Configuration unchanged, skipping qmake step.
02:14:25: Starting: "/usr/bin/make" 
g++ -c -pipe -g -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/etc/qt4/mkspecs/macx-g++ -I../SerialPlot -I/usr/local/include/QtCore -I/usr/local/include/QtGui -I/usr/local/include -I/Users/macbook/Qt-code/SerialPlot/../qwt-6.0.1/src -I/Users/macbook/Qt-code/SerialPlot/../qextserialport/src -I. -I. -I../SerialPlot -I. -F/usr/local/lib -o main.o ../SerialPlot/main.cpp
In file included from ../SerialPlot/main.cpp:2:
../SerialPlot/mainwindow.h:5:10: fatal error: 'qextserialport.h' file not found
#include 
         ^~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [main.o] Error 1
02:14:27: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project SerialPlot (kit: Desktop)
When executing step "Make"
02:14:27: Elapsed time: 00:02.

I couldn’t find qextserialport.h on the file system and it would seem to be an additional package, from /qextserialport. Unzip the ZIP file, remove the -master from the directory name, and place (as a sibling directory) in the parent directory that contains the SerialPlot directory, for example:

~/qt-code
~/qt-code/SerialPlot
~/qt-code/qextserialport

This can be seen in the SerialPlot.pro file:

INCLUDEPATH += $$PWD/../qextserialport/src
DEPENDPATH += $$PWD/../qextserialport/src

Then qwt_plot.h error:

/Users/macbook/Qt-code/SerialPlot/PlotWindow.h:6: error: 'qwt/qwt_plot.h' file not found

In full

02:26:13: Running steps for project SerialPlot...
02:26:13: Configuration unchanged, skipping qmake step.
02:26:13: Starting: "/usr/bin/make" 
g++ -c -pipe -g -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/etc/qt4/mkspecs/macx-g++ -I../SerialPlot -I/usr/local/include/QtCore -I/usr/local/include/QtGui -I/usr/local/include -I/Users/macbook/Qt-code/SerialPlot/../qwt-6.0.1/src -I/Users/macbook/Qt-code/SerialPlot/../qextserialport/src -I. -I. -I../SerialPlot -I. -F/usr/local/lib -o main.o ../SerialPlot/main.cpp
In file included from ../SerialPlot/main.cpp:2:
In file included from ../SerialPlot/mainwindow.h:6:
../SerialPlot/PlotWindow.h:6:10: fatal error: 'qwt/qwt_plot.h' file not found
#include <qwt/qwt_plot.h>
         ^~~~~~~~~~~~~~~~
1 error generated.
make: *** [main.o] Error 1
02:26:16: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project SerialPlot (kit: Desktop)
When executing step "Make"
02:26:16: Elapsed time: 00:03.

Again, looking in the .pro file

INCLUDEPATH += $$PWD/../qwt-6.0.1/src
DEPENDPATH += $$PWD/../qwt-6.0.1/src

So another package is also required: qwt-6.0.1.

qwt-6.0.1 is available from https://sourceforge.net/projects/qwt/files/qwt/6.0.1/

Unzip and place in the parent directory, as was done with the qextserialport directory.

~/qt-code 
~/qt-code/SerialPlot 
~/qt-code/qextserialport
~/qt-code/qwt-6.0.1

However, the error will still persist, due to the qwt/qwt_plot.h include line in ../SerialPlot/PlotWindow.h.

To actually get past this issue, without having to change any code, it is necessary to create a qwt directory inside the src directory and copy all of the files in the src to the new src/qwt directory.

~/qt-code/qwt-6.0.1/*
~/qt-code/qwt-6.0.1/qwt
~/qt-code/qwt-6.0.1/qwt/*

Or in other words

Create:
~/qt-code/qwt-6.0.1/qwt
and move:
~/qt-code/qwt-6.0.1/*
to
~/qt-code/qwt-6.0.1/qwt/*

Then the next error:

:-1: error: /usr/local/bin/moc: No such file or directory

in full

02:35:41: Running steps for project SerialPlot...
02:35:41: Configuration unchanged, skipping qmake step.
02:35:41: Starting: "/usr/bin/make" 
g++ -c -pipe -g -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/etc/qt4/mkspecs/macx-g++ -I../SerialPlot -I/usr/local/include/QtCore -I/usr/local/include/QtGui -I/usr/local/include -I/Users/macbook/Qt-code/SerialPlot/../qwt-6.0.1/src -I/Users/macbook/Qt-code/SerialPlot/../qextserialport/src -I. -I. -I../SerialPlot -I. -F/usr/local/lib -o main.o ../SerialPlot/main.cpp
g++ -c -pipe -g -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/etc/qt4/mkspecs/macx-g++ -I../SerialPlot -I/usr/local/include/QtCore -I/usr/local/include/QtGui -I/usr/local/include -I/Users/macbook/Qt-code/SerialPlot/../qwt-6.0.1/src -I/Users/macbook/Qt-code/SerialPlot/../qextserialport/src -I. -I. -I../SerialPlot -I. -F/usr/local/lib -o mainwindow.o ../SerialPlot/mainwindow.cpp
g++ -c -pipe -g -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/etc/qt4/mkspecs/macx-g++ -I../SerialPlot -I/usr/local/include/QtCore -I/usr/local/include/QtGui -I/usr/local/include -I/Users/macbook/Qt-code/SerialPlot/../qwt-6.0.1/src -I/Users/macbook/Qt-code/SerialPlot/../qextserialport/src -I. -I. -I../SerialPlot -I. -F/usr/local/lib -o SensorCurve.o ../SerialPlot/SensorCurve.cpp
g++ -c -pipe -g -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/etc/qt4/mkspecs/macx-g++ -I../SerialPlot -I/usr/local/include/QtCore -I/usr/local/include/QtGui -I/usr/local/include -I/Users/macbook/Qt-code/SerialPlot/../qwt-6.0.1/src -I/Users/macbook/Qt-code/SerialPlot/../qextserialport/src -I. -I. -I../SerialPlot -I. -F/usr/local/lib -o SensorData.o ../SerialPlot/SensorData.cpp
g++ -c -pipe -g -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/etc/qt4/mkspecs/macx-g++ -I../SerialPlot -I/usr/local/include/QtCore -I/usr/local/include/QtGui -I/usr/local/include -I/Users/macbook/Qt-code/SerialPlot/../qwt-6.0.1/src -I/Users/macbook/Qt-code/SerialPlot/../qextserialport/src -I. -I. -I../SerialPlot -I. -F/usr/local/lib -o DynamicParam.o ../SerialPlot/DynamicParam.cpp
g++ -c -pipe -g -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/etc/qt4/mkspecs/macx-g++ -I../SerialPlot -I/usr/local/include/QtCore -I/usr/local/include/QtGui -I/usr/local/include -I/Users/macbook/Qt-code/SerialPlot/../qwt-6.0.1/src -I/Users/macbook/Qt-code/SerialPlot/../qextserialport/src -I. -I. -I../SerialPlot -I. -F/usr/local/lib -o serialSelectDialog.o ../SerialPlot/serialSelectDialog.cpp
../SerialPlot/serialSelectDialog.cpp:31:52: warning: unused parameter 'index' [-Wunused-parameter]
void SerialSelectDialog::doubleClicked(QModelIndex index)
                                                   ^
1 warning generated.
g++ -c -pipe -g -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/etc/qt4/mkspecs/macx-g++ -I../SerialPlot -I/usr/local/include/QtCore -I/usr/local/include/QtGui -I/usr/local/include -I/Users/macbook/Qt-code/SerialPlot/../qwt-6.0.1/src -I/Users/macbook/Qt-code/SerialPlot/../qextserialport/src -I. -I. -I../SerialPlot -I. -F/usr/local/lib -o PlotWindow.o ../SerialPlot/PlotWindow.cpp
g++ -c -pipe -g -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/etc/qt4/mkspecs/macx-g++ -I../SerialPlot -I/usr/local/include/QtCore -I/usr/local/include/QtGui -I/usr/local/include -I/Users/macbook/Qt-code/SerialPlot/../qwt-6.0.1/src -I/Users/macbook/Qt-code/SerialPlot/../qextserialport/src -I. -I. -I../SerialPlot -I. -F/usr/local/lib -o ParamWindow.o ../SerialPlot/ParamWindow.cpp
g++ -c -pipe -g -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/etc/qt4/mkspecs/macx-g++ -I../SerialPlot -I/usr/local/include/QtCore -I/usr/local/include/QtGui -I/usr/local/include -I/Users/macbook/Qt-code/SerialPlot/../qwt-6.0.1/src -I/Users/macbook/Qt-code/SerialPlot/../qextserialport/src -I. -I. -I../SerialPlot -I. -F/usr/local/lib -o LogWindow.o ../SerialPlot/LogWindow.cpp
/usr/local/bin/moc -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/etc/qt4/mkspecs/macx-g++ -I../SerialPlot -I/usr/local/include/QtCore -I/usr/local/include/QtGui -I/usr/local/include -I/Users/macbook/Qt-code/SerialPlot/../qwt-6.0.1/src -I/Users/macbook/Qt-code/SerialPlot/../qextserialport/src -I. -I. -I../SerialPlot -I. -F/usr/local/lib -D__APPLE__ -D__GNUC__ ../SerialPlot/mainwindow.h -o moc_mainwindow.cpp
make: /usr/local/bin/moc: No such file or directory
make: *** [moc_mainwindow.cpp] Error 1
02:35:50: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project SerialPlot (kit: Desktop)
When executing step "Make"
02:35:50: Elapsed time: 00:09.

Easily fixed, as was the uic issue by a symlink:

ln -s /usr/local/Cellar/qt@4/4.8.7_6.reinstall/bin/moc /usr/local/bin/moc

Next error, after some substantial compiling time,

:-1: error: framework not found qwt

So install it

brew install qwt

(Will this never end?)

$ brew install qwt
Updating Homebrew...
==> Auto-updated Homebrew!
Updated Homebrew from 4cf282094 to 5ec335188.
Updated 3 taps (caskroom/cask, homebrew/cask and homebrew/core).
==> Updated Formulae
Updated 14 formulae.
==> Updated Casks
Updated 6 casks.

Warning: You are using macOS 10.13.
We (and Apple) do not provide support for this old version.
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Twitter or any other official channels. You are responsible for resolving
any issues you experience while you are running this
old version.

==> Downloading https://downloads.sourceforge.net/project/qwt/qwt/6.1.6/qwt-6.1.
==> Downloading from https://jaist.dl.sourceforge.net/project/qwt/qwt/6.1.6/qwt-
######################################################################## 100.0%
Warning: Your Xcode (9.4.1) is outdated.
Please update to Xcode 10.1 (or delete it).
Xcode can be updated from the App Store.

==> Patching
==> /usr/local/opt/qt@5/bin/qmake -config release -spec macx-clang
==> make
==> make install
🍺  /usr/local/Cellar/qwt/6.1.6_1: 1,666 files, 18.7MB, built in 2 minutes 35 seconds
$

That worked.

Finally, a number of (what seem to be) linker errors:

clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
ld: warning: directory not found for option '-L/Users/macbook/Qt-code/SerialPlot/../qextserialport/src/build/'
ld: warning: directory not found for option '-F/Users/macbook/Qt-code/SerialPlot/../qwt-6.0.1/lib/'
ld: library not found for -lqextserialport
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [SerialPlot.app/Contents/MacOS/SerialPlot] Error 1
02:51:41: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project SerialPlot (kit: Desktop)
When executing step "Make"

So it seems like a link is required from /usr/local/Cellar/qwt/6.1.6_1/lib to /Users/macbook/Qt-code/SerialPlot/../qwt-6.0.1/lib

ln -s /usr/local/Cellar/qwt/6.1.6_1/lib /Users/macbook/Qt-code/qwt-6.0.1/lib

and…

for some reason qextserialport/src/build doesn’t exist, which should contain the qextserialport library… according to these lines in the .pro file:

win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../qextserialport/src/build/ -lqextserialport
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../qextserialport/src/build/ -lqextserialportd
else:unix:!symbian: LIBS += -L$$PWD/../qextserialport/src/build/ -lqextserialport

Building qextserialport manually – in a terminal

However, trying to build qextserialport manually:

$ /usr/local/Cellar/qt@4/4.8.7_6.reinstall/bin/qmake
$ make
/Library/Developer/CommandLineTools/usr/bin/make -f Makefile.Release all
/usr/local/bin/moc -DQEXTSERIALPORT_BUILD_SHARED -DQT_NO_DEBUG -DQT_CORE_LIB -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/etc/qt4/mkspecs/unsupported/macx-clang-libc++ -I. -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtCore.framework/Versions/4/Headers -I/usr/local/include -Isrc -Irelease -F/usr/local/lib -D__APPLE__ -D__GNUC__ src/qextserialport.h -o release/moc_qextserialport.cpp
clang++ -c -pipe -stdlib=libc++ -mmacosx-version-min=10.7 -O2 -arch x86_64 -Wall -W -fPIC -DQEXTSERIALPORT_BUILD_SHARED -DQT_NO_DEBUG -DQT_CORE_LIB -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/etc/qt4/mkspecs/unsupported/macx-clang-libc++ -I. -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtCore.framework/Versions/4/Headers -I/usr/local/include -Isrc -Irelease -F/usr/local/lib -o release/qextserialport.o src/qextserialport.cpp
/usr/local/bin/moc -DQEXTSERIALPORT_BUILD_SHARED -DQT_NO_DEBUG -DQT_CORE_LIB -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/etc/qt4/mkspecs/unsupported/macx-clang-libc++ -I. -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtCore.framework/Versions/4/Headers -I/usr/local/include -Isrc -Irelease -F/usr/local/lib -D__APPLE__ -D__GNUC__ src/qextserialenumerator.h -o release/moc_qextserialenumerator.cpp
clang++ -c -pipe -stdlib=libc++ -mmacosx-version-min=10.7 -O2 -arch x86_64 -Wall -W -fPIC -DQEXTSERIALPORT_BUILD_SHARED -DQT_NO_DEBUG -DQT_CORE_LIB -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/etc/qt4/mkspecs/unsupported/macx-clang-libc++ -I. -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtCore.framework/Versions/4/Headers -I/usr/local/include -Isrc -Irelease -F/usr/local/lib -o release/qextserialenumerator.o src/qextserialenumerator.cpp
clang++ -c -pipe -stdlib=libc++ -mmacosx-version-min=10.7 -O2 -arch x86_64 -Wall -W -fPIC -DQEXTSERIALPORT_BUILD_SHARED -DQT_NO_DEBUG -DQT_CORE_LIB -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/etc/qt4/mkspecs/unsupported/macx-clang-libc++ -I. -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtCore.framework/Versions/4/Headers -I/usr/local/include -Isrc -Irelease -F/usr/local/lib -o release/qextserialport_unix.o src/qextserialport_unix.cpp
clang++ -c -pipe -stdlib=libc++ -mmacosx-version-min=10.7 -O2 -arch x86_64 -Wall -W -fPIC -DQEXTSERIALPORT_BUILD_SHARED -DQT_NO_DEBUG -DQT_CORE_LIB -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/etc/qt4/mkspecs/unsupported/macx-clang-libc++ -I. -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtCore.framework/Versions/4/Headers -I/usr/local/include -Isrc -Irelease -F/usr/local/lib -o release/qextserialenumerator_osx.o src/qextserialenumerator_osx.cpp
rm -f libqextserialport.1.2.0.dylib libqextserialport.dylib libqextserialport.1.dylib libqextserialport.1.2.dylib
clang++ -headerpad_max_install_names -stdlib=libc++ -mmacosx-version-min=10.7 -arch x86_64 -single_module -dynamiclib -compatibility_version	1.2 -current_version	1.2.0 -install_name	/usr/local/lib/libqextserialport.1.dylib -o libqextserialport.1.2.0.dylib release/qextserialport.o release/qextserialenumerator.o release/qextserialport_unix.o release/qextserialenumerator_osx.o  -F/usr/local/lib -L/usr/local/lib -framework IOKit -framework CoreFoundation -framework QtCore  
ld: warning: text-based stub file /System/Library/Frameworks//IOKit.framework/IOKit.tbd and library file /System/Library/Frameworks//IOKit.framework/IOKit are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation are out of sync. Falling back to library file for linking.
ld: framework not found QtCore
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [libqextserialport.1.2.0.dylib] Error 1
make: *** [release-all] Error 2
$ 

I could try to link QtCore to someplace… but first trying a different tack, after a re-read…

Building qextserialport within SerialPlot

As per the documentation in “method 1” on the qextserialport web page, adding the following line:

include(../qextserialport/src/qextserialport.pri)

to the SerialPlot.pro file

#-------------------------------------------------
#
# Project created by QtCreator 2011-09-04T21:04:31
#
# install_name_tool -change libqextserialport.1.dylib @executable_path/../Frameworks/libqextserialport.1.dylib SerialPlot
#-------------------------------------------------

QT       += core gui

TARGET = SerialPlot
TEMPLATE = app


SOURCES += main.cpp\
        mainwindow.cpp \
    SensorCurve.cpp \
    SensorData.cpp \
    DynamicParam.cpp \
    serialSelectDialog.cpp \
    PlotWindow.cpp \
    ParamWindow.cpp \
    LogWindow.cpp

HEADERS  += mainwindow.h \
    SensorCurve.h \
    SensorData.h \
    DynamicParam.h \
    serialSelectDialog.h \
    PlotWindow.h \
    ParamWindow.h \
    LogWindow.h

FORMS    += mainwindow.ui \
    serialSelectDialog.ui \
    PlotWindow.ui \
    ParamWindow.ui \
    LogWindow.ui

include(../qextserialport/src/qextserialport.pri)

win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../qwt-6.0.1/lib/release/ -lqwt
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../qwt-6.0.1/lib/debug/ -lqwt
else:mac: LIBS += -F$$PWD/../qwt-6.0.1/lib/ -framework qwt
else:unix: LIBS += -L$$PWD/../qwt-6.0.1/lib/ -lqwt

INCLUDEPATH += $$PWD/../qwt-6.0.1/src
DEPENDPATH += $$PWD/../qwt-6.0.1/src

win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../qextserialport/src/build/ -lqextserialport
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../qextserialport/src/build/ -lqextserialportd
else:unix:!symbian: LIBS += -L$$PWD/../qextserialport/src/build/ -lqextserialport

INCLUDEPATH += $$PWD/../qextserialport/src
DEPENDPATH += $$PWD/../qextserialport/src

gives

:-1: error: library not found for -lqextserialport

in full

03:13:17: Running steps for project SerialPlot...
03:13:17: Configuration unchanged, skipping qmake step.
03:13:17: Starting: "/usr/bin/make" 
/usr/local/Cellar/qt@4/4.8.7_6.reinstall/bin/qmake -spec /usr/local/Cellar/qt@4/4.8.7_6.reinstall/etc/qt4/mkspecs/macx-g++ CONFIG+=debug CONFIG+=x86_64 -o Makefile ../SerialPlot/SerialPlot.pro
/usr/local/bin/moc -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/etc/qt4/mkspecs/macx-g++ -I../SerialPlot -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtGui.framework/Versions/4/Headers -I/usr/local/include -I../qextserialport/src -I../qwt-6.0.1/src -I../qextserialport/src -I. -I. -I../SerialPlot -I. -F/usr/local/lib -D__APPLE__ -D__GNUC__ ../qextserialport/src/qextserialport.h -o moc_qextserialport.cpp
g++ -c -pipe -g -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/etc/qt4/mkspecs/macx-g++ -I../SerialPlot -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtGui.framework/Versions/4/Headers -I/usr/local/include -I../qextserialport/src -I../qwt-6.0.1/src -I../qextserialport/src -I. -I. -I../SerialPlot -I. -F/usr/local/lib -o qextserialport.o ../qextserialport/src/qextserialport.cpp
/usr/local/bin/moc -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/etc/qt4/mkspecs/macx-g++ -I../SerialPlot -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtGui.framework/Versions/4/Headers -I/usr/local/include -I../qextserialport/src -I../qwt-6.0.1/src -I../qextserialport/src -I. -I. -I../SerialPlot -I. -F/usr/local/lib -D__APPLE__ -D__GNUC__ ../qextserialport/src/qextserialenumerator.h -o moc_qextserialenumerator.cpp
g++ -c -pipe -g -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/etc/qt4/mkspecs/macx-g++ -I../SerialPlot -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtGui.framework/Versions/4/Headers -I/usr/local/include -I../qextserialport/src -I../qwt-6.0.1/src -I../qextserialport/src -I. -I. -I../SerialPlot -I. -F/usr/local/lib -o qextserialenumerator.o ../qextserialport/src/qextserialenumerator.cpp
g++ -c -pipe -g -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/etc/qt4/mkspecs/macx-g++ -I../SerialPlot -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtGui.framework/Versions/4/Headers -I/usr/local/include -I../qextserialport/src -I../qwt-6.0.1/src -I../qextserialport/src -I. -I. -I../SerialPlot -I. -F/usr/local/lib -o qextserialport_unix.o ../qextserialport/src/qextserialport_unix.cpp
g++ -c -pipe -g -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/etc/qt4/mkspecs/macx-g++ -I../SerialPlot -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtGui.framework/Versions/4/Headers -I/usr/local/include -I../qextserialport/src -I../qwt-6.0.1/src -I../qextserialport/src -I. -I. -I../SerialPlot -I. -F/usr/local/lib -o qextserialenumerator_osx.o ../qextserialport/src/qextserialenumerator_osx.cpp
g++ -headerpad_max_install_names -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -o SerialPlot.app/Contents/MacOS/SerialPlot main.o mainwindow.o SensorCurve.o SensorData.o DynamicParam.o serialSelectDialog.o PlotWindow.o ParamWindow.o LogWindow.o qextserialport.o qextserialenumerator.o qextserialport_unix.o qextserialenumerator_osx.o moc_mainwindow.o moc_DynamicParam.o moc_serialSelectDialog.o moc_PlotWindow.o moc_ParamWindow.o moc_LogWindow.o   -F/usr/local/lib -L/usr/local/lib -framework IOKit -framework CoreFoundation -F/Users/macbook/Qt-code/SerialPlot/../qwt-6.0.1/lib/ -framework qwt -L/Users/macbook/Qt-code/SerialPlot/../qextserialport/src/build/ -lqextserialport -framework QtGui -framework QtCore 
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
ld: warning: directory not found for option '-L/Users/macbook/Qt-code/SerialPlot/../qextserialport/src/build/'
ld: warning: text-based stub file /System/Library/Frameworks//IOKit.framework/IOKit.tbd and library file /System/Library/Frameworks//IOKit.framework/IOKit are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation are out of sync. Falling back to library file for linking.
ld: library not found for -lqextserialport
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [SerialPlot.app/Contents/MacOS/SerialPlot] Error 1
03:13:26: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project SerialPlot (kit: Desktop)
When executing step "Make"
03:13:26: Elapsed time: 00:09.

The pesky line:

ld: library not found for -lqextserialport

Building qextserialport in QtCreator

After reading this answer to linking mac framework to qt creator then returning to the building of qextserialport, opening the qextserialport.pro in QtCreator (instead of running qmake/make in the terminal) and adding the line (the path to QtCore):

QMAKE_LFLAGS += -F/usr/local/Cellar/qt@4/4.8.7_6.reinstall/Frameworks

This made it compile – the additional following line was not necessary (and I did not add it… well, I did but then I removed it after I found that I could get the library to build and output the libraries, without it being necessary to include the line [Ed: This may have consequences later, see below, The next day].

LIBS += -framework QtCore

However, it then asked for the location of the executable:

Qt4.5 Creator - qextserialport - Custom Executable

However, that was because the Run button had been pressed.

For Build only, it works as expected, with the library being created, in qextserialport/debug/ as qextserialport.o, along with a number of other static library files [Edit: the .o file is an object file, not a static library]:

qextserialport - debug

However, the following day, after a good nights sleep I realised that a number of other dynamic library files had also been created, in the qextserialport directory itself:

qextserialport - dylib

More about these dynamic library files later… see The next day, below.

Continuing with SerialPlot

So, the qextserialport library is (presumably) built.

Now, I thought that I would cheat a bit — instead of waiting for the SerialPlot build to create the qextserialport library itself, I would create a build directory in qextserialport/src myself and manually copy qextserialport.o from qextserialport/debug/ into the qextserialport/src/build directory [Edit: the .o file is an object file, not a static library]. Once the expected library was in place, then I build SerialPlot.

This made the error reduce to

clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
ld: warning: text-based stub file /System/Library/Frameworks//IOKit.framework/IOKit.tbd and library file /System/Library/Frameworks//IOKit.framework/IOKit are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation are out of sync. Falling back to library file for linking.
ld: library not found for -lqextserialport
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [SerialPlot.app/Contents/MacOS/SerialPlot] Error 1
05:07:20: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project SerialPlot (kit: Desktop)
When executing step "Make"
05:07:20: Elapsed time: 00:20.

That is to say that the following line had gone

ld: warning: directory not found for option '-L/Users/macbook/Qt-code/SerialPlot/../qextserialport/src/build/'

Maybe just because the directory had been manually created..? Or was it because I had manually moved the library myself. It seemed to be more that the directory was now present, and the latter was doubtful, because…

However, it still couldn’t seem to see the qextserialport.o library just sitting in src/build, which was odd. [Edit: the .o file is an object file, not a static library]

Apart from not seeing the library, why wasn’t the build directory being created? There must be a mis-configuration issue in one of the .pro files. Presumably, the .pro file of SerialPlot, as it was that which was directing the build of qextseriaport – by way of the include line, that was added above:

include(../qextserialport/src/qextserialport.pri) 

Addendum: I rechecked the requirement of the directory build being present by renaming build to build2 and re-running Build of SerialPlot and the error/warning

ld: warning: directory not found for option '-L/Users/macbook/Qt-code/SerialPlot/../qextserialport/src/build/'

returned. So that directory requirement was confirmed.

The next day – using dynamic libraries

After a fevered sleep, as noted above, I saw that, as well as the static .o library files [Edit: the .o file is an object file, not a static library] in qextserialport/debug/, there were also a number of .dylib libraries that had also been created. Maybe it was these dynamic libraries that the SerialPlot linker was looking for in qextserialport/src/build..?

So, cheating again, and manually copying all 9 of the .dylib files into the src/build directory and then running Build on SerialPort certainly produced a different result:

:-1: error: framework not found QtGui

In full

14:40:01: Running steps for project SerialPlot...
14:40:01: Configuration unchanged, skipping qmake step.
14:40:01: Starting: "/usr/bin/make" 
g++ -headerpad_max_install_names -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -o SerialPlot.app/Contents/MacOS/SerialPlot main.o mainwindow.o SensorCurve.o SensorData.o DynamicParam.o serialSelectDialog.o PlotWindow.o ParamWindow.o LogWindow.o qextserialport.o qextserialenumerator.o qextserialport_unix.o qextserialenumerator_osx.o moc_mainwindow.o moc_DynamicParam.o moc_serialSelectDialog.o moc_PlotWindow.o moc_ParamWindow.o moc_LogWindow.o   -F/usr/local/lib -L/usr/local/lib -framework IOKit -framework CoreFoundation -F/Users/macbook/Qt-code/SerialPlot/../qwt-6.0.1/lib/ -framework qwt -L/Users/macbook/Qt-code/SerialPlot/../qextserialport/src/build/ -lqextserialport -framework QtGui -framework QtCore 
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
ld: warning: text-based stub file /System/Library/Frameworks//IOKit.framework/IOKit.tbd and library file /System/Library/Frameworks//IOKit.framework/IOKit are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation are out of sync. Falling back to library file for linking.
ld: framework not found QtGui
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [SerialPlot.app/Contents/MacOS/SerialPlot] Error 1
14:40:03: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project SerialPlot (kit: Desktop)
When executing step "Make"
14:40:03: Elapsed time: 00:02.

As a sanity check, I removed the dylib files (and the debug qextserialport.o [Edit: the .o file is an object file, not a static library]) from qextserialport/src/build/, rebuilt and the missing library error returned. After reinstating only the dylib files (and not the debug qextserialport.o [Edit: the .o file is an object file, not a static library]), the missing library error disappeared, moving on to the QtGui error.

So it was confirmed that the dylib files were required. In fact not all nine files (including the erroneous .pri file) were required, and I reduced it down to just four files (by removing the *_debug files:

qextserialport - build directory

One thing that was weird, was that although I had copied over just 9 .dylib files, there was also a libqextserialport_debug.prl file in src/debug, which I hadn’t placed there. Where had that come from? [Ed. turns out that I had actually copied over myself – it was amongst the .dylib files].

So… on with the missing QtGui error…

Adding the QtGui framework

This is the same error as that from my attempt to manually build qextserialport in a terminal, see Building qextserialport manually – in a terminal, above.

The issue was that, unlike an include or even a binary, creating a symlink wasn’t possible as there are no Framework directories in /etc or /usr/local, etc. to which to link.

However, from Building qextserialport in QtCreator above, there was this line (from this answer to linking mac framework to qt creator) that I had not included when building qextserialport:

LIBS += -framework QtCore

Maybe it was necessary to include a similar line in the SerialPlot.pro file, along the lines of

LIBS += -framework QtGui

That did not help, so I also added

QMAKE_LFLAGS += -F/usr/local/Cellar/qt@4/4.8.7_6.reinstall/Frameworks

That seemed to enable getting passed the QtGui error.

However, then I got

:-1: error: symbol(s) not found for architecture x86_64

In full

...
g++ -headerpad_max_install_names -F/usr/local/Cellar/qt@4/4.8.7_6.reinstall/Frameworks -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -o SerialPlot.app/Contents/MacOS/SerialPlot main.o mainwindow.o SensorCurve.o SensorData.o DynamicParam.o serialSelectDialog.o PlotWindow.o ParamWindow.o LogWindow.o qextserialport.o qextserialenumerator.o qextserialport_unix.o qextserialenumerator_osx.o moc_mainwindow.o moc_DynamicParam.o moc_serialSelectDialog.o moc_PlotWindow.o moc_ParamWindow.o moc_LogWindow.o   -F/usr/local/lib -L/usr/local/lib -framework IOKit -framework CoreFoundation -F/Users/macbook/Qt-code/SerialPlot/../qwt-6.0.1/lib/ -framework qwt -L/Users/macbook/Qt-code/SerialPlot/../qextserialport/src/build/ -lqextserialport -framework QtGui -L/usr/local/opt/openssl@1.0/lib -L/usr/local/Cellar/qt@4/4.8.7_6/lib -F/usr/local/Cellar/qt@4/4.8.7_6/lib -framework QtCore 
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
ld: warning: directory not found for option '-L/usr/local/Cellar/qt@4/4.8.7_6/lib'
ld: warning: directory not found for option '-F/usr/local/Cellar/qt@4/4.8.7_6/lib'
ld: warning: text-based stub file /System/Library/Frameworks//IOKit.framework/IOKit.tbd and library file /System/Library/Frameworks//IOKit.framework/IOKit are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation are out of sync. Falling back to library file for linking.
Undefined symbols for architecture x86_64:
  "QwtPlotZoomer::QwtPlotZoomer(QwtPlotCanvas*, bool)", referenced from:
      PlotWindow::PlotWindow(QWidget*) in PlotWindow.o
  "QwtPlot::insertLegend(QwtLegend*, QwtPlot::LegendPosition, double)", referenced from:
      PlotWindow::PlotWindow(QWidget*) in PlotWindow.o
  "QwtLegend::setItemMode(QwtLegend::LegendItemMode)", referenced from:
      PlotWindow::PlotWindow(QWidget*) in PlotWindow.o
  "QwtPlotItem::legendItem() const", referenced from:
      vtable for SensorCurve in SensorCurve.o
  "QwtPlotCurve::updateLegend(QwtLegend*) const", referenced from:
      vtable for SensorCurve in SensorCurve.o
  "QwtPlotCurve::drawLegendIdentifier(QPainter*, QRectF const&) const", referenced from:
      vtable for SensorCurve in SensorCurve.o
  "QwtPlotAbstractSeriesItem::draw(QPainter*, QwtScaleMap const&, QwtScaleMap const&, QRectF const&) const", referenced from:
      vtable for SensorCurve in SensorCurve.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [SerialPlot.app/Contents/MacOS/SerialPlot] Error 1
15:44:30: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project SerialPlot (kit: Desktop)
When executing step "Make"
15:44:30: Elapsed time: 00:18.

These were all qwt errors. Had I downloaded the wrong source files from Sourceforge? Or had the brew install qwt installed the incorrect files (binaries?) or versions?

Tackling the qwt issues

Examining the qwt source files, I saw that they were also Qt files and I opened the qwt.pro file in QtCreator – to see if I could see what the issue was more clearly (as I had done with qextserialport).

Trying to build, gave this error:

/Users/macbook/Qt-code/qwt-6.0.1/src/qwt_plot_renderer.cpp:33: error: 'qsvggenerator.h' file not found

in full

16:40:24: Running steps for project qwt...
16:40:24: Starting: "/usr/local/Cellar/qt@4/4.8.7_6.reinstall/bin/qmake" /Users/macbook/Qt-code/qwt-6.0.1/qwt.pro -r -spec macx-g++ CONFIG+=debug CONFIG+=x86_64
Reading /Users/macbook/Qt-code/qwt-6.0.1/src/src.pro [/Users/macbook/Qt-code/build-qwt-Qt_4_8_7_4_8_7_6_reinstall-Debug/src]
Reading /Users/macbook/Qt-code/qwt-6.0.1/textengines/textengines.pro [/Users/macbook/Qt-code/build-qwt-Qt_4_8_7_4_8_7_6_reinstall-Debug/textengines]
 Reading /Users/macbook/Qt-code/qwt-6.0.1/textengines/mathml/mathml.pro [/Users/macbook/Qt-code/build-qwt-Qt_4_8_7_4_8_7_6_reinstall-Debug/textengines/mathml]
Project MESSAGE: The qwtmathml library contains code of the MML Widget from the Qt solutions package.
Project MESSAGE: Beside the Qwt license you also have to take care of its license.
Reading /Users/macbook/Qt-code/qwt-6.0.1/designer/designer.pro [/Users/macbook/Qt-code/build-qwt-Qt_4_8_7_4_8_7_6_reinstall-Debug/designer]
16:40:26: The process "/usr/local/Cellar/qt@4/4.8.7_6.reinstall/bin/qmake" exited normally.
16:40:26: Starting: "/usr/bin/make" 
cd src/ && /Library/Developer/CommandLineTools/usr/bin/make -f Makefile 
compiling ../../qwt-6.0.1/src/qwt_abstract_scale_draw.cpp
compiling ../../qwt-6.0.1/src/qwt_interval_symbol.cpp
compiling ../../qwt-6.0.1/src/qwt_clipper.cpp
compiling ../../qwt-6.0.1/src/qwt_color_map.cpp
compiling ../../qwt-6.0.1/src/qwt_column_symbol.cpp
compiling ../../qwt-6.0.1/src/qwt_interval.cpp
compiling ../../qwt-6.0.1/src/qwt_dyngrid_layout.cpp
compiling ../../qwt-6.0.1/src/qwt_math.cpp
compiling ../../qwt-6.0.1/src/qwt_magnifier.cpp
compiling ../../qwt-6.0.1/src/qwt_panner.cpp
compiling ../../qwt-6.0.1/src/qwt_null_paintdevice.cpp
compiling ../../qwt-6.0.1/src/qwt_painter.cpp
compiling ../../qwt-6.0.1/src/qwt_picker.cpp
compiling ../../qwt-6.0.1/src/qwt_round_scale_draw.cpp
compiling ../../qwt-6.0.1/src/qwt_scale_div.cpp
compiling ../../qwt-6.0.1/src/qwt_scale_draw.cpp
compiling ../../qwt-6.0.1/src/qwt_scale_map.cpp
compiling ../../qwt-6.0.1/src/qwt_spline.cpp
compiling ../../qwt-6.0.1/src/qwt_text_engine.cpp
compiling ../../qwt-6.0.1/src/qwt_text_label.cpp
compiling ../../qwt-6.0.1/src/qwt_text.cpp
compiling ../../qwt-6.0.1/src/qwt_event_pattern.cpp
compiling ../../qwt-6.0.1/src/qwt_picker_machine.cpp
compiling ../../qwt-6.0.1/src/qwt_point_3d.cpp
compiling ../../qwt-6.0.1/src/qwt_point_polar.cpp
compiling ../../qwt-6.0.1/src/qwt_scale_engine.cpp
compiling ../../qwt-6.0.1/src/qwt_symbol.cpp
compiling ../../qwt-6.0.1/src/qwt_system_clock.cpp
compiling ../../qwt-6.0.1/src/qwt_curve_fitter.cpp
compiling ../../qwt-6.0.1/src/qwt_legend.cpp
compiling ../../qwt-6.0.1/src/qwt_legend_item.cpp
compiling ../../qwt-6.0.1/src/qwt_plot.cpp
compiling ../../qwt-6.0.1/src/qwt_plot_renderer.cpp
../../qwt-6.0.1/src/qwt_plot_renderer.cpp:33:10: fatal error: 'qsvggenerator.h' file not found
#include 
         ^~~~~~~~~~~~~~~~~
1 error generated.
make[1]: *** [obj/qwt_plot_renderer.o] Error 1
make: *** [sub-src-make_default-ordered] Error 2
16:40:56: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project qwt (kit: Qt 4.8.7 (4.8.7_6.reinstall))
When executing step "Make"
16:40:56: Elapsed time: 00:32.

Apart from these two messages in red:

Project MESSAGE: The qwtmathml library contains code of the MML Widget from the Qt solutions package. 
Project MESSAGE: Beside the Qwt license you also have to take care of its license.

There was (most importantly) this error:

../../qwt-6.0.1/src/qwt_plot_renderer.cpp:33:10: fatal error: 'qsvggenerator.h' file not found

However, this is under /usr/local/Cellar/qt@4/4.8.7_6_reinstall/include/QtSvg/qsvggenerator.hso a path is not set correctly, somewhere.

I think that the QT_INSTALL_* environment variables (which still point to /usr/local for the most part), need configuring to point to /usr/local/Cellar/qt@4/4.8.7_6_reinstall/

Qt4.5 Creator - Desktop environment - more paths

Maybe:

  • Tackle the qwt compile from a different angle/direction, and compile it while compiling SerialPlot.
    • This could be done by adding an include line to serialplot.pro, as was done for qextserialport, to include the qwt source (when building SerialPort):
      • so, in a manner similar to adding include(../qextserialport/src/qextserialport.pri)  to serialplot.pro, one could also add include(../qwt-6.0.1/src/qwt.pri).
    • However, there is no .pri file. Also, trying to get qwt to compile alone is probably to simplest option, as there are less inter-dependancies – causing qwt to compile whilst compiling SerialPlot maybe the more correct method, but also adds unnecessary complexities.
  • If qwt is not compiling due to an error, then that explains (maybe) the missing x86 symbols when compiling SerialPlot, as there are no library binaries to be found.

Regardless, this missing header issue seemed similar to the 'QtGui/QApplication' file not found error above, when first attempting to compile SerialPlot (it was the third error logged above). The solution then was to add

/usr/local/Cellar/qt@4/4.8.7_6.reinstall/bin

to the PATH in the build environment. However, that will not work here as we need to add

/usr/local/Cellar/qt@4/4.8.7_6.reinstall/include

However, looking at the .pro for SerialPlot, there is:

INCLUDEPATH += $$PWD/../qwt-6.0.1/src

Adding something similar to the.pro file of qwt:

INCLUDEPATH += /usr/local/Cellar/qt@4/4.8.7_6.reinstall/include

Meh… no, because it should be in the Build path anyway, due to the kit being selected… I dunno, this is giving me a headache now.

From Qt center – Forum – Problem with SVG libraries and headers, I found some useful posts.

I tried adding to the .pro file:

QT += svg

Same issue.

I changed in qwt_plot_renderer.cpp

#include <qsvggenerator.h>

to

#include <QtSvg/QSvgGenerator>

Same issue.

At this point I was desperate enough to read the README in qwt directory, and then the INSTALL text file, which said to run the following three commands in a terminal.

qmake qwt.pro
make
make install

So

/usr/local/Cellar/qt@4/4.8.7_6.reinstall/bin/qmake qwt.pro

worked fine. Then

make

produced the same issue as above in QtCreator:

$ make
cd src/ && /usr/local/Cellar/qt@4/4.8.7_6.reinstall/bin/qmake /Users/macbook/Qt-code/qwt-6.0.1/src/src.pro -o Makefile
cd src/ && /Library/Developer/CommandLineTools/usr/bin/make -f Makefile 
compiling qwt_abstract_scale_draw.cpp
compiling qwt_interval_symbol.cpp
compiling qwt_clipper.cpp
compiling qwt_color_map.cpp
compiling qwt_column_symbol.cpp
compiling qwt_interval.cpp
compiling qwt_dyngrid_layout.cpp
compiling qwt_math.cpp
compiling qwt_magnifier.cpp
compiling qwt_panner.cpp
compiling qwt_null_paintdevice.cpp
compiling qwt_painter.cpp
compiling qwt_picker.cpp
compiling qwt_round_scale_draw.cpp
compiling qwt_scale_div.cpp
compiling qwt_scale_draw.cpp
compiling qwt_scale_map.cpp
compiling qwt_spline.cpp
compiling qwt_text_engine.cpp
compiling qwt_text_label.cpp
compiling qwt_text.cpp
compiling qwt_event_pattern.cpp
compiling qwt_picker_machine.cpp
compiling qwt_point_3d.cpp
compiling qwt_point_polar.cpp
compiling qwt_scale_engine.cpp
compiling qwt_symbol.cpp
compiling qwt_system_clock.cpp
compiling qwt_curve_fitter.cpp
compiling qwt_legend.cpp
compiling qwt_legend_item.cpp
compiling qwt_plot.cpp
compiling qwt_plot_renderer.cpp
qwt_plot_renderer.cpp:33:10: fatal error: 'QtSvg/qsvggenerator.h' file not found
#include <QtSvg/qsvggenerator.h>
         ^~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[1]: *** [obj/qwt_plot_renderer.o] Error 1
make: *** [sub-src-make_default-ordered] Error 2
$

Time to give up???

qt creator does not see the qwt headers does not help.

Temp fix – copy the headers over manually

In the end, I was so exasperated that I just ended up copying qsvggenerator.h from /usr/local/Cellar/qt@4/4.8.7_6_reinstall/include/QtSvg/to qwt-6.0.1/src.

Note: the /usr/local/Cellar/qt@4/4.8.7_6_reinstall/include/QtSvg is a link to within 4.8.7_6_reinstall/lib/QtSvg.framework/Versions/4/Headers

That made it compile (in the terminal)

$ make
cd src/ && /Library/Developer/CommandLineTools/usr/bin/make -f Makefile 
compiling qwt_plot_renderer.cpp
compiling qwt_plot_xml.cpp
compiling qwt_plot_axis.cpp
compiling qwt_plot_curve.cpp
compiling qwt_plot_dict.cpp
compiling qwt_plot_directpainter.cpp
compiling qwt_plot_grid.cpp
compiling qwt_plot_histogram.cpp
compiling qwt_plot_item.cpp
compiling qwt_plot_intervalcurve.cpp
qwt_plot_intervalcurve.cpp:409:26: warning: unused variable 'clipRect'
      [-Wunused-variable]
            const QRectF clipRect = canvasRect.adjusted(-pw, -pw, pw, pw);
                         ^
1 warning generated.
compiling qwt_plot_spectrogram.cpp
compiling qwt_plot_spectrocurve.cpp
compiling qwt_plot_scaleitem.cpp
compiling qwt_plot_seriesitem.cpp
compiling qwt_plot_marker.cpp
compiling qwt_plot_layout.cpp
compiling qwt_plot_canvas.cpp
compiling qwt_plot_panner.cpp
compiling qwt_plot_rasteritem.cpp
compiling qwt_plot_picker.cpp
compiling qwt_plot_zoomer.cpp
compiling qwt_plot_magnifier.cpp
compiling qwt_plot_rescaler.cpp
compiling qwt_raster_data.cpp
compiling qwt_matrix_raster_data.cpp
compiling qwt_sampling_thread.cpp
compiling qwt_series_data.cpp
compiling qwt_scale_widget.cpp
compiling qwt_plot_svgitem.cpp
qwt_plot_svgitem.cpp:16:10: fatal error: 'qsvgrenderer.h' file not found
#include 
         ^~~~~~~~~~~~~~~~
1 error generated.
make[1]: *** [obj/qwt_plot_svgitem.o] Error 1
make: *** [sub-src-make_default-ordered] Error 2
$ 

Then doing the same with qsvgrenderer.h

$ make
cd src/ && /Library/Developer/CommandLineTools/usr/bin/make -f Makefile 
compiling qwt_plot_svgitem.cpp
compiling qwt_abstract_slider.cpp
compiling qwt_abstract_scale.cpp
compiling qwt_arrow_button.cpp
compiling qwt_analog_clock.cpp
compiling qwt_compass.cpp
compiling qwt_compass_rose.cpp
compiling qwt_counter.cpp
compiling qwt_dial.cpp
compiling qwt_dial_needle.cpp
compiling qwt_double_range.cpp
compiling qwt_knob.cpp
compiling qwt_slider.cpp
compiling qwt_thermo.cpp
compiling qwt_wheel.cpp
moc qwt_dyngrid_layout.h
compiling moc/moc_qwt_dyngrid_layout.cpp
moc qwt_magnifier.h
compiling moc/moc_qwt_magnifier.cpp
moc qwt_panner.h
compiling moc/moc_qwt_panner.cpp
moc qwt_picker.h
compiling moc/moc_qwt_picker.cpp
moc qwt_text_label.h
compiling moc/moc_qwt_text_label.cpp
moc qwt_legend.h
compiling moc/moc_qwt_legend.cpp
moc qwt_legend_item.h
compiling moc/moc_qwt_legend_item.cpp
moc qwt_plot.h
compiling moc/moc_qwt_plot.cpp
moc qwt_plot_renderer.h
compiling moc/moc_qwt_plot_renderer.cpp
moc qwt_plot_canvas.h
compiling moc/moc_qwt_plot_canvas.cpp
moc qwt_plot_panner.h
compiling moc/moc_qwt_plot_panner.cpp
moc qwt_plot_picker.h
compiling moc/moc_qwt_plot_picker.cpp
moc qwt_plot_zoomer.h
compiling moc/moc_qwt_plot_zoomer.cpp
moc qwt_plot_magnifier.h
compiling moc/moc_qwt_plot_magnifier.cpp
moc qwt_sampling_thread.h
compiling moc/moc_qwt_sampling_thread.cpp
moc qwt_scale_widget.h
compiling moc/moc_qwt_scale_widget.cpp
moc qwt_abstract_slider.h
compiling moc/moc_qwt_abstract_slider.cpp
moc qwt_analog_clock.h
compiling moc/moc_qwt_analog_clock.cpp
moc qwt_compass.h
compiling moc/moc_qwt_compass.cpp
moc qwt_counter.h
compiling moc/moc_qwt_counter.cpp
moc qwt_dial.h
compiling moc/moc_qwt_dial.cpp
moc qwt_knob.h
compiling moc/moc_qwt_knob.cpp
moc qwt_slider.h
compiling moc/moc_qwt_slider.cpp
moc qwt_thermo.h
compiling moc/moc_qwt_thermo.cpp
moc qwt_wheel.h
compiling moc/moc_qwt_wheel.cpp
rm -f qwt qwt.framework/qwt ../lib/qwt.framework/qwt
rm: qwt: is a directory
make[1]: [../lib/qwt.framework/qwt] Error 1 (ignored)
linking ../lib/qwt.framework/qwt
ld: framework not found QtSvg
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [../lib/qwt.framework/qwt] Error 1
make: *** [sub-src-make_default-ordered] Error 2
$

So now the old framework problem for QtSvg – which was predictable, especially as the paths still weren’t correctly set and I had cheated by copying the two headers to the src directory of qwt.

Adding the QtSvg framework

This was similar to the missing QtGui framework issue, see the section Adding the QtGui framework, above.

Maybe it was necessary to include a similar line in qwt.pro file, along the lines of

LIBS += -framework QtSvg

I didn’t know where to add it, if using the terminal, so returning to QtCreator I put it in the qwt.pro file.

That did help, so I didn’t (need to) add

QMAKE_LFLAGS += -F/usr/local/Cellar/qt@4/4.8.7_6.reinstall/Frameworks

Note: This is actually the reverse of the QtGui issue. There the LIBS += didn’t help, but QMAKE_LFLAGS += did help. Here LIBS += did help the QtSvg issue, and the QMAKE_LFLAGS += wasn’t needed.

So, adding the LIBS += seemed to have built the qwt library… Amazing! Or rather, upon inspection, a lot of object files (.o) in qwt-6.0.1/src/obj.

There was an additional qwt-6.0.1/lib directory that is just a link to /usr/local/Cellar/qwt/6.1.6-1/lib with a number of newly created files (a framework and version other stuff):

qwt - linked lib

Back to SerialPlot

Remember we are still trying to build SerialPlot… I, personally, had forgotten – what with all of the qwt hassle…

To recap, the last issue had been:

ld: symbol(s) not found for architecture x86_64

Now, opening SerialPlot in QtCreator, and hitting build, the issue was now

:-1: error: framework not found qwt

In full

g++ -headerpad_max_install_names -F/usr/local/Cellar/qt@4/4.8.7_6.reinstall/Frameworks -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -o SerialPlot.app/Contents/MacOS/SerialPlot main.o mainwindow.o SensorCurve.o SensorData.o DynamicParam.o serialSelectDialog.o PlotWindow.o ParamWindow.o LogWindow.o qextserialport.o qextserialenumerator.o qextserialport_unix.o qextserialenumerator_osx.o moc_mainwindow.o moc_DynamicParam.o moc_serialSelectDialog.o moc_PlotWindow.o moc_ParamWindow.o moc_LogWindow.o   -F/usr/local/lib -L/usr/local/lib -framework IOKit -framework CoreFoundation -F/Users/macbook/Qt-code/SerialPlot/../qwt-6.0.1/lib/ -framework qwt -L/Users/macbook/Qt-code/SerialPlot/../qextserialport/src/build/ -lqextserialport -framework QtGui -L/usr/local/opt/openssl@1.0/lib -L/usr/local/Cellar/qt@4/4.8.7_6/lib -F/usr/local/Cellar/qt@4/4.8.7_6/lib -framework QtCore 
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
ld: warning: directory not found for option '-L/usr/local/Cellar/qt@4/4.8.7_6/lib'
ld: warning: directory not found for option '-F/usr/local/Cellar/qt@4/4.8.7_6/lib'
ld: warning: text-based stub file /System/Library/Frameworks//IOKit.framework/IOKit.tbd and library file /System/Library/Frameworks//IOKit.framework/IOKit are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation are out of sync. Falling back to library file for linking.
ld: framework not found qwt
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [SerialPlot.app/Contents/MacOS/SerialPlot] Error 1
01:06:32: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project SerialPlot (kit: Desktop)
When executing step "Make"
01:06:32: Elapsed time: 00:01.

Ah, the old “framework not found” issue. Well, we’ve just fixed that for qwt and its QtSvg framework not found issue, see Adding the QtSvg framework above.

So the solution would appear to be to add to the serialplot.pro file

LIBS += -framework qwt

n’est pas?

No! So maybe add to the serialplot.pro file a version of

QMAKE_LFLAGS += -F/usr/local/Cellar/qt@4/4.8.7_6.reinstall/Frameworks

is required. The line already exists for qt, so what is the form required for qwt?

Maybe /usr/local/Cellar/qwt/6.1.6-1/lib, as this directory contains the qwt.framework file:

QMAKE_LFLAGS += -F/usr/local/Cellar/qwt/6.1.6-1/lib

Still the same error:

g++ -headerpad_max_install_names -F/usr/local/Cellar/qt@4/4.8.7_6.reinstall/Frameworks -F/usr/local/Cellar/qwt/6.1.6-1/lib -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -o SerialPlot.app/Contents/MacOS/SerialPlot main.o mainwindow.o SensorCurve.o SensorData.o DynamicParam.o serialSelectDialog.o PlotWindow.o ParamWindow.o LogWindow.o qextserialport.o qextserialenumerator.o qextserialport_unix.o qextserialenumerator_osx.o moc_mainwindow.o moc_DynamicParam.o moc_serialSelectDialog.o moc_PlotWindow.o moc_ParamWindow.o moc_LogWindow.o   -F/usr/local/lib -L/usr/local/lib -framework IOKit -framework CoreFoundation -F/Users/macbook/Qt-code/SerialPlot/../qwt-6.0.1/lib/ -framework qwt -L/Users/macbook/Qt-code/SerialPlot/../qextserialport/src/build/ -lqextserialport -framework QtGui -L/usr/local/opt/openssl@1.0/lib -L/usr/local/Cellar/qt@4/4.8.7_6/lib -F/usr/local/Cellar/qt@4/4.8.7_6/lib -framework QtCore 
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
ld: warning: directory not found for option '-L/usr/local/Cellar/qt@4/4.8.7_6/lib'
ld: warning: directory not found for option '-F/usr/local/Cellar/qwt/6.1.6-1/lib'
ld: warning: directory not found for option '-F/usr/local/Cellar/qt@4/4.8.7_6/lib'
ld: warning: text-based stub file /System/Library/Frameworks//IOKit.framework/IOKit.tbd and library file /System/Library/Frameworks//IOKit.framework/IOKit are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation are out of sync. Falling back to library file for linking.
ld: framework not found qwt
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [SerialPlot.app/Contents/MacOS/SerialPlot] Error 1
01:16:57: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project SerialPlot (kit: Desktop)
When executing step "Make"
01:16:57: Elapsed time: 00:22.

Directory not found warnings

After reading Qt Forum – QWT Framework not found, I thought I’d check that the directories exist.

What is strange about the above error output are these three lines:

ld: warning: directory not found for option '-L/usr/local/Cellar/qt@4/4.8.7_6/lib'
ld: warning: directory not found for option '-F/usr/local/Cellar/qwt/6.1.6-1/lib'
ld: warning: directory not found for option '-F/usr/local/Cellar/qt@4/4.8.7_6/lib'

In terminal, as a sanity check:

$ ls /usr/local/Cellar/qwt/6.1.6-1/lib
ls: /usr/local/Cellar/qwt/6.1.6-1/lib: No such file or directory
$ ls /usr/local/Cellar/qt@4/4.8.7_6/lib
ls: /usr/local/Cellar/qt@4/4.8.7_6/lib: No such file or directory
$

Very odd, considering

qwt - linked lib - path

and

qwt.framework - path

But

$ ls /usr/local/Cellar/qwt/6.1.6_1/
.DS_Store             INSTALL_RECEIPT.json  features/
.brew/                README                lib/
COPYING               doc/                  
$ ls /usr/local/Cellar/qwt/6.1.6_1/lib
qt qwt.framework
$

and

$ ls /usr/local/Cellar/qt@4
4.8.7_6.reinstall
$ ls /usr/local/Cellar/qt@4/4.8.7_6.reinstall
Assistant.app		QMLViewer.app		lib
Designer.app		README			qttracereplay.app
Frameworks		bin			translations
INSTALL_RECEIPT.json	etc
Linguist.app		include
$ ls /usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib
Qt3Support.framework		QtTest.framework
QtCore.framework		QtXml.framework
QtDeclarative.framework		QtXmlPatterns.framework
QtDesigner.framework		libQtCLucene.4.8.7.dylib
QtDesignerComponents.framework	libQtCLucene.4.8.dylib
QtGui.framework			libQtCLucene.4.dylib
QtHelp.framework		libQtCLucene.dylib
QtMultimedia.framework		libQtCLucene.prl
QtNetwork.framework		libQtUiTools.a
QtOpenGL.framework		libQtUiTools.prl
QtScript.framework		libQtUiTools_debug.a
QtScriptTools.framework		libQtUiTools_debug.prl
QtSql.framework			pkgconfig
QtSvg.framework			qt4
$

Finally it dawned on me that the actual directory names did not match those that the compiler/linker was using:

/usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib

not

/usr/local/Cellar/qt@4/4.8.7_6/lib

and

/usr/local/Cellar/qwt/6.1.6_1/lib

not

/usr/local/Cellar/qwt/6.1.6-1/lib

So, fixing my self-introduced typo for qwt and changing to - for a _

MAKE_LFLAGS += -F/usr/local/Cellar/qwt/6.1.6_1/lib

However, in the SerialPort.pro file, the qt directory was specified correctly:

LIBS += -framework QtGui
QMAKE_LFLAGS += -F/usr/local/Cellar/qt@4/4.8.7_6.reinstall/Frameworks

LIBS += -framework qwt
QMAKE_LFLAGS += -F/usr/local/Cellar/qwt/6.1.6_1/lib

So why was the .reinstall being dropped in the error message? Where was the /usr/local/Cellar/qt@4/4.8.7_6/lib coming from?

Also, why was the .reinstall in the directory name anyway (it had occurred during the installation, as mentioned right at the top of this page. Having a brainwave, I made a symlink without the .reinstall:

ln -s 4.8.7_6.reinstall 4.8.7_6

so

$ cd /usr/local/Cellar/qt@4/
$ ls
4.8.7_6.reinstall
$ ls -al
total 24
drwxr-xr-x    3 macbook  admin   136 Jul 24 23:24 .
drwxrwxr-x  209 macbook  admin  7208 Jul 25 02:48 ..
-rw-r--r--@   1 macbook  admin  8196 Jul 26 00:44 .DS_Store
drwxr-xr-x   15 macbook  admin   612 Jul 24 23:27 4.8.7_6.reinstall
$ ln -s 4.8.7_6.reinstall 4.8.7_6
$ ls
4.8.7_6			4.8.7_6.reinstall
$ ls -al
total 32
drwxr-xr-x    3 macbook  admin   170 Jul 26 02:01 .
drwxrwxr-x  209 macbook  admin  7208 Jul 25 02:48 ..
-rw-r--r--@   1 macbook  admin  8196 Jul 26 00:44 .DS_Store
lrwxr-xr-x    1 macbook  admin    17 Jul 26 02:01 4.8.7_6 -> 4.8.7_6.reinstall
drwxr-xr-x   15 macbook  admin   612 Jul 24 23:27 4.8.7_6.reinstall
$

Now upon building, at least the directory warnings had gone

clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
ld: warning: text-based stub file /System/Library/Frameworks//IOKit.framework/IOKit.tbd and library file /System/Library/Frameworks//IOKit.framework/IOKit are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation are out of sync. Falling back to library file for linking.
ld: framework not found qwt
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [SerialPlot.app/Contents/MacOS/SerialPlot] Error 1
02:03:06: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project SerialPlot (kit: Desktop)
When executing step "Make"
02:03:06: Elapsed time: 00:16.

Back to the qwt framework

Hmmm…

Maybe create a symlink to qwt somewhere?

Interestingly, upon a whim, I commented out the lines that I had previously added to SerialPlot’s .pro file:

# Added lines -mgj

#LIBS += -framework QtGui
#QMAKE_LFLAGS += -F/usr/local/Cellar/qt@4/4.8.7_6.reinstall/Frameworks

#LIBS += -framework qwt
#QMAKE_LFLAGS += -F/usr/local/Cellar/qwt/6.1.6_1/lib

and the error was the same (framework not found qwt). The lines (in particular the first two QtGui and Frameworks lines) were not necessary, at all – even after a Clean and a Rebuild… Strange, no? [Edit – Or is it just that as the object files were already made, then these flags weren’t needed anymore and that, maybe, after a clean and/or a rebuild they may be required again? No, I checked this.] Note that Rebuild is actually Clean and Build together.

clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
ld: warning: text-based stub file /System/Library/Frameworks//IOKit.framework/IOKit.tbd and library file /System/Library/Frameworks//IOKit.framework/IOKit are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation are out of sync. Falling back to library file for linking.
ld: framework not found qwt
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [SerialPlot.app/Contents/MacOS/SerialPlot] Error 1
03:22:15: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project SerialPlot (kit: Desktop)
When executing step "Make"

Disparity noticed

In SerialPlot.pro

win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../qwt-6.0.1/lib/release/ -lqwt
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../qwt-6.0.1/lib/debug/ -lqwt
else:mac: LIBS += -F$$PWD/../qwt-6.0.1/lib/ -framework qwt
else:unix: LIBS += -L$$PWD/../qwt-6.0.1/lib/ -lqwt

The source directory downloaded from source forge

qwt-6.0.1

and the library installed with brew

/usr/local/Cellar/qwt/6.1.6_1/lib

They all have different versions in the directory name. I tried sym-linking a faux version, that matches the one that SerialPort is searching for:

ln -s 6.1.6_1 6.0.1

However, it didn’t help.

The third day (qwt build)

Ho hum, here we are again… “A new day, a new version of qwt”

After realising that I should read the documentation and finding Qwt User’s Guide 6.2.0 and the real downloads page: qwt, I thought I’d try a new version, the latest version 6.2.0. I downloaded the .tar.bz2 and the .qch files. I couldn’t find the qwtdesigner-6.2.0-*.zip file.

However, it is worth bearing in mind that 2014-10-09, two years after the last commit to SerialPlot, the current version of qwt was version 0.2h. So, this might account for some of the issues – compatibility?

In a terminal, bunzip2, tar xvf, copy to ~/Qt-code, qmake all ran fine.

$ /usr/local/Cellar/qt@4/4.8.7_6.reinstall/bin/qmake qwt.pro
$

However, make gave three errors

In file included from qwt_abstract_scale_draw.cpp:14:
./qwt_math.h:93:5: error: C++ requires a type specifier for all declarations
    QT_WARNING_DISABLE_CLANG("-Wdouble-promotion")
    ^
./qwt_math.h:93:51: error: expected ';' after top level declarator
    QT_WARNING_DISABLE_CLANG("-Wdouble-promotion")
                                                  ^
                                                  ;
qwt_abstract_scale_draw.cpp:359:18: error: use of undeclared identifier
      'qwtMaxF'
        length = qwtMaxF( length, m_data->tickLength[i] );
                 ^
3 errors generated.
make[1]: *** [obj/qwt_abstract_scale_draw.o] Error 1
make: *** [sub-src-make_default-ordered] Error 2
$

nullptr issue

QtCreator gave an additional error, to the three above, about nullptr

In file included from ../../qwt-6.2.0/src/qwt_abstract_scale_draw.cpp:12:
../../qwt-6.2.0/src/qwt_painter.h:128:66: error: use of undeclared identifier 'nullptr'
    static QFont scaledFont( const QFont&, const QPaintDevice* = nullptr );
                                                                 ^

for this line:

    static QFont scaledFont( const QFont&, const QPaintDevice* = nullptr );

Apparently, this is due to libC++11 not being used, see nullptr not declared in scope when compiling on mac. Adding --std=c++11 :

qwt.6.2.0 - Adding --std=c++11

Didn’t work.

The correct way is from this answer to C++ Qt – How to add “-std=c++11” to the makefile which is generated by qmake?

Add to the qwt.pro

CONFIG += c++11

However, this still didn’t work. I even tried c++14.

Note: Why doesn’t this nullptr issue occur when building in the terminal? Is QtCreator using a different qmake from the qt@4 that I installed? Possibly, as the path is different, in the , from that which I specified in the command line in the terminal. Or rather, given the following, a different C library is being used…

From error: use of undeclared identifier ‘nullptr’

My understanding is that nullptr is a part of the C++11 standard. The default 
C++ standard library used on OS X 10.8 and earlier is the Apple GCC 4.2.1 
version of libstdc++, and it does not support C++11. The default C++ standard 
library used on OS X 10.9 and later is libc++, and it does support C++11.

Interestingly, in the 6.2.0 qwt.pro there is this at the top:

lessThan(QT_MAJOR_VERSION, 5) {

    lessThan(QT_MINOR_VERSION, 8) {
        error(Qt >= 4.8 required.)
    }
}

and we are using 4.8.7_6, so it should be A-OK.

qmake v5 – building in a terminal (qwt build)

In the terminal I tried v5 of qmake:

/usr/local/Cellar/qt@5/5.15.2/bin/qmake qwt.pro

Which gave a .stash file.

$ /usr/local/Cellar/qt@5/5.15.2/bin/qmake qwt.pro
Info: creating stash file /Users/macbook/Qt-code/qwt-6.2.0/.qmake.stash
$

However, make gave the same three errors:

In file included from qwt_abstract_scale_draw.cpp:14:
./qwt_math.h:93:5: error: C++ requires a type specifier for all declarations
    QT_WARNING_DISABLE_CLANG("-Wdouble-promotion")
    ^
./qwt_math.h:93:51: error: expected ';' after top level declarator
    QT_WARNING_DISABLE_CLANG("-Wdouble-promotion")
                                                  ^
                                                  ;
qwt_abstract_scale_draw.cpp:359:18: error: use of undeclared identifier
      'qwtMaxF'
        length = qwtMaxF( length, m_data->tickLength[i] );
                 ^
3 errors generated.
make[1]: *** [obj/qwt_abstract_scale_draw.o] Error 1
make: *** [sub-src-make_default-ordered] Error 2
$

Commenting out the offending lines (qwt build)

Exasperated, I decided to give up on the nullptr resolution and look at the other three errors.

Two of the errors were in qwtmath.h, so I just commented out those lines, as they seemed to be pointless warning suppression:

    //QT_WARNING_DISABLE_CLANG("-Wdouble-promotion")
    //QT_WARNING_DISABLE_GCC("-Wdouble-promotion")

Then continuing the make in the terminal, so as to avoid QtCreator’s nullptr complaint, I got better results, with the third error (“use of undeclared identifier qwtMaxF “) remarkably just vanishing, poooof!

Copying the header files – again

Then after a while, make crashed out with a familiar error raising its head:

compiling qwt_symbol.cpp
qwt_symbol.cpp:20:10: fatal error: 'qsvgrenderer.h' file not found
#include 
         ^~~~~~~~~~~~~~~~
1 error generated.
make[1]: *** [obj/qwt_symbol.o] Error 1
make: *** [sub-src-make_first-ordered] Error 2
$

Remember the cheaty fix from last time? See Temp fix – copy the headers over manually above. Just manually copy over the qsvgrenderer.h file to qwt-6.2.0/src.

Then

compiling qwt_plot_renderer.cpp
qwt_plot_renderer.cpp:67:10: fatal error: 'qsvggenerator.h' file not found
#include 
         ^~~~~~~~~~~~~~~~~
1 error generated.
make[1]: *** [obj/qwt_plot_renderer.o] Error 1
make: *** [sub-src-make_first-ordered] Error 2
$

Just manually copy over the qsvggenerator.h file from /usr/local/Cellar/qt@4/4.8.7_6_reinstall/include/QtSvg/ to qwt-6.2.0/src.

Then

compiling qwt_plot_glcanvas.cpp
In file included from qwt_plot_glcanvas.cpp:10:
./qwt_plot_glcanvas.h:16:10: fatal error: 'qgl.h' file not found
#include 
         ^~~~~~~
1 error generated.
make[1]: *** [obj/qwt_plot_glcanvas.o] Error 1
make: *** [sub-src-make_first-ordered] Error 2
$ 

Just manually copy over the qgl.h file from /usr/local/Cellar/qt@4/4.8.7_6_reinstall/include/QtOpenGL/ to qwt-6.2.0/src.

Then

compiling qwt_plot_glcanvas.cpp
In file included from qwt_plot_glcanvas.cpp:10:
In file included from ./qwt_plot_glcanvas.h:16:
./qgl.h:47:10: fatal error: 'QtOpenGL/qglcolormap.h' file not found
#include <QtOpenGL/qglcolormap.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[1]: *** [obj/qwt_plot_glcanvas.o] Error 1
make: *** [sub-src-make_first-ordered] Error 2
$

Interesting to note that the file is QtOpenGL/qglcolormap.h, whereas previously the QtOpenGL/ prefix was missing for ogl.h

Just manually copy over the qcolormap.h file from /usr/local/Cellar/qt@4/4.8.7_6_reinstall/include/QtOpenGL/ to qwt-6.2.0/src.

Are you starting to see a pattern emerging here? Obviously it would be better, and more correct, to just fix the path (and remove all of the copied over header files from qwt-6.2.0/src/.

Hmmm. however, this time it didn’t work as the QtOpenGL/ path prefix is specified… so maybe we need to fix the paths after all.

Unless… we cheat and copy qcolormap.h file from /usr/local/Cellar/qt@4/4.8.7_6_reinstall/include/QtOpenGL/ to qwt-6.2.0/src/QtOpenGL/ i.e., create a QtOpenGL directory in src. A cunning stunt, huh?

That worked…!

Then

compiling qwt_plot_glcanvas.cpp
qwt_plot_glcanvas.cpp:17:10: fatal error: 'qglframebufferobject.h' file not
      found
#include 
         ^~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[1]: *** [obj/qwt_plot_glcanvas.o] Error 1
make: *** [sub-src-make_first-ordered] Error 2
$

Just manually copy over the qglframebufferobject.h file from /usr/local/Cellar/qt@4/4.8.7_6_reinstall/include/QtOpenGL/ to qwt-6.2.0/src.

Then

compiling qwt_plot_glcanvas.cpp
In file included from qwt_plot_glcanvas.cpp:17:
./qglframebufferobject.h:45:10: fatal error: 'QtOpenGL/qgl.h' file not found
#include <QtOpenGL/qgl.h>
         ^~~~~~~~~~~~~~~~
1 error generated.
make[1]: *** [obj/qwt_plot_glcanvas.o] Error 1
make: *** [sub-src-make_first-ordered] Error 2
$

Even though ogl.h is already in src/, this time the qgl.h must also be copied to src/QtOpenGL/. Talk about inconsistent use of paths in the header #include lines in the code!

Then, our old friend returned…

linking ../lib/qwt.framework/qwt
ld: framework not found QtSvg
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [../lib/qwt.framework/qwt] Error 1
make: *** [sub-src-make_first-ordered] Error 2
$

Day Four – flogging a dead qwt

So attempting to fix the framework not found QtSvg issue in the same way as before, see Adding the QtSvg framework above, I added:

Maybe it was necessary to include a similar line in qwt.pro file, along the lines of

LIBS += -framework QtSvg

Running make produced the same error. However, if you change the .pro file then you need to re-run qmake? Nope and yes….  If you make a change to a .pro file, in QtCreator, it automatically runs qmake upon a save. Regardless, running qmake and then make didn’t help.

==This is nonsense – BEGIN

However, examining the error message a little more closely, you can see that it is looking for

linking ../lib/qwt.framework/qwt

I didn’t know where to add it, if using the terminal, so returning to QtCreator I put it in the qwt.pro file.

That did help, so I didn’t (need to) add

QMAKE_LFLAGS += -F/usr/local/Cellar/qt@4/4.8.7_6.reinstall/Frameworks

Note:

==This is nonsense – END

I added another kit, Qt 5.15.2 in some vain hope that it might work better. But then I gave up for the day.

Day four? – I’m losing count, actually day five…

Going back over the nullptr error, in QtCreator, again, see nullptr issue above. A heads up warning, today was a day littered with frustrating typos…

After re-reading C++ Qt – How to add “-std=c++11” to the makefile which is generated by qmake?, and seeing this answer, which has OS X specific instructions:

-mmacosx-version-min=10.7

Use QMAKE_CXXFLAGS or CONFIG? (qwt build)

This seems to be some disparity as to whether QMAKE_CXXFLAGS or CONFIG should be used. That is to say, should one use

QMAKE_CXXFLAGS += -libc++11

or

CONFIG += c++11

Note this comment for Qt 4:

Tweaking CONFIG does not work for Qt4. Haven’t tested for Qt5.

and this comment

That’s right, however I tried to compile Qt5 code using CONFIG+=c++11 for using range based for with a Qt container (QList for being accurate) and I have got a compiler error, then I changed it for QMAKE_CXXFLAGS += -std=gnu++11 and it worked perfectly.

A useful reference: QMAKE_CXXFLAGS.

The answer to Qt 5: CONFIG+=c++11 vs QMAKE_CXXFLAGS+=-std=c++11 (What’s better) recommends using CONFIG. However, I found it does nothing, using Qt4. However, it may work differently for Qt5.

As a side note: I had noticed that, in QtCreator, I had not added /usr/local/Cellar/qt@4/4.8.7_6.reinstall/bin to the PATH in Build Environment for qwt-6.20. This time I added it to the beginning of the PATH, rather than the end:

QtCreator - Adding to PATH in Build Environment

The typos begin (qwt build)

[You can skip to the last line of this section]

Anyway, to be safe I added both lines

CONFIG += c++11
QMAKE_CXXFLG += c++11

to both the qwt.pro and the src.pro and I still got the nullptr error

Then I noticed my typo, QMAKE_CXXFLG instead of QMAKE_CXXFLAGS (which when you type in correctly, it turns mauve in the editor) and corrected

CONFIG += c++11   
QMAKE_CXXFLAGS += c++11

and re-ran qmake. This actually seemed to fix the nullptr error… but I got a new error instead:

error: [obj/qwt.o] Error 1

Now to sanity check which .por file the lines are required in. First remove both lines from src.pro, but leaving in qwt.pro, caused the error to come back. Removing both lines from qwt.pro, but leaving in src.pro, again fixed the nullptr error. So this suggests that the “top level” qwt.pro does not “control” the lower level .pro files. OK.

Now to sanity check which of the two lines is needed. First comment out the CONFIG, but leave the QMAKE_CXXFLAGS, and the nullptr issue was still fixed. Comment out the QMAKE_CXXFLAGS, but leaving the CONFIG, made the nullptr issue return. Interesting.

Never the less, with the nullptr issue seemingly fixed, I got a new error

:-1: error: [obj/qwt.o] Error 1

In full

cd src/ && /Library/Developer/CommandLineTools/usr/bin/make -f Makefile 
compiling ../../qwt-6.2.0/src/qwt.cpp
clang: error: no such file or directory: 'c++11'
make[1]: *** [obj/qwt.o] Error 1
make: *** [sub-src-make_default-ordered] Error 2
01:38:06: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project qwt (kit: Qt 4.8.7 (4.8.7_6.reinstall))
When executing step "Make"
01:38:06: Elapsed time: 00:03.

Interesting to note the line:

clang: error: no such file or directory: 'c++11'

So, maybe the nullptr issue wasn’t fixed after all, as the build just wasn’t getting that far, because of the newly added c++11 flag.

I then noticed yet another typo, the line should be

QMAKE_CXXFLAGS += std=c++11

not

QMAKE_CXXFLAGS += c++11

Still the obj/qwt.o error.

Ah damn it, I had missed a - and the line should actually be

QMAKE_CXXFLAGS += -std=c++11

The end of the typos (qwt build)

Now that seemed to help and instead of the obj/qwt.o, I got a new error:

/usr/local/include/QtCore/qlist.h:55: error: 'initializer_list' file not found

in full

compiling ../../qwt-6.2.0/src/qwt.cpp
In file included from ../../qwt-6.2.0/src/qwt.cpp:11:
In file included from /usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtGui.framework/Versions/4/Headers/qapplication.h:45:
In file included from /usr/local/include/QtCore/qcoreapplication.h:45:
In file included from /usr/local/include/QtCore/qobject.h:50:
/usr/local/include/QtCore/qlist.h:55:10: fatal error: 'initializer_list' file not found
#include <initializer_list>
         ^~~~~~~~~~~~~~~~~~
1 error generated.
make[1]: *** [obj/qwt.o] Error 1
make: *** [sub-src-make_default-ordered] Error 2
01:52:55: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project qwt (kit: Qt 4.8.7 (4.8.7_6.reinstall))
When executing step "Make"
01:52:55: Elapsed time: 00:10.

From “initializer_list” file not found

CFLAGS='-mmacosx-version-min=10.7 -std=c++11 -stdlib=libc++'

adding these to the QMAKE_CXXFLAGS line

QMAKE_CXXFLAGS +='-mmacosx-version-min=10.7 -std=c++11 -stdlib=libc++'

I got

compiling ../../qwt-6.2.0/src/qwt.cpp
clang: error: invalid deployment target for -stdlib=libc++ (requires OS X 10.7 or later)
make[1]: *** [obj/qwt.o] Error 1
make: *** [sub-src-make_default-ordered] Error 2
02:02:28: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project qwt (kit: Qt 4.8.7 (4.8.7_6.reinstall))
When executing step "Make"
02:02:28: Elapsed time: 00:01.

Removing the -stdlib=libc++, the error went back to

compiling ../../qwt-6.2.0/src/qwt.cpp
In file included from ../../qwt-6.2.0/src/qwt.cpp:11:
In file included from /usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtGui.framework/Versions/4/Headers/qapplication.h:45:
In file included from /usr/local/include/QtCore/qcoreapplication.h:45:
In file included from /usr/local/include/QtCore/qobject.h:50:
/usr/local/include/QtCore/qlist.h:55:10: fatal error: 'initializer_list' file not found
#include <initializer_list>
         ^~~~~~~~~~~~~~~~~~
1 error generated.
make[1]: *** [obj/qwt.o] Error 1
make: *** [sub-src-make_default-ordered] Error 2
02:05:02: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project qwt (kit: Qt 4.8.7 (4.8.7_6.reinstall))
When executing step "Make"
02:05:02: Elapsed time: 00:01.

Apparently a known issue for Qt5.0, from this answer to Compile error when trying to compile a qt project, use the following lines:

QMAKE_CXXFLAGS = -mmacosx-version-min=10.7 -std=gnu0x -stdlib=libc++
CONFIG +=c++11

Looks like a typo in the first line, not libc+ but libc++

From this comment to the answer above:

QMAKE_CXXFLAGS = -mmacosx-version-min=10.7 -std=c++11 -stdlib=libc++

Regardless, I tried all of the following

#CONFIG += c++11
#QMAKE_CXXFLAGS += -std=c++11
#QMAKE_CXXFLAGS +='-mmacosx-version-min=10.7 -std=c++11 -stdlib=libc++'
#QMAKE_CXXFLAGS += -mmacosx-version-min=10.7 -std=c++11 -stdlib=libc++
QMAKE_CXXFLAGS += -mmacosx-version-min=10.8 -std=c++11 -stdlib=libc++
#QMAKE_CXXFLAGS +='-mmacosx-version-min=10.7 -std=c++11'
#QMAKE_CXXFLAGS = -mmacosx-version-min=10.7 -std=gnu0x -stdlib=libc++
CONFIG +=c++11

None of which worked and I always the same error:

clang: error: invalid deployment target for -stdlib=libc++ (requires OS X 10.7 or later)

And I am using 10.13.6

From https://bugreports.qt.io/browse/QTBUG-28097 : clone the Qt kit and change the C compiler to Clang-C

QtCreator - Clone and Clang

and use

QMAKE_CXXFLAGS = -mmacosx-version-min=10.7 -std=gnu0x -stdlib=libc++ CONFIG +=c++11

However, I still got the 10.7 error

clang: error: invalid deployment target for -stdlib=libc++ (requires OS X 10.7 or later)

Day six

I Just went over the notes above and fixed typos, I just couldn’t face anymore qwt shit today.

However, after some thought, one of the issues is how to get QtCreator to use either Qt4 or Qt5…. by choosing a kit, right? But how to choose which Qt verion is used when using make in a terminal? That way one could check whether CONFIG or QMAKE_CXXFLAGS works best.

Day whatever… seven? (qwt build)

Just found this, could be useful: Install and use QWT under Mac OS X, which suggests an interesting couple of lines at the end:

Add to the .pro file:

include ( /usr/local/qwt-6.1.4/features/qwt.prf )

and symlink

$ sudo ln -s/usr/local/qwt-6.1.4/lib/qwt.framework/qwt /usr/lib/qwt

On Mojave:

cp qwt.framework Library/Frameworks

This last line gave me an idea (see below).

Anyway, to recap the scenario for qwt:

  • In QtCreator
    • There is an issue with nullptr and libc++11
  • In the terminal
    • QtSvg.framework can’t be found.

Back to the terminal (qwt build)

From the “On Mojave” tip above, I thought to symlink the Qt frameworks…

So, for QtSvg.framework

$ sudo ln -s /usr/local/Cellar/qt4/4.8.7_6/lib/QtSvg.framework /Library/Frameworks/QtSvg.framework

That fixed the QtSvg error:

ld: framework not found QtSvg

but gave rise to the next error:

ld: framework not found QtOpenGL

So, repeating the process:

$ sudo ln -s /usr/local/Cellar/qt4/4.8.7_6/lib/QtOpenGL.framework /Library/Frameworks/QtOpenGL.framework

Next error:

ld: framework not found QtGui

Next fix

$ sudo ln -s /usr/local/Cellar/qt4/4.8.7_6/lib/QtGui.framework /Library/Frameworks/QtGui.framework

Next error

ld: framework not found QtCore

Next fix

$ sudo ln -s /usr/local/Cellar/qt4/4.8.7_6/lib/QtCore.framework /Library/Frameworks/QtCore.framework

Note: Instead of all this symlinking, it would probably have been better to add to a (library?) path environment variable. According to this comment on an answer to qwt 6.1.0 on mac os 10.9 causes : Library not loaded: qwt.framework/Versions/6/qwt it should be possible using DYLD_FRAMEWORK_PATH.

Nevertheless, progress was being made.

Then it went on to compile a lot further until:

compiling main.cpp
linking ../bin/animation.app/Contents/MacOS/animation
Undefined symbols for architecture x86_64:
  "QwtPlotOpenGLCanvas::QwtPlotOpenGLCanvas(QwtPlot*)", referenced from:
      _main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [../bin/animation.app/Contents/MacOS/animation] Error 1
make[1]: *** [sub-animation-make_first] Error 2
make: *** [sub-examples-make_first-ordered] Error 2
$

Now this was similar to something we’d already seen whilst compiling SerialPlot, see Adding the QtGui framework above.

 

Giving up on that for the moment…

Linking qwt.framework to /Library/Framework (SerialPlot build)

Going back to the last failure of SerialPlot, it was that the qwt framework wasn’t found.

Given the previous successes of linking the .frameworks to /Library/Frameworks and after reading the answers to qwt 6.1.0 on mac os 10.9 causes : Library not loaded: qwt.framework/Versions/6/qwt

I thought that I would return to the SerialPlot build and symlink the qwt.framework in the qwt-6.0.1, that brew has installed, to /Library/Framework

$ sudo ln -s /usr/local/Cellar/qwt/6.0.1/lib/qwt.framework /Library/Frameworks/qwt.framework

6.0.1 is the version specified in SerialPlot.pro

But still the error appeared:

:-1: error: framework not found qwt

In full

g++ -headerpad_max_install_names -F/usr/local/Cellar/qwt/6.0.1/lib -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -o SerialPlot.app/Contents/MacOS/SerialPlot main.o mainwindow.o SensorCurve.o SensorData.o DynamicParam.o serialSelectDialog.o PlotWindow.o ParamWindow.o LogWindow.o qextserialport.o qextserialenumerator.o qextserialport_unix.o qextserialenumerator_osx.o moc_mainwindow.o moc_DynamicParam.o moc_serialSelectDialog.o moc_PlotWindow.o moc_ParamWindow.o moc_LogWindow.o   -F/usr/local/lib -L/usr/local/lib -framework IOKit -framework CoreFoundation -F/Users/macbook/Qt-code/SerialPlot/../qwt-6.0.1/lib/ -framework qwt -L/Users/macbook/Qt-code/SerialPlot/../qextserialport/src/build/ -lqextserialport -framework QtGui -framework QtCore 
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
ld: warning: text-based stub file /System/Library/Frameworks//IOKit.framework/IOKit.tbd and library file /System/Library/Frameworks//IOKit.framework/IOKit are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation are out of sync. Falling back to library file for linking.
ld: framework not found qwt
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [SerialPlot.app/Contents/MacOS/SerialPlot] Error 1
03:47:12: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project SerialPlot (kit: Desktop)
When executing step "Make"
03:47:12: Elapsed time: 00:28.

But, thinking back, this is strange, as this was one of the first errors seen, then, after fiddling with qextserialport, it was replaced with the ld: symbol(s) not found for architecture x86_64  error, and then it reappeared (after fiddling with qwt(version 6.0.1)).

Note: If the qwt.framework can’t be seen, even when residing in /Library/Frameworks, then where is it actually meant to be, and where is QtCreator looking..?

Day 8 (SerialPlot build)

Looking at the build output above, in particular this part:

-F/Users/macbook/Qt-code/SerialPlot/../qwt-6.0.1/lib/ -framework qwt

However, /Users/macbook/Qt-code/qwt-6.0.1/lib is a link to /usr/local/Cellar/qwt/6.1.6_1/lib/ which contains qwt.framework. Phhhfff, I going around in circles with this…

To the terminal

I realised that I hadn’t actually tried to build SerialPlot in a terminal. I opened a terminal and navigated to the SerialPlot directory and ran make (assuming that as qmake had been previously run in QtCreator, then make should just run). However, I got this error:

$ make
make: *** No rule to make target `../../../QtSDK/Desktop/Qt/473/gcc/mkspecs/macx-g++/qmake.conf', needed by `Makefile'.  Stop.
$

which was odd.

Never the less, I ran

$ /usr/local/Cellar/qt@4/4.8.7_6.reinstall/bin/qmake

and then make

clang++ -headerpad_max_install_names -stdlib=libc++ -mmacosx-version-min=10.7 -F/usr/local/Cellar/qwt/6.0.1/lib -arch x86_64 -o SerialPlot.app/Contents/MacOS/SerialPlot main.o mainwindow.o SensorCurve.o SensorData.o DynamicParam.o serialSelectDialog.o PlotWindow.o ParamWindow.o LogWindow.o qextserialport.o qextserialenumerator.o qextserialport_unix.o qextserialenumerator_osx.o moc_mainwindow.o moc_DynamicParam.o moc_serialSelectDialog.o moc_PlotWindow.o moc_ParamWindow.o moc_LogWindow.o   -F/usr/local/lib -L/usr/local/lib -framework IOKit -framework CoreFoundation -F/Users/macbook/Qt-code/SerialPlot/../qwt-6.0.1/lib/ -framework qwt -L/Users/macbook/Qt-code/SerialPlot/../qextserialport/src/build/ -lqextserialport -framework QtGui -framework QtCore 
ld: warning: text-based stub file /System/Library/Frameworks//IOKit.framework/IOKit.tbd and library file /System/Library/Frameworks//IOKit.framework/IOKit are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation are out of sync. Falling back to library file for linking.
ld: framework not found qwt
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [SerialPlot.app/Contents/MacOS/SerialPlot] Error 1
$

Which was sort of expected.

However, then running,

$ /usr/local/Cellar/qt@5/5.15.2/bin/qmake
Info: creating stash file /Users/macbook/Qt-code/SerialPlot/.qmake.stash
$ make

I got

/Library/Developer/CommandLineTools/usr/bin/clang++ -c -pipe -stdlib=libc++ -O2 -std=gnu++11  -arch x86_64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=10.13 -Wall -Wextra -fPIC -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I. -I../qextserialport/src -I../qwt-6.0.1/src -I../qextserialport/src -I/usr/local/Cellar/qt@5/5.15.2/lib/QtGui.framework/Headers -I/usr/local/Cellar/qt@5/5.15.2/lib/QtCore.framework/Headers -I. -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AGL.framework/Headers -I/usr/local/Cellar/qt@5/5.15.2/mkspecs/macx-clang -F/usr/local/Cellar/qt@5/5.15.2/lib -o moc_mainwindow.o moc_mainwindow.cpp
In file included from moc_mainwindow.cpp:10:
./mainwindow.h:4:10: fatal error: 'QMainWindow' file not found
#include 
         ^~~~~~~~~~~~~
1 error generated.
make: *** [moc_mainwindow.o] Error 1
$

Which was different. Was this because I hadn’t run make clean between the two qmake versions?

$ make clean
rm -f moc_predefs.h
rm -f moc_mainwindow.cpp moc_DynamicParam.cpp moc_serialSelectDialog.cpp moc_PlotWindow.cpp moc_ParamWindow.cpp moc_LogWindow.cpp moc_qextserialport.cpp moc_qextserialenumerator.cpp
rm -f main.o mainwindow.o SensorCurve.o SensorData.o DynamicParam.o serialSelectDialog.o PlotWindow.o ParamWindow.o LogWindow.o qextserialport.o qextserialenumerator.o qextserialport_unix.o qextserialenumerator_osx.o moc_mainwindow.o moc_DynamicParam.o moc_serialSelectDialog.o moc_PlotWindow.o moc_ParamWindow.o moc_LogWindow.o
rm -f *~ core *.core
$ /usr/local/Cellar/qt@5/5.15.2/bin/qmake
$ make
/Library/Developer/CommandLineTools/usr/bin/clang++ -c -pipe -stdlib=libc++ -O2 -std=gnu++11  -arch x86_64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=10.13 -Wall -Wextra -fPIC -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I. -I../qextserialport/src -I../qwt-6.0.1/src -I../qextserialport/src -I/usr/local/Cellar/qt@5/5.15.2/lib/QtGui.framework/Headers -I/usr/local/Cellar/qt@5/5.15.2/lib/QtCore.framework/Headers -I. -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AGL.framework/Headers -I/usr/local/Cellar/qt@5/5.15.2/mkspecs/macx-clang -F/usr/local/Cellar/qt@5/5.15.2/lib -o main.o main.cpp
main.cpp:1:10: fatal error: 'QtGui/QApplication' file not found
#include <QtGui/QApplication>
         ^~~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [main.o] Error 1
$ 

A different error again, so the make clean was necessary – however, the SerialPlot build hadn’t progressed very far, in fact it stopped at the first line.

New day (9) (SerialPlot build)

Upon a whim, I created a symlink in  /usr/local/Cellar/qwt/6.1.6_1/lib/

ln -s qwt.framework qwt

and re-ran qmake and make clean and make, in QtCreator. Now I got completely different errors!

/Users/macbook/Qt-code/build-SerialPlot-Desktop_65b4b4-Debug/moc_qextserialport.cpp:96: error: member access into incomplete type 'QextSerialPortPrivate'
        case 13: _t->d_func()->_q_canRead(); break;
                             ^

and

/Users/macbook/Qt-code/qextserialport/src/qextserialport.h:167: forward declaration of 'QextSerialPortPrivate'

In full

g++ -c -pipe -g -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/etc/qt4/mkspecs/macx-g++ -I../SerialPlot -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtGui.framework/Versions/4/Headers -I/usr/local/include -I../qextserialport/src -I../qwt-6.0.1/src -I../qextserialport/src -I. -I. -I../SerialPlot -I. -F/usr/local/lib -o moc_qextserialport.o moc_qextserialport.cpp
moc_qextserialport.cpp:96:30: error: member access into incomplete type 'QextSerialPortPrivate'
        case 13: _t->d_func()->_q_canRead(); break;
                             ^
./../qextserialport/src/qextserialport.h:167:7: note: forward declaration of 'QextSerialPortPrivate'
class QextSerialPortPrivate;
      ^
1 error generated.
make: *** [moc_qextserialport.o] Error 1
00:29:17: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project SerialPlot (kit: Desktop)
When executing step "Make"
00:29:17: Elapsed time: 00:23.

These errors persisted even after removing the newly created symlink, and rebuilding qextserialport and partially rebuilding qwt. I could not get back to my familiar “qwt framework not found issue”. This was strange – I am at a loss to explain this change…

See Trying to finish SerialPlot below, for an explanation attempt

Directory and .pro file naming mismatch (qwt build)

Then I realised that while the SerialPlot and qextserialport directories did not contain version numbers in the name, the qwt.pro files were in folders called qwt-6.0.1 and qwt-6.2.0. The .pro files should be named the same as the directories, so was this mismatch causing the issues..?

Copying and renaming qwt-6.0.1 to just qwt, and re-ran qmake and make clean and make, in QtCreator. This time I got a much longer compile time…

I got a new error, which I had not seen before.

/Users/macbook/Qt-code/qwt/textengines/mathml/qwt_mml_document.cpp:5: error: 'QDomNode' file not found

in full

compiling ../../../qwt/textengines/mathml/qwt_mml_document.cpp
../../../qwt/textengines/mathml/qwt_mml_document.cpp:5:10: fatal error: 'QDomNode' file not found
#include 
         ^~~~~~~~~~
1 error generated.
make[2]: *** [obj/qwt_mml_document.o] Error 1
make[1]: *** [sub-mathml-make_default] Error 2
make: *** [sub-textengines-make_default-ordered] Error 2
00:46:50: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project qwt (kit: Qt 4.8.7 (4.8.7_6.reinstall))
When executing step "Make"

It seemed like the directory name mismatch really was an issue! A new library had appeared in lib, qwtmathml.framework

According to this answer to Error in finding QDomDocument in c++ code, this line should be added

QT += xml

but it didn’t help.

Cheating (as before with the header files) and copying (in the Finder) the file from /usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtXml.framework/Versions/4/Headers/QDomNode to qwt/src seemed to help. New error

../../../qwt/src/QDomNode:1: error: 'qdom.h' file not found

So copying (in the Finder) /usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtXml.framework/Versions/4/Headers/qdom.h to qwt/src

New error

:-1: error: framework not found QtXml

Copying (in the Finder) /usr/local/Cellar/qt@4/4.8.7_6.reinstall/Frameworks/QtXml.framework to /Library/Frameworks surprisingly did not help.

In full

linking ../../../qwt/lib/qwtmathml.framework/qwtmathml
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
ld: framework not found QtXml
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [../../../qwt/lib/qwtmathml.framework/qwtmathml] Error 1
make[1]: *** [sub-mathml-make_default] Error 2
make: *** [sub-textengines-make_default-ordered] Error 2
01:15:08: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project qwt (kit: Qt 4.8.7 (4.8.7_6.reinstall))
When executing step "Make"
01:15:08: Elapsed time: 02:02.

That was disappointing.

Adding the line

LIBS += -framework QtXml

didn’t help (although it did seem to get rid of a lot of warnigs). This was similar to the qwt framework not being found, even though it was in /Library/Frameworks, and I was at a loss (again).

However, I realised that I had copied the framework (using the Finder), whereas previously (see Day whatever… seven?Back to the terminal) I had symlinked (in a terminal). So moving the newly copied QtXml.framework to the trash and creating a sym link instead

sudo ln -s /usr/local/Cellar/qt4/4.8.7_6/lib/QtXml.framework /Library/Frameworks/QtXml.framework

This worked.

Next error

compiling ../../qwt/designer/qwt_designer_plugin.cpp
../../qwt/designer/qwt_designer_plugin.cpp:17:10: fatal error: 'QDesignerFormEditorInterface' file not found
#include 
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[1]: *** [obj/qwt_designer_plugin.o] Error 1
make: *** [sub-designer-make_default-ordered] Error 2
02:22:37: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project qwt (kit: Qt 4.8.7 (4.8.7_6.reinstall))
When executing step "Make"
02:22:37: Elapsed time: 00:02.

Copying (in the Finder) /usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtDesigner.framework/Versions/4/Headers/QDesignerFormEditorInterface to qwt/src.

Next error

compiling ../../qwt/designer/qwt_designer_plugin.cpp
In file included from ../../qwt/designer/qwt_designer_plugin.cpp:17:
../../qwt/src/QDesignerFormEditorInterface:1:10: fatal error: 'abstractformeditor.h' file not found
#include "abstractformeditor.h"
         ^~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[1]: *** [obj/qwt_designer_plugin.o] Error 1
make: *** [sub-designer-make_default-ordered] Error 2
02:25:58: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project qwt (kit: Qt 4.8.7 (4.8.7_6.reinstall))
When executing step "Make"
02:25:58: Elapsed time: 00:01.

Copying /usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtDesigner.framework/Versions/4/Headers/abstractformeditor.h to qwt/src

Next error

compiling ../../qwt/designer/qwt_designer_plugin.cpp
In file included from ../../qwt/designer/qwt_designer_plugin.cpp:17:
In file included from ../../qwt/src/QDesignerFormEditorInterface:1:
../../qwt/src/abstractformeditor.h:45:10: fatal error: 'QtDesigner/sdk_global.h' file not found
#include <QtDesigner/sdk_global.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[1]: *** [obj/qwt_designer_plugin.o] Error 1
make: *** [sub-designer-make_default-ordered] Error 2
02:27:14: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project qwt (kit: Qt 4.8.7 (4.8.7_6.reinstall))
When executing step "Make"
02:27:14: Elapsed time: 00:01.

Creating a new directory QtDesigner in qwt/src and copying /usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtDesigner.framework/Versions/4/Headers/sdk_global.h to qwt/src/QtDesigner

compiling ../../qwt/designer/qwt_designer_plugin.cpp
../../qwt/designer/qwt_designer_plugin.cpp:18:10: fatal error: 'QDesignerFormWindowInterface' file not found
#include 
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[1]: *** [obj/qwt_designer_plugin.o] Error 1
make: *** [sub-designer-make_default-ordered] Error 2
02:31:22: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project qwt (kit: Qt 4.8.7 (4.8.7_6.reinstall))
When executing step "Make"
02:31:22: Elapsed time: 00:01.

Copying /usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtDesigner.framework/Versions/4/Headers/QDesignerFormWindowInterface to qwt/src

compiling ../../qwt/designer/qwt_designer_plugin.cpp
In file included from ../../qwt/designer/qwt_designer_plugin.cpp:18:
../../qwt/src/QDesignerFormWindowInterface:1:10: fatal error: 'abstractformwindow.h' file not found
#include "abstractformwindow.h"
         ^~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[1]: *** [obj/qwt_designer_plugin.o] Error 1
make: *** [sub-designer-make_default-ordered] Error 2
02:32:56: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project qwt (kit: Qt 4.8.7 (4.8.7_6.reinstall))
When executing step "Make"
02:32:56: Elapsed time: 00:01.

Copying /usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtDesigner.framework/Versions/4/Headers/abstractformwindow.h to qwt/src

Then

../../qwt/designer/qwt_designer_plugin.cpp:19:10: fatal error: 'QDesignerFormWindowCursorInterface' file not found
#include 
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[1]: *** [obj/qwt_designer_plugin.o] Error 1
make: *** [sub-designer-make_default-ordered] Error 2
02:34:13: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project qwt (kit: Qt 4.8.7 (4.8.7_6.reinstall))
When executing step "Make"
02:34:13: Elapsed time: 00:01.

Bahh, I could see that there would be lot of these. How to just specify the path, instead of copying? Why wasn’t the path seen anyway, was it due to the qt@4 in the path name? I found How to add include path in Qt Creator?

I added

INCLUDEPATH += /usr/local/Cellar/qt@4/4.8.7_6.reinstall/

Same WindowCursorInterface issue. However, maybe /usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtDesigner.framework/Versions/4/Headers/ was better?

INCLUDEPATH += /usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtDesigner.framework/Versions/4/Headers/

Nope… how about

#INCLUDEPATH += /usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtDesigner.framework/Versions/4/Headers/
INCLUDEPATH += /usr/local/Cellar/qt@4/4.8.7_6.reinstall/include

Nope

I just continued copying over these files to qwt/src (except for the two files to qwt/src/QtDesigner/):

  • /usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtDesigner.framework/Versions/4/Headers/abstractformwindowcursor.h
  • /usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtDesigner.framework/Versions/4/Headers/QExtensionManager
  • /usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtDesigner.framework/Versions/4/Headers/qextensionmanager.h
  • /usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtDesigner.framework/Versions/4/Headers/extension_global.h to qwt/src/QtDesigner/
  • /usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtDesigner.framework/Versions/4/Headers/extension.h to qwt/src/QtDesigner/
  • /usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtDesigner.framework/Versions/4/Headers/QDesignerCustomWidgetInterface
  • /usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtDesigner.framework/Versions/4/Headers/customwidget.h
  • /usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtDesigner.framework/Versions/4/Headers/QDesignerTaskMenuExtension
  • /usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtDesigner.framework/Versions/4/Headers/taskmenu.h

This was getting tedious. I tried a make in the terminal but got the same errors. There must be a way to just specific the sodding path

  • /usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtDesigner.framework/Versions/4/Headers/QExtensionFactory
  • /usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtDesigner.framework/Versions/4/Headers/default_extensionfactory.h

Finally a different error

:-1: error: [resources/qrc_qwt_designer_plugin.cpp] Error 127

In full

moc ../../qwt/designer/qwt_designer_plotdialog.h
compiling moc/moc_qwt_designer_plotdialog.cpp
rcc ../../qwt/designer/qwt_designer_plugin.qrc
/bin/sh: /usr/local/bin/rcc: No such file or directory
make[1]: *** [resources/qrc_qwt_designer_plugin.cpp] Error 127
make: *** [sub-designer-make_default-ordered] Error 2
03:05:50: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project qwt (kit: Qt 4.8.7 (4.8.7_6.reinstall))
When executing step "Make"
03:05:50: Elapsed time: 00:04.

Need a binary rcc. From https://github.com/robocorp/rcc

Install with brew

brew install robocorp/tools/rcc

However, the error persisted, in a different form

rcc ../../qwt/designer/qwt_designer_plugin.qrc
Error: unknown command "qwt_designer_plugin" for "rcc"
Run 'rcc --help' for usage.
Error: [rcc v9.16.0] unknown command "qwt_designer_plugin" for "rcc"
make[1]: *** [resources/qrc_qwt_designer_plugin.cpp] Error 1
make: *** [sub-designer-make_default-ordered] Error 2
03:14:21: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project qwt (kit: Qt 4.8.7 (4.8.7_6.reinstall))
When executing step "Make"
03:14:21: Elapsed time: 00:01.

I gave up for the night….

Afterthought about plugins (qwt build)

At least it was a different error, I had conquered the directory naming, and I needed to find a way to specify the PATH. Also, why was the designer being build – maybe I didn’t need it and could suppress it… had the main qwt already been built, and I was now building supplemental (designer) plugin shit..?

See “Nothing to be done for `first'” message when ‘make’ qwt, which states

These lines actually tell you that the library was built:

mv -f libqwt.so ../lib/ 
mv -f libqwt.so.6 ../lib/ 
mv -f libqwt.so.6.1 ../lib/

Just check lib directory.

I get two mv commands in the compiler output:

mv -f qwt ../../qwt/lib/qwt.framework/Versions/6/qwt

and

mv -f qwtmathml ../../../qwt/lib/qwtmathml.framework/Versions/6/qwtmathml

So it would appear that I’m getting the qwt framework, plus qwt.mathml framework, which examination of the lib directory confirms.

In /usr/local/Cellar/qwt/6.1.6_1/lib/qwt.framework

qwt frameworks in lib directory

Path

Path to qwt frameworks in lib directory

From Qt: *.pro vs *.pri, to prevent the QwtDesigner from being built, comment out the following line, in qwtconfig.pri

QWT_CONFIG     += QwtDesigner

Doing so means that the qwt build completes successfully..!

Next day – day 10 (qwt build)

Briefly, going back to the QwtDesigner and trying the rcc command manually gave the same error

$ cd qwt/designer/
$ ls
Makefile			qwt_designer_plotdialog.cpp
designer.pro			qwt_designer_plotdialog.h
moc				qwt_designer_plugin.cpp
obj				qwt_designer_plugin.h
pixmaps				qwt_designer_plugin.qrc
plugins				resources
$ rcc qwt_designer_plugin.qrc 
Error: unknown command "qwt_designer_plugin.qrc" for "rcc"
Run 'rcc --help' for usage.
Error: [rcc v9.16.0] unknown command "qwt_designer_plugin.qrc" for "rcc"
$

However, the command should run, see line 2406.

Trying to finish SerialPlot (SerialPlot build)

Nevertheless, now that everything compiles separately, SerialPlot should now compile and build… right?

Some edits to SerialPlot.pro are necessary to reflect the change of directory name from qwt-6.0.1 to just qwt:

win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../qwt-6.0.1/lib/release/ -lqwt
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../qwt-6.0.1/lib/debug/ -lqwt
else:mac: LIBS += -F$$PWD/../qwt-6.0.1/lib/ -framework qwt
else:unix: LIBS += -L$$PWD/../qwt-6.0.1/lib/ -lqwt

INCLUDEPATH += $$PWD/../qwt-6.0.1/src
DEPENDPATH += $$PWD/../qwt-6.0.1/src

to

win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../qwt-6.0.1/lib/release/ -lqwt
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../qwt-6.0.1/lib/debug/ -lqwt
else:mac: LIBS += -F$$PWD/../qwt/lib/ -framework qwt
else:unix: LIBS += -L$$PWD/../qwt/lib/ -lqwt

INCLUDEPATH += $$PWD/../qwt/src
DEPENDPATH += $$PWD/../qwt/src

However, I still got the same two errors as where we had left off previously (see New day (9)):

g++ -c -pipe -g -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/etc/qt4/mkspecs/macx-g++ -I../SerialPlot -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Cellar/qt@4/4.8.7_6.reinstall/lib/QtGui.framework/Versions/4/Headers -I/usr/local/include -I../qextserialport/src -I../qwt/src -I../qextserialport/src -I. -I. -I../SerialPlot -I. -F/usr/local/lib -o moc_qextserialport.o moc_qextserialport.cpp
moc_qextserialport.cpp:96:30: error: member access into incomplete type 'QextSerialPortPrivate'
        case 13: _t->d_func()->_q_canRead(); break;
                             ^
./../qextserialport/src/qextserialport.h:167:7: note: forward declaration of 'QextSerialPortPrivate'
class QextSerialPortPrivate;
      ^
1 error generated.
make: *** [moc_qextserialport.o] Error 1
22:08:31: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project SerialPlot (kit: Desktop)
When executing step "Make"
22:08:31: Elapsed time: 00:26.

Previously I had been at a loss as to why I was no longer getting the ld: framework not found qwt error, and why I was seeing these two new errors instead. Had it been due to the symlink..? I think that the symlink was a red herring and in fact the qwt build had progressed far enough as to make a qwt framework, which meant that the SerialPlot build was no longer barffing on qwt and had in fact moved on passed that and on to these two new errors.

Actually after looking at the output of the compiler it seemed like these two errors were way before the qwt issue. Delving in to QtCreator setup I found that the selected kit was Desktop and not qt4.8.7. Maybe this was the issue..? However, changing it did not remove the two errors.

All of the paths in SerialPlot.pro pointing to qextserialport, seemed fine, except… there was still the issue of the qextserailport libraries being wrongly created in qextserailport/ rather than qextserailport/src/build/ which was where the Serialplot was looking for them.

qextserialport libraries in the wrong directory

Copying all of the libraries (including the debug libraries) into the src/build/ directory didn’t help.

I added these lines to SerialPlot.pro, as a OSX conditional was missing, and I didn’t know if the unix: conditional would count.

win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../qextserialport/src/build/ -lqextserialport
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../qextserialport/src/build/ -lqextserialportd
#else:mac: LIBS += -l$$PWD/../qextserialport/src/build/ -lqextserialport
else:mac: LIBS += -l$$PWD/../qextserialport/ -lqextserialport
else:unix:!symbian: LIBS += -L$$PWD/../qextserialport/src/build/ -lqextserialport

Neither of the two lines helped.

I stared at these two pages for a long time:

I was considering making a new directory of the sources files at this point, in case I had messed up something, see A new start below. I used INCLUDEPATH. This eased compilation of qwt considerably. I managed to get an application to build.

This above particular thread of disaster I left as it was though… hopefully never to return to.

Summary

See the Summary at the bottom of the page.

Conclusion

This is probably the most arse about face way of doing it, and is (most likely) down to my inexperience and ineptitude with Qt and QtCreator – incorrectly set paths, poorly configured (or misunderstood) project files (.pro), etc.. However, at least it is up and running.

Other issues of note

  • The confusing choice of using either desktop kit and the Qt 4.8.7, when first opening a project in QtCreator. Just choose the Qt 4.8.7 kit.
  • When opening a project in QtCreator I really had the feeling of just having to randomly clicking settings and dialogs just to work the project to open without warnings.
  • Upon first opening the qwt project, there was a message about qmake default spec (I forget the exact wording, possibly: Could not find qmake spec ‘default’), this question and answer could explain a lot, I have this error in QT creator: Could not find qmake configuration file linux-g++-64. However, the message vanished when I first made the build.
    • From the INSTALL readme file for qwt, it states
    • In the recent Qt4 releases the default target of qmake is to generate
      XCode project files instead of makefiles. So you might need to do the
      following:
      
      qmake -spec macx-g++
  • There were a number of warnings for all three project, which I ignored and glossed over in the above log. These may be tackled later…. below.
  • See Static and Dynamic Libraries for OS X.
  • It is annoying that the .pri and .pro extensions are recognised as KiCad files
  • There is a disparity in the SerialPlot .pro file:
    • There is a mac entry for qwt
      • win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../qwt-6.0.1/lib/release/ -lqwt
        else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../qwt-6.0.1/lib/debug/ -lqwt
        else:mac: LIBS += -F$$PWD/../qwt-6.0.1/lib/ -framework qwt
        else:unix: LIBS += -L$$PWD/../qwt-6.0.1/lib/ -lqwt
    • no mac entry for qextserialport
      • win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../qextserialport/src/build/ -lqextserialport
        else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../qextserialport/src/build/ -lqextserialportd
        else:unix:!symbian: LIBS += -L$$PWD/../qextserialport/src/build/ -lqextserialport
  • Why did the qt folder get renamed XXXX.reinstall?
  • The Could not find qmake spec 'default'. warning reappeared in qwt-6.2.0, under General Messages in QtCreator. From QMAKESPEC, this the default spec is the OS specific options, in etc/qt4/mkspecs.
    • There was also Failed to set up kit for Qbs: Error reading qconfig.h; could not determine whether Qt is using Cocoa or Carbon in qwt-6.2.0, under General Messages in QtCreator.

qwt - General Messages

  • Qt 4.8.7 had a persistent warning, which Qt 5.15.2 did not exhibit:
ABI detection failed: Make sure to use a matching compiler when building.
No qmlviewer installed

Qt 4.8.7 Warnings - ABI, qmlviewer

Cheats

  • Copying the qextserialport dylib files to /src/build
  • Copying the qsvggenerator.h and qsvgrenderer.h headers to qwt-6.0.1/src
  • Copying a load of headers: The qsvggenerator.h, qsvgrenderer.h, QtOpenGL/qglcolormap.h, qgl.h, QtOpenGL/qgl.h, and qglframebufferobject.h header files to qwt-6.2.0/src
  • sym link for qt directory name, pointing to the .rename directory
  • sym link qt4 to /usr/local/cellar/qt@4 as the @ seemed to be causing bash completion issues… ln -s /usr/local/Cellar/qt@4 /usr/local/Cellar/qt4
  • symlink Qt framework files to /Library/Frameworks. Such as QtSvg, QtGui, QtOpenGL and QtCore

Random crazy attempts and clutching a straws thoughts

These can be ignored

Changing the env vars in QtCreator

(Ignore this, I’m clutching t straws)

See Setting Environment Variables for All Projects in Qt Creator

In this dialog,

QtCreator - Kit Preferences
QtCreator – Kit Preferences

click change environment, and add

QT_INSTALL_HEADERS=/usr/local/Cellar/qt@4/4.8.7_6_reinstall/include

Like so

QtCreator - Edit Environment
QtCreator – Edit Environment

Then the env var stays the bloody same!!!

QtCreator - Build & Run - Qt Versions
QtCreator – Build & Run – Qt Versions

What is the syntax!???

See Configuring qmake

 

 

Setting Library paths on OSX

Instead of randomly moving or symlinking libraries to /Library/Frameworks, is there a way of just specifying a path in an environment variable? I didn’t find anything definitive nor recommended (due to OS changes and security issues), but these links may be useful:

Gotchas

Qt project directory names

My main gotcha was that the Qwt source directory was not named simply qwt, but had a version number in it.

I had been misled by these two lines, to think it was Ok to check the version number in the name:

INCLUDEPATH += $$PWD/../qwt-6.0.1/src
DEPENDPATH += $$PWD/../qwt-6.0.1/src

However, there must be a way to have version numbers in the directory name… maybe by also changing the name of the .pro file. [However, this would also require the .pro file of the calling project to be edited as well, to change the name of any referenced .pro files]. Mind you, the path would have to be changed anyway in the lines above, anyway, to

INCLUDEPATH += $$PWD/../qwt/src
DEPENDPATH += $$PWD/../qwt/src

 

Symlink (in terminal), don’t copy (in Finder), frameworks

Run

sudo ln -s /usr/local/Cellar/qt4/4.8.7_6/lib/QtXml.framework /Library/Frameworks/QtXml.framework

instead of just option dragging (copying) in Finder.

The latter didn’t seem to work, even though it should create a real copy.

I discovered this with the QtXml.framework, see New Day (9)Directory and .pro file naming mismatch above.

 

Biggest issues

As there is a lot of back and forth between the different builds, it is important to remember that the main issues that were being chased were:

  • nullptr issue for qwt designer
  • qwt not found for SerialPlot
  • rcc issue for QwtDesigner

The sections Summary and A new start have been moved to Compiling Qt SerialPlot (for OS X)

Outstanding issues

  • rcc error when building QwtDesigner

Bundling the frameworks into the application bundle

Unfortunately, we are not finished yet. To make SerialPlot portable, the Qwt and Qt frameworks, upon which SerialPlot depends, need to be bundled into the SerialPlot.app application bundle.

See Qt for macOS – Deployment for further details.

This bundling of the frameworks can be done either manually, which I cover below, or by using the purpose built script bundleframeworks_SerialPlot.sh. You could also use the macdeployqt command, which I am not going to cover here.

First we need to see which frameworks SerialPlot depends upon.

$ otool -L SerialPlot.app/Contents/MacOS/SerialPlot

This gives…

$ otool -L SerialPlot.app/Contents/MacOS/SerialPlot 
SerialPlot.app/Contents/MacOS/SerialPlot:
	/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1455.255.0)
	qwt.framework/Versions/6/qwt (compatibility version 6.0.0, current version 6.0.1)
	/usr/local/lib/libqextserialport.1.dylib (compatibility version 1.2.0, current version 1.2.0)
	/usr/local/opt/qt@4/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.8.0, current version 4.8.7)
	/usr/local/opt/qt@4/lib/QtCore.framework/Versions/4/QtCore (compatibility version 4.8.0, current version 4.8.7)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4)
MacBook-Pro-van-Macbook:SerialPlot macbook$

So, at the very least, we will need to bundle in:

  • qwt.framework
  • libqextserialport.dylib
  • QtGui.framework
  • QtCore.framework

So we copy these to SerialPlot.app/Contents/Frameworks/

$ mkdir SerialPlot.app/Contents/Frameworks
$ cp -R ../qwt/lib/qwt.framework SerialPlot.app/Contents/Frameworks
$ cp -R ../qextserialport/libqextserialport.dylib SerialPlot.app/Contents/Frameworks
$ cp -R ../qextserialport/libqextserialport.1.dylib SerialPlot.app/Contents/Frameworks
$ cp -R ../qextserialport/libqextserialport.1.2.dylib SerialPlot.app/Contents/Frameworks
$ cp -R ../qextserialport/libqextserialport.1.2.0.dylib SerialPlot.app/Contents/Frameworks
$ cp -R /Library/Frameworks/QtGui.framework SerialPlot.app/Contents/Frameworks
$ cp -R /Library/Frameworks/QtCore.framework SerialPlot.app/Contents/Frameworks

The last two is assuming that you copied QtGui and QtCore to /Library/Frameworks previously, as I did. Did I mention that above (TODO check??!!). If you didn’t then copy them from /usr/local/opt/qt@4/lib/.

Changing the reference to these frameworks, for the SerialPlot application binary

$ install_name_tool -change /usr/local/opt/qt@4/lib/QtGui.framework/Versions/4/QtGui @rpath/QtGui.framework/Versions/4/QtGui SerialPlot.app/Contents/MacOS/SerialPlot

$ install_name_tool -change /usr/local/opt/qt@4/lib/QtCore.framework/Versions/4/QtCore @rpath/QtCore.framework/Versions/4/QtCore SerialPlot.app/Contents/MacOS/SerialPlot

$ install_name_tool -change qwt.framework/Versions/6/qwt @rpath/qwt.framework/Versions/6/qwt SerialPlot.app/Contents/MacOS/SerialPlot

$ install_name_tool -change /usr/local/lib/libqextserialport.1.dylib @rpath/libqextserialport.1.dylib SerialPlot.app/Contents/MacOS/SerialPlot

Now to check for the dependencies that these four frameworks have themselves. Remember to use the library path given by the output of otool -Lwhen run on the application binary (i.e. the output above)

Running otool -L on SerialPlot.app/Contents/Frameworks/qwt.framework/Versions/6/qwt

or on the path shown by the output of otool -L, which (in this case) there isn’t one.

$ otool -L qwt.framework/Versions/6/qwt 
qwt.framework/Versions/6/qwt:
	qwt.framework/Versions/6/qwt (compatibility version 6.0.0, current version 6.0.1)
	/usr/local/opt/qt@4/lib/QtSvg.framework/Versions/4/QtSvg (compatibility version 4.8.0, current version 4.8.7)
	/usr/local/opt/qt@4/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.8.0, current version 4.8.7)
	/usr/local/opt/qt@4/lib/QtCore.framework/Versions/4/QtCore (compatibility version 4.8.0, current version 4.8.7)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4)
$

Shows that qwt depends upon QtSvg, QtGui and QtCore

Running otool -L on libqextserialport

$ otool -L /usr/local/lib/libqextserialport.1.dylib
/usr/local/lib/libqextserialport.1.dylib:
	/usr/local/lib/libqextserialport.1.dylib (compatibility version 1.2.0, current version 1.2.0)
	/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1455.255.0)
	/usr/local/opt/qt@4/lib/QtCore.framework/Versions/4/QtCore (compatibility version 4.8.0, current version 4.8.7)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4)
$ 

Shows that libqextserialport depends upon QtCore.

Running otool -L on QtGui

$ otool -L /usr/local/opt/qt@4/lib/QtGui.framework/Versions/4/QtGui
/usr/local/opt/qt@4/lib/QtGui.framework/Versions/4/QtGui:
	/usr/local/opt/qt@4/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.8.0, current version 4.8.7)
	/usr/local/Cellar/qt@4/4.8.7_6/lib/QtCore.framework/Versions/4/QtCore (compatibility version 4.8.0, current version 4.8.7)
	/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 158.0.0)
	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
	/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1561.60.100)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4)
	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 50.0.0)
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1454.90.0)
	/System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics (compatibility version 64.0.0, current version 1161.21.0)
	/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 822.36.0)
	/System/Library/Frameworks/CoreText.framework/Versions/A/CoreText (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1454.90.0)
	/System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO (compatibility version 1.0.0, current version 1.0.0)
	/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
$ 

Shows QtGui depends upon QtCore, as expected.

And running otool -L on QtCore

$ otool -L /usr/local/opt/qt@4/lib/QtCore.framework/Versions/4/QtCore
/usr/local/opt/qt@4/lib/QtCore.framework/Versions/4/QtCore:
	/usr/local/opt/qt@4/lib/QtCore.framework/Versions/4/QtCore (compatibility version 4.8.0, current version 4.8.7)
	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4)
	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 50.0.0)
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1454.90.0)
	/System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 58286.70.7)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.0)
	/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 822.36.0)
$

Depends upon nothing Qt related, again as expected.

So, we have to add QtSvg to the bundle as it is a dependancy of qwt.

$ cp -R /Library/Frameworks/QtCore.framework SerialPlot.app/Contents/Frameworks

Now set the dependencies’ names for qwt

$ install_name_tool -change /usr/local/opt/qt@4/lib/QtCore.framework/Versions/4/QtCore @rpath/QtCore.framework/Versions/4/QtCore SerialPlot.app/Contents/Frameworks/qwt.framework/Versions/6/qwt

$ install_name_tool -change /usr/local/opt/qt@4/lib/QtGui.framework/Versions/4/QtGui @rpath/QtGui.framework/Versions/4/QtGui SerialPlot.app/Contents/Frameworks/qwt.framework/Versions/6/qwt

$ install_name_tool -change /usr/local/opt/qt@4/lib/QtSvg.framework/Versions/4/QtSvg @rpath/QtSvg.framework/Versions/4/QtSvg SerialPlot.app/Contents/Frameworks/qwt.framework/Versions/6/qwt

Now set the dependencies’ names for libqextserialport,

$ install_name_tool -change /usr/local/opt/qt@4/lib/QtCore.framework/Versions/4/QtCore @rpath/QtCore.framework/Versions/4/QtCore SerialPlot.app/Contents/Frameworks/libqextserialport.1.dylib

Now set the dependencies’ names for QtGui, noting that a different path (i.e. Cellar and not opt) is required

$ install_name_tool -change /usr/local/Cellar/qt@4/4.8.7_6/lib/QtCore.framework/Versions/4/QtCore @rpath/QtCore.framework/Versions/4/QtCore SerialPlot.app/Contents/Frameworks/QtGui.framework/Versions/4/QtGui

Now we need to check the dependencies of the newly added QtSvg

$ otool -L /usr/local/opt/qt@4/lib/QtSvg.framework/Versions/4/QtSvg
/usr/local/opt/qt@4/lib/QtSvg.framework/Versions/4/QtSvg:
	/usr/local/opt/qt@4/lib/QtSvg.framework/Versions/4/QtSvg (compatibility version 4.8.0, current version 4.8.7)
	/usr/local/Cellar/qt@4/4.8.7_6/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.8.0, current version 4.8.7)
	/usr/local/Cellar/qt@4/4.8.7_6/lib/QtCore.framework/Versions/4/QtCore (compatibility version 4.8.0, current version 4.8.7)
	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4)
$ 

Shows it depends only upon QtCore and QtGui, so change its dependencies’ names

$ install_name_tool -change /usr/local/Cellar/qt@4/4.8.7_6/lib/QtCore.framework/Versions/4/QtCore @rpath/QtCore.framework/Versions/4/QtCore SerialPlot.app/Contents/Frameworks/QtSvg.framework/Versions/4/QtSvg

$ install_name_tool -change /usr/local/Cellar/qt@4/4.8.7_6/lib/QtGui.framework/Versions/4/QtGui @rpath/QtGui.framework/Versions/4/QtGui SerialPlot.app/Contents/Frameworks/QtSvg.framework/Versions/4/QtSvg

That should be it… I don’t think I’ve forgotten anything.

Then run otool -L on all of them as a sanity check

$ otool -L SerialPlot.app/Contents/Resources/MacOS/SerialPlot
$ otool -L SerialPlot.app/Contents/Frameworks/qwt.framework/Versions/6/qwt
$ otool -L SerialPlot.app/Contents/Frameworks/libqextserialport.1.dylib
$ otool -L SerialPlot.app/Contents/Frameworks/QtSvg.framework/Versions/4/QtSvg
$ otool -L SerialPlot.app/Contents/Frameworks/QtGui.framework/Versions/4/QtGui
$ otool -L SerialPlot.app/Contents/Frameworks/QtCore.framework/Versions/4/QtCore

Note: There is no need to run install_name_tool -id

Bundle Cocoa platform plugin

Unlike Qt5, there doesn’t seem to be a libqcocoa.dylib library.

This is the end, my friend.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s