Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build with (official binary installer) Qt 5.6 on OS X not supported #7714

Closed
paveljanik opened this issue Mar 18, 2016 · 20 comments
Closed

Build with (official binary installer) Qt 5.6 on OS X not supported #7714

paveljanik opened this issue Mar 18, 2016 · 20 comments

Comments

@paveljanik
Copy link
Contributor

Qt 5.6 was released a few days ago (http://blog.qt.io/blog/2016/03/16/qt-5-6-released/).

configure --with-gui=qt5 on OS X (can't test other systems right now) fails with:

checking for QT... no
configure: error: Qt dependencies not found

config.log contains:

configure:22230: checking for QT
configure:22237: $PKG_CONFIG --exists --print-errors "$qt5_modules"
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

Qt 5.6 contains only 2 *.pc files compared to 89 in e.g. 5.4:

pavel$ find Qt/5.4 -name *.pc | wc -l
      89
pavel$ find Qt5.6.0 -name *.pc
Qt5.6.0/5.6/clang_64/lib/pkgconfig/Qt5OpenGLExtensions.pc
Qt5.6.0/5.6/clang_64/lib/pkgconfig/Qt5UiTools.pc
pavel$ 

Relevant upstream change: https://codereview.qt-project.org/#/c/140954/

@paveljanik
Copy link
Contributor Author

Ready for some hackery?

Qt installed from the offline installer, to /tmp/Qt5.6.0.

# To save typing
export QTDIR="/tmp/Qt5.6.0/5.6/clang_64/"

# Prepare includes - HACK
cd ${QTDIR}/include
for fwk in `cd ../lib/; ls -1d *framework`; do FWK=`echo $fwk | sed 's#.framework##'`; ln -sf ../lib/$fwk/Versions/Current/Headers $FWK; done
cd -

# Use moc from Qt5.6.0, not the old one from the system, important!
export PATH=${QTDIR}/bin/:$PATH

# HACK - missing pkgconfig files in Qt5.6
QT_CFLAGS="-I${QTDIR}/include -I${QTDIR}/include/QtWidgets -I${QTDIR}/include/QtCore -I${QTDIR}/include/QtGui -I${QTDIR}/include/QtNetwork" QT_LIBS="-F${QTDIR}/lib -framework QtCore -framework QtNetwork -framework QtGui -framework QtWidgets" ./configure --with-gui=qt5

make

# Fix rpath
#
# Without it:
#
#dyld: Library not loaded: @rpath/QtCore.framework/Versions/5/QtCore
#  Referenced from: /private/tmp/bitcoin-master.qt/src/qt/./bitcoin-qt
#  Reason: image not found
# Trace/BPT trap: 5
install_name_tool -add_rpath ${QTDIR}/lib src/qt/bitcoin-qt

I'd be happy if someone replicates this.

@paveljanik
Copy link
Contributor Author

Compare with #5728...

@theuni
Copy link
Member

theuni commented Mar 18, 2016

See here: Homebrew/legacy-homebrew@620baaf

Looks like this might not affect us with Homebrew, and Linux/Win builds aren't affected either. @paveljanik mind testing with an updated Homebrew?

@paveljanik
Copy link
Contributor Author

I use Macports. And Qt from the binary installer, so I can't test it myself.

@fanquake
Copy link
Member

I can confirm that Homebrew is unaffected. Just compiled master + Qt 5.6.0 with no issue.
qt56

@paveljanik
Copy link
Contributor Author

@fanquake great! Can you please upload all pkgconfig files somewhere?

@paveljanik paveljanik changed the title Build with Qt 5.6 not supported Build with (official binary installer) Qt 5.6 on OS X not supported Mar 19, 2016
@paveljanik
Copy link
Contributor Author

@fanquake ping

@jonasschnelli
Copy link
Contributor

@paveljanik:

Thanks for having a closer look at this.

You might want to check:
https://github.com/Homebrew/homebrew/blob/master/Library/Formula/qt5.rb#L29
and
https://raw.githubusercontent.com/Homebrew/patches/e8fe6567/qt5/restore-pc-files.patch

I also attached my local Qt5.6 pc files:
pkgconfig.zip

@fanquake
Copy link
Member

fanquake commented Apr 1, 2016

@paveljanik sorry for not following up. If you don't have enough info with what @jonasschnelli has provided, let me know and i'll upload my files.

@paveljanik
Copy link
Contributor Author

@fanquake No problem, thank you. Files from @jonasschnelli are enough.

So the new summary of problems, redone from clean installation of original binary Qt installer:

  1. four pkgconfig files are missing: Qt5Core.pc, Qt5Gui.pc, Qt5Network.pc and Qt5Widgets.pc. The problem is worked around in brew (https://github.com/Homebrew/homebrew/blob/master/Library/Formula/qt5.rb#L29).
  2. '# Prepare includes - HACK' needed. Again, worked around in brew already (https://github.com/Homebrew/homebrew/blob/master/Library/Formula/qt5.rb#L112).
  3. rpath problems (https://codereview.qt-project.org/#/c/138349). Original installer installs libraries with @rpath ID:
$ otool -l QtNetwork | grep rpath/QtNetwork
         name @rpath/QtNetwork.framework/Versions/5/QtNetwork (offset 24)
$

This can be changed by:

lib$ for fwk in *framework; do FWK=`echo $fwk | sed 's#.framework##'`; install_name_tool -id `pwd`/$fwk/$FWK $fwk/$FWK; done

This can be fixed in the configure phase of Qt, with -no-rpath as already done in brew.

To sum up: you can build with the original installer after these three steps...

@paveljanik
Copy link
Contributor Author

Two more .pc files missing: Qt5Test.pc added. But there is no Qt5DBus.pc in Jonas' files. This results in this difference in the build log:

-checking for QT_DBUS... yes
+checking for QT_DBUS... no
-checking whether to build GUI with support for D-Bus... yes
+checking whether to build GUI with support for D-Bus... no

Strange.

@paveljanik
Copy link
Contributor Author

After adding Qt5DBus.pc (similar to the previous Qt version), the build is now complete.

@laanwj
Copy link
Member

laanwj commented Apr 2, 2016

We should probably document this somewhere, for example paste @paveljanik 's summary into the OSX build doc, until this is fixed in upstream (and it looks like they broke it on purpose 💩) I don't think you'll be the only one stumbling on this

@paveljanik
Copy link
Contributor Author

I'll prepare something, probably in the form of contrib script to fix the local installation coming from the official installer with some documentation...

@paveljanik paveljanik reopened this Apr 2, 2016
@paveljanik
Copy link
Contributor Author

It is not worth the effort to prepare script for this. See #7789 for small doc addition.

@danieleTrimarchi
Copy link

Hi,

I have downloaded the Qt5.7 for macOsX and I have the problem discussed here: only Qt5UiTools.pc and Qt5OpenGLExtensions.pc in my $(QTROOT)/5.7/clang_64/lib/pkgconfig.

The links provided by paveljanik on April, the 1st appear to be broken, is this still the path to fix the local installation of Qt coming from the official installer?

Can you guys assist with this and point me to the location of the patches?

Thanks,
Daniele

@paveljanik
Copy link
Contributor Author

I have not updated yet. Please try https://github.com/Homebrew/homebrew-core/blob/master/Formula/qt5.rb#L166

@paveljanik
Copy link
Contributor Author

OK, I have tested with 5.7.1:

  1. add include links:
cd include
for fwk in `cd ../lib/; ls -1d *framework`; do FWK=`echo $fwk | sed 's#.framework##'`; ln -sf ../lib/$fwk/Versions/Current/Headers $FWK; done
  1. fix rpath:
cd lib
for fwk in *framework; do FWK=`echo $fwk | sed 's#.framework##'`; install_name_tool -id `pwd`/$fwk/$FWK $fwk/$FWK; done
  1. add pkgconfig files: http://tmp.janik.cz/Bitcoin/qt5.7.1-addedpkgconfig.tar.gz

It works afterwards... Can you test it?

@danieleTrimarchi
Copy link

danieleTrimarchi commented Dec 27, 2016 via email

@danieleTrimarchi
Copy link

danieleTrimarchi commented Nov 30, 2018

Hi paveljanik,
I am still trying to generate the .pc files for Qt : would you be able to help me with this?
Thanks,
Daniele

@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants