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 Qt 6 #43

Open
cjmayo opened this issue Dec 28, 2023 · 2 comments
Open

Build with Qt 6 #43

cjmayo opened this issue Dec 28, 2023 · 2 comments

Comments

@cjmayo
Copy link
Contributor

cjmayo commented Dec 28, 2023

No code changes required. On Linux and FreeBSD with Qt >= 6.2.5 it's enough to:

--- a/Makefile.in
+++ b/Makefile.in
@@ -17,9 +17,9 @@ incpath = -I. -I$(PREFIX)/include
 libpath = -L$(PREFIX)/lib
 
 CFLAGS = $(warn) $(dbg) $(opt) $(incpath) -fPIC $(add_cflags) -MMD
-CXXFLAGS = -std=c++11 $(warn) $(dbg) $(opt) $(incpath) -fPIC `pkg-config --cflags Qt5Core Qt5Gui Qt5Widgets` \
+CXXFLAGS = -std=c++17 $(warn) $(dbg) $(opt) $(incpath) -fPIC `pkg-config --cflags Qt6Core Qt6Gui Qt6Widgets` \
 		 $(add_cflags) -MMD
-LDFLAGS = $(libpath) `pkg-config --libs Qt5Core Qt5Gui Qt5Widgets` -lspnav -lX11 \
+LDFLAGS = $(libpath) `pkg-config --libs Qt6Core Qt6Gui Qt6Widgets` -lspnav -lX11 \
 		  $(add_ldflags)
 
 $(bin): $(obj)

Although 6.1 typically moved moc, rcc and uic into a libexec subdirectory so most people will have to set UIC, MOC and RCC.

On Ubuntu 22.04 with Qt 6.2.4, and macOS apparently, the pkg-config files are not installed
https://bugreports.qt.io/browse/QTBUG-86080

causing make to fail - Ubuntu 22.04:

g++ -std=c++17 -pedantic -Wall -g -O3 -I. -I/usr/local/include -fPIC `pkg-config --cflags Qt6Core Qt6Gui Qt6Widgets`  -MMD   -c -o src/main.o src/main.cc
Package Qt6Core was not found in the pkg-config search path.
Perhaps you should add the directory containing `Qt6Core.pc'
to the PKG_CONFIG_PATH environment variable
No package 'Qt6Core' found
Package Qt6Gui was not found in the pkg-config search path.
Perhaps you should add the directory containing `Qt6Gui.pc'
to the PKG_CONFIG_PATH environment variable
No package 'Qt6Gui' found
Package Qt6Widgets was not found in the pkg-config search path.
Perhaps you should add the directory containing `Qt6Widgets.pc'
to the PKG_CONFIG_PATH environment variable
No package 'Qt6Widgets' found
src/main.cc:18:10: fatal error: QApplication: No such file or directory
   18 | #include <QApplication>
      |          ^~~~~~~~~~~~~~
compilation terminated.
make: *** [<builtin>: src/main.o] Error 1
@jtsiomb
Copy link
Contributor

jtsiomb commented Dec 28, 2023

I see. Ok so the first step is to allow the user to choose Qt version during configure.

Ubuntu not packaging the pkgconfig file should probably be considered an ubuntu bug, but we could add a configure flag to let the user specify Qt paths, instead of calling pkg-config.

On MacOSX, homebrew seems to be doing something about this bug: https://github.com/Homebrew/homebrew-core/blob/52f473e5dd31e50afc267821eb7e1a32a2b283a0/Formula/q/qt.rb#L300

@cjmayo
Copy link
Contributor Author

cjmayo commented Dec 29, 2023

Interesting homebrew link. I should have made it clear I don't have access to a Mac. If they are fixing it then maybe it is just a question of waiting for Ubuntu 24.04 and then switching.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants