bugGNU Octave - Bugs: bug #55282, QT_CPPFLAGS and QT_LDFLAGS...

 
 

bug #55282: QT_CPPFLAGS and QT_LDFLAGS command-line / environment vars ignored by configure

Submitted by:  Ben Abbott <bpabbott>
Submitted on:  Wed 26 Dec 2018 12:49:30 AM UTC  
 
Category:  Configuration and Build System Severity:  1 - Wish
Priority:  1 - Later Item Group:  Build Failure
Status:  Confirmed Assigned to:  None
Originator Name:  Ben Abbott Open/Closed:  Open
Release:  dev Operating System:  Any

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

( Jump to the original submission)

Thu 03 Jan 2019 02:28:57 PM UTC, comment #23: 

opps.  If the symbolic link Qt include directory tree is a Homebrew creation, and not a Qt creation, we shouldn't rely on it.

Ben Abbott <bpabbott>
Project Member
Thu 03 Jan 2019 06:24:58 AM UTC, comment #22: 

Ok. If the symbolic like Qt include directory tree is a Homebrew creation,  and not a Qt creation, we shouldn't rely on it.

But I think that also means that the standard release of Qt on macOS isn't functional since <QtCore/qvariant.h>  will not be located.

Ben Abbott <bpabbott>
Project Member
Thu 03 Jan 2019 03:33:09 AM UTC, comment #21: 

> Andrew, please see Mike's suggestion below. Can you report the problem with pkg-config back to Homebrew?


I'll look in to it. I don't quite understand the issue well enough to make a bug report yet; playing around with it tonight.

> Thus "# include <module/include.h>" works on linux, but cannot work on macOS unless the linux directory structure is created using symbolic links. The Qt from Homebrew is setup this way (so -I/usr/opt/qt/include could be added to each module's pc-file). However, I don't know if this directory structure is Homebrew's creation or part of Qt. If the latter, a bug report could be filed.


This is Homebrew's creation. It's done as part of the qt formula's install script. A vanilla Qt install will not have them.

https://github.com/Homebrew/homebrew-core/blob/0de5e99130bb5462af029d0d5d238b7a9b09e817/Formula/qt.rb#L52-L57

    # The pkg-config files installed suggest that headers can be found in the
    # `include` directory. Make this so by creating symlinks from `include` to
    # the Frameworks' Headers folders.
    Pathname.glob("#{lib}/*.framework/Headers") do |path|
      include.install_symlink path => path.parent.basename(".framework")
    end

That is, Homebrew does not change Qt's pkgconfig files, but it does alter the layout of the Qt installation to reflect what its pkgconfig files are saying.

Andrew Janke <apjanke>
Mon 31 Dec 2018 01:32:09 AM UTC, comment #20: 

I agree. It's annoying, but not a priority.

Ben Abbott <bpabbott>
Project Member
Sun 30 Dec 2018 06:34:09 PM UTC, comment #19: 

I think that we should fix this in the same changeset for all affected libraries, and this is not a new issue nor urgently needed for the Octave 5 release.

Mike Miller <mtmiller>
Project Administrator
Sun 30 Dec 2018 06:31:41 PM UTC, comment #18: 

I agree that is a good rephrasing of the issue, and agree that that does not work. It also does not work for some other libraries used by Octave. It does work for any library that we detect using the m4 macro OCTAVE_CHECK_LIB. It does not work for FLTK_CPPFLAGS/LDFLAGS, MAGICK_CPPFLAGS/LDFLAGS, LLVM_CPPFLAGS/LDFLAGS, and QT_CPPFLAGS/LDFLAGS, possibly some others.

To be specific, by way of example:

$ export MAGICK_CPPFLAGS=-I/usr/local/include/GraphicsMagick
$ ../configure MAGICK_CPPFLAGS=-I/usr/local/include/GraphicsMagick
[…]
$ grep ^MAGICK Makefile
MAGICK_CPPFLAGS = -I/usr/include/GraphicsMagick
MAGICK_LDFLAGS =
MAGICK_LIBS = -lGraphicsMagick++ -lGraphicsMagick

For any of these libraries, this can be easily worked around by using the global CPPFLAGS and LDFLAGS user variables.

Mike Miller <mtmiller>
Project Administrator
Sun 30 Dec 2018 01:20:15 PM UTC, comment #17: 

Returning to original problem, and rephrasing, setting QT_CPPFLAGS and QT_LDFLAGS via the shell environment, or as a configure option, should produce the expected result.

Ben Abbott <bpabbott>
Project Member
Sun 30 Dec 2018 12:45:32 AM UTC, comment #16: 

@Mike,

My apologies, I haven't been as specific about the troubles on macOS as I should be. With the upgrades to Qt 5.10 and 5.11, I didn't worry about the Qt details. I was just happy to have Octave build, and didn't worry about the "why".  With the present discussion (your input) the situation is clarifying for me.

On macOS, pkg-config hasn't provided a root include path for any version of Qt. For some versions the "-L/usr/.../lib" (5.11) needed to be added manually, for other versions "-F/usr/.../lib" needed to be added (5.10, 5.12).

I expect all of this can be resolved if all frameworks and libraries were present in a root lib directory (they are), and if all modules' include directories were present in a root Qt include path. If that were done it would resolve the Qt Creator problem as well as the autotools problem for building with Qt (the autotools fix can piggy-back on the Qt Creator fix).

Ben Abbott <bpabbott>
Project Member
Sat 29 Dec 2018 10:52:27 PM UTC, comment #15: 

That bug report looks specific to the Qt Creator IDE, but if you think it's relevant, you can certainly try to get that resolved there.

To me this looks more like a homebrew packaging issue than a Qt upstream issue. As you reported on bug #55187, Qt 5.11 worked for you, and the pkg-config CFLAGS were reported as "-I/usr/local/Cellar/qt/5.11.2/include/QtCore -I/usr/local/Cellar/qt/5.11.2/include", for Qt5Core for example. In your Qt 5.12 installation this changed to "-I/usr/local/Cellar/qt/5.12.0/lib/QtCore.framework/Headers". If these were both installed from homebrew, then I would start there, find out whether Qt or homebrew is responsible for the contents of the pkg-config files, whether this change was intentional or not, and whether something was overlooked when the new version was packaged.

Mike Miller <mtmiller>
Project Administrator
Sat 29 Dec 2018 10:50:21 AM UTC, comment #14: 

Looks like this problem has already been reported.

https://bugreports.qt.io/browse/QTCREATORBUG-20099

I've added a suggestion in the comment section.

Ben Abbott <bpabbott>
Project Member
Sat 29 Dec 2018 10:31:18 AM UTC, comment #13: 

Ok. Understood.

The problem is on macOS the module include-files are located in separate frameworks. While on linux the includes for each module are contained in subdirectories of one directory. Thus "# include <module/include.h>" works on linux, but cannot work on macOS unless the linux directory structure is created using symbolic links. The Qt from Homebrew is setup this way (so -I/usr/opt/qt/include could be added to each module's pc-file). However, I don't know if this directory structure is Homebrew's creation or part of Qt. If the latter, a bug report could be filed.

Ben Abbott <bpabbott>
Project Member
Fri 28 Dec 2018 05:21:42 PM UTC, comment #12: 

Introducing a new pkg-config name "Qt5AutoToolsInclude" would not help anyone. It needs to work with the module names that Octave already tests for, Qt5Core, Qt5Gui, Qt5Network, etc.

Mike Miller <mtmiller>
Project Administrator
Thu 27 Dec 2018 08:00:53 AM UTC, comment #11: 

@Mike

The pkg-config info for Qt includes files like the one below (Qt5Core.pc).

prefix=/usr/local/Cellar/qt/5.12.0
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/lib/QtCore.framework/Headers

host_bins=${prefix}/bin
qt_config=shared qt_framework release c++11 c++14 concurrent dbus reduce_exports stl properties animation textcodec big_codecs codecs textdate datestring doubleconversion filesystemiterator filesystemwatcher gestures itemmodel proxymodel identityproxymodel library mimetype process statemachine regularexpression settings sharedmemory sortfilterproxymodel stringlistmodel systemsemaphore temporaryfile translation xmlstream xmlstreamreader xmlstreamwriter

Name: Qt5 Core
Description: Qt Core module
Version: 5.12.0
Libs: -F${libdir} -framework QtCore
Cflags: -DQT_CORE_LIB -I${includedir} -F${libdir}

To fix this problem, each module's pc-file would need to be modified to include ...

includedir=${prefix}/include

Where this folder includes subfolders which are symbolic links to the headers for each framework.

This seems a bit too much. Meaning the include files for all Modules would be present even if only one module were specified.

An improved, but sloppy, approach would be to add a new pc-file, say "Qt5AutoToolsInclude.pc"

prefix=/usr/local/Cellar/qt/5.12.0
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${libdir}/include

host_bins=${prefix}/bin
qt_config=shared qt_framework release c++11 c++14 concurrent dbus reduce_exports stl properties animation textcodec big_codecs codecs textdate datestring doubleconversion filesystemiterator filesystemwatcher gestures itemmodel proxymodel identityproxymodel library mimetype process statemachine regularexpression settings sharedmemory sortfilterproxymodel stringlistmodel systemsemaphore temporaryfile translation xmlstream xmlstreamreader xmlstreamwriter

Name: Qt5 Autotools Include
Description: All Qt modules
Version: 5.12.0
Libs: -F${libdir}
Cflags: -DQT_CORE_LIB -I${includedir} -F${libdir}

Maybe the Libs should be fully populated with all the modules?

Ben Abbott <bpabbott>
Project Member
Thu 27 Dec 2018 07:40:14 AM UTC, comment #10: 

Andrew, please see Mike's suggestion below. Can you report the problem with pkg-config back to Homebrew?

Ben Abbott <bpabbott>
Project Member
Thu 27 Dec 2018 07:22:16 AM UTC, comment #9: 

Thanks. Then it looks to me like the pkg-config that comes with your installation of Qt is giving you a bad configuration. It should be giving you -I options that point to /usr/local/opt/qt/include that can actually be used, and not the other. If you can fix your Qt pkg-config files, then Octave's configure should set everything up correctly. If you can't, then you will have to use the global CPPFLAGS environment variable.

For other math libraries Octave has options like --with-arpack-includedir=DIR. But Qt is much more complicated and has many more moving parts, and we simply don't have an option or a variable for you to pass in the Qt include directory alone.

You might want to report a bug to homebrew or whoever your packager is for the Qt library, because it seems to me that the pkg-config isn't useful in the state it's in now.

If you pass in CPPFLAGS=-I/usr/local/opt/qt/include, Qt is found and works correctly, so can we close this as working correctly?

Mike Miller <mtmiller>
Project Administrator
Thu 27 Dec 2018 07:16:02 AM UTC, comment #8: 

@Mike

As you may have surmised, qvariant.h is present in the Headers for the QtCore framework.

/usr/local/Cellar/qt/5.12.0/lib/QtCore.framework/Headers/qvariant.h

Ben Abbott <bpabbott>
Project Member
Thu 27 Dec 2018 07:12:07 AM UTC, comment #7: 

@Mike,

Regarding qvairant.h, I think this is the problem. There is no QtCore sub-directory in /usr/local/Cellar/qt/5.12.0/lib/QtCore.framework/Headers.

Meanwhile /usr/local/opt/qt/include/QtCore is a sym-link to /usr/local/Cellar/qt/5.12.0/lib/QtCore.framework/Headers.

Thus adding -I//usr/local/opt/qt/include works with <QtCore/qvariant.h>

Ben Abbott <bpabbott>
Project Member
Thu 27 Dec 2018 07:11:14 AM UTC, comment #6: 

> Note that the configure help string indicates ...


True, unfortunately, Octave doesn't use those variables and instead calls pkg-config with its own set of options. I don't know if there's a way to use the autoconf pkg-config support without implicitly creating these help strings.

Setting that aside, I'm still curious about your system configuration. Your Qt pkg-config -I options include the directories /usr/local/Cellar/qt/5.12.0/lib/QtGui.framework/Headers and /usr/local/Cellar/qt/5.12.0/lib/QtCore.framework/Headers. Does qvariant.h live under those directories anywhere? Or does it only exist under /usr/local/opt/qt5/include? What is the relationship between /usr/local/opt/qt5/include and /usr/local/Cellar/qt/5.12.0/lib/*.framework?

Mike Miller <mtmiller>
Project Administrator
Thu 27 Dec 2018 06:45:06 AM UTC, comment #5: 

Ok, trying again

More information ... paraphrased to only include the relevant detail.

This works

QT_CPPFLAGS="-I/usr/local/opt/qt5/include"
QT_LDFLAGS="-F/usr/local/opt/qt5/lib"
# Needed for make (ex: libgui/graphics/__init_qt__.la)
LDFLAGS="$LDFLAGS $QT_LDFLAGS"
# Needed for configure (ex: check for "QAbstractItemModel::beginResetModel")
CPPFLAGS="$CPPFLAGS $QT_CPPFLAGS"
export CPPFLAGS
export LDFLAGS
./configure ...

But this does not.

QT_CPPFLAGS="-I/usr/local/opt/qt5/include"
QT_LDFLAGS="-F/usr/local/opt/qt5/lib"
./configure   QT_CFLAGS=QT_CPPFLAGS \
     QT_LDFLAGS=QT_LDFLAGS \
     ...

Note that the configure help string indicates ...

  QT_CFLAGS   C compiler flags for QT, overriding pkg-config
  QT_LIBS     linker flags for QT, overriding pkg-config

Ben Abbott <bpabbott>
Project Member
Wed 26 Dec 2018 08:43:55 PM UTC, comment #4: 

I think that got cut off.

1. I think you might be confusing a couple points about QT_CPPFLAGS. One thing is that trying to override QT_CPPFLAGS and QT_LDFLAGS from the shell environment when calling configure doesn't do anything. If I run

./configure --whatever ... QT_CPPFLAGS=-I/tmp

that override has no effect. Same with exporting it in the shell. The only way at the moment (I think) to have QT_CPPFLAGS set correctly is to have a correctly configure pkg-config for Qt.

2. Is pkg-config for Qt on your system correct or not? You have shown that it returns /usr/local/Cellar/qt/5.12.0/lib/QtGui.framework/Headers and /usr/local/Cellar/qt/5.12.0/lib/QtCore.framework/Headers. Are those directories correct and complete? Does qvariant.h exist under /usr/local/Cellar/qt/5.12.0/lib/QtCore.framework/Headers/QtCore (I think that was one of the missing header files in one of your other threads).

3. If I had a GNU/Linux system with Qt installed in a non-standard location and no pkg-config working for it, I would use CPPFLAGS to point to the directories needed. This is a feature, not a bug.

But, assuming you do have pkg-config set correctly and those -I options are correct, the header files do exist, then you shouldn't need to set CPPFLAGS at all.

Mike Miller <mtmiller>
Project Administrator
Wed 26 Dec 2018 10:59:01 AM UTC, comment #3: 

More information ... paraphrased to only include the relevant detail.

This works

Ben Abbott <bpabbott>
Project Member
Wed 26 Dec 2018 06:25:37 AM UTC, comment #2: 

@Mike

By default my pkg-config path does not include Qt.

$ pkg-config --cflags-only-I Qt5Core Qt5Gui
Package Qt5Core was not found in the pkg-config search path.
Perhaps you should add the directory containing `Qt5Core.pc'
to the PKG_CONFIG_PATH environment variable
No package 'Qt5Core' found
Package Qt5Gui was not found in the pkg-config search path.
Perhaps you should add the directory containing `Qt5Gui.pc'
to the PKG_CONFIG_PATH environment variable
No package 'Qt5Gui' found

I use a script to configure octave. Among the several things I set for the environment is the pkg-config path.

$ PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig"
$ PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/opt/qt/lib/pkgconfig"
$ export PKG_CONFIG_PATH
$ pkg-config --cflags-only-I Qt5Core Qt5Gui
-I/usr/local/Cellar/qt/5.12.0/lib/QtGui.framework/Headers -I/usr/local/Cellar/qt/5.12.0/lib/QtCore.framework/Headers

However, the QT_CPPFLAGS  doesn't get set properly during configure. Same for the QT_LDFLAGS during make.

In case it matters, my pkg-config is located in /usr/local/bin

... switching the [Operating System] to [Mac OS].

Ben Abbott <bpabbott>
Project Member
Wed 26 Dec 2018 01:54:33 AM UTC, comment #1: 

I don't think this is true. I think the configure script does set CPPFLAGS to include QT_CPPFLAGS when it runs the test.

I also think that the compilation of '__init_qt__' includes QT_CPPFLAGS correctly.

These all work on my system, where the -I options for Qt only exist in QT_CPPFLAGS.

In another bug report I think you mentioned that you also need to manually set QT_CPPFLAGS on your system. Is it possible that your installation of Qt 5.12 is not correct? What does 'pkg-config --cflags-only-I Qt5Core Qt5Gui' return?

Mike Miller <mtmiller>
Project Administrator
Wed 26 Dec 2018 12:49:30 AM UTC, original submission:  

The use of QT_CPPFLAGS and QT_LDFLAGS isn't consistent. Presently, it is necessary to include the Qt flags in CPPFLAGS and LDFLAGS.

One example are the several (all?) Qt tests. For example, the test for QAbstractItemModel::beginResetModel requires that the Qt flags be included in CPPFLAGS and LDFLAGS or the test will fail.

A second example is compiling _init_qt_.

I expect this is a fairly easy problem to fix. Can someone point me to where flags are added to configure tests? And where flags are added for specific files?

Ben Abbott <bpabbott>
Project Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by apjanke (Posted a comment)
  • -email is unavailable- added by bpabbott
  • -email is unavailable- added by bpabbott (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-12-30 mtmiller Severity3 - Normal => 1 - Wish
        Priority5 - Normal => 1 - Later
        StatusWorks For Me => Confirmed
        Open/ClosedClosed => Open
        Operating SystemMac OS => Any
        SummaryQT_CPPFLAGS and QT_LDFLAGS not always present when needed => QT_CPPFLAGS and QT_LDFLAGS command-line / environment vars ignored by configure
    2018-12-27 bpabbott Open/ClosedOpen => Closed
        Carbon-Copy- => Added floss@apjanke.net
    2018-12-26 bpabbott Operating SystemAny => Mac OS
    2018-12-26 mtmiller StatusNone => Works For Me

    Back to the top


    Powered by Savane 3.5