[Freeciv-tickets] [freeciv] #42402: Qt clients require c++11 (explicitly, on older macOS)

Back to archive index
OSDN Ticket System norep****@osdn*****
Fri Jun 11 15:15:48 JST 2021


#42402: Qt clients require c++11 (explicitly, on older macOS)

  Open Date: 2021-05-26 18:29
Last Update: 2021-06-10 23:15

URL for this Ticket:
    https://osdn.net//projects/freeciv/ticket/42402
RSS feed for this Ticket:
    https://osdn.net/ticket/ticket_rss.php?group_id=12505&tid=42402

---------------------------------------------------------------------

Last Changes/Comment on this Ticket:
2021-06-10 23:15 Updated by: jdlh

Comment:

Configuring with CXXFLAGS="-std=c++11" was successful for branch S2_6 compiling on macOS 10.13.6 High Sierra. I just tried the experiment. The configure script recognised Qt5 as available, and the freeciv-qt client built successfully.
Even so, I am still in favour of accepting this patch, so that the automake scripts will set that flag, instead of relying on the downstream builder.

---------------------------------------------------------------------
Ticket Status:

      Reporter: jdlh
         Owner: (None)
          Type: Bugs
        Status: Open
      Priority: 5 - Medium
     MileStone: (None)
     Component: Bootstrap
      Severity: 5 - Medium
    Resolution: None
---------------------------------------------------------------------

Ticket details:

Freeciv's configure scripts refuse to enable the Qt client or modpack installer on older macOS systems. It seems that the Qt clients have code which requires the C++11 language standard. The automake scripts correctly test for this language support. The clang/LLVM compiler which Apple supplies with older macOS systems defaults to the C++98 standard, but supports newer standards when requested. Thus the configure scripts determine that the compiler is insufficient. The solution is to add an option to the automake scripts to instruct the compiler to use the C++11 language standard.
How to reproduce:
On a macOS 10.13.6 High Sierra installation, install XCode, and MacPorts, and at least the autotools and qt5-qtbase ports. Maybe also need ports qt5-qtdeclarative, qt5-qtmacextras, qt5-qtmultimedia, qt5-qtsvg, qt5-qttools, qt5-qttranslations .
export PATH=/opt/local/bin:/opt/local/libexec/qt5/bin/:${PATH} so that the freeciv build process sees both the autotools and the Qt5 utilities installed via MacPorts.
% export LDFLAGS='-L/opt/local/libexec/qt5/lib -L/opt/local/lib' so that the freeciv build process sees both the autotools and the Qt5 libraries installed via MacPorts.
Run autogen, with options you prefer. I used something like: 
% ./autogen.sh --disable-silent-rules --enable-fcdb=sqlite3 --prefix=$HOME/opt/freeciv
 --with-readline --enable-sdl-mixer --enable-fcmp=qt  --enable-client=qt
Observed behaviour:
Configure fails with an error message, "selected client 'qt' cannot be built: Missing Qt5 development files". 
This is the configure output, on branch S2_6 at least:
+ checking for autoconf >= 2.61 ... found 2.71, ok.
+ checking for autoheader >= 2.61 ... found 2.71, ok.
…[elided]…
checking for qtpaths... qtpaths
checking Qt5 framework... not found
configure: error: selected client 'qt' cannot be built: Missing Qt5 development files

configure failed
Expected behaviour:
Configure succeeds with a message like, "Maintained client frontends:  QT: yes". 
This is successful configure output on S2_6:
+ checking for autoconf >= 2.61 ... found 2.71, ok.
+ checking for autoheader >= 2.61 ... found 2.71, ok.
…[elided]…
configure:
****************** Configuration Summary ******************
…[elided]…
  == Client ==
  Build freeciv client:  yes

  Maintained client frontends:
    Gtk-3.0:  no
    Gtk-2.0:  no
    Gtk-3.22: no
    SDL:      no
    QT:       yes
    Stub:     no

…[elided]…
  == Tools ==
  Modpack installers:    qt
  Ruleset editor:        yes
  Manual generator:      wiki


Now type 'make' to compile freeciv.
% 
Also expected: make all compiles apps freeciv-qt and freeciv-mp-qt .
Discussion:
The configuration error is raised by automake scripts in m4/qt5-darwin.m4. (Darwin refers to the macOS kernel.)
macOS 10.13.6 High Sierra uses the Apple LLVM version 10.0.0 (clang-1000.11.45.5) compiler, rather than gcc. This compiler conforms
to the c++98 standard by default. The Qt5 application code requires features from the c++11 standard.
Compiler option -std=c++11 makes the clang compiler conform to the correct standard.
This apparently hasn't been an issue on Windows and Linux builds. I suspect that the reason is that the gcc defaults to the c++11 language standard. Qt5 code compiles without an explicit compiler option. Newer macOS versions have newer clang compilers, which might also default to the necessary language standard.
I believe the right way to fix this bug is to ensure that the automake scripts pass a -std=c++11 or the like to the compiler, as needed by the codebase being compiled. The automake scripts should not assume that the compiler will support the correct C++ language standard by default. I suspect that there is no harm to specifying the language standard even on platforms and compilers where the default is good enough. So, we could make automake scripts for all C++ clients specify the language standard. This is perhaps better. However, for me it is enough to fix the problem for macOS.
In S2_6, I see automake scripts ./m4/qt.m4 and ./m4/qt-darwin.m4 .
qt-darwin.m4 seems to be the macOS alternative to qt.m4 .
Both set a variable FC_QT5_CXXFLAGS. When I added " -std=c++11" to this
code, it made the Qt client and modpack programs compile
on macOS 10.13.6 High Sierra.
I have only glanced quickly at the S3_0, S3_1, and master branches. It looks like they have parallel automake structures. 
master at least has code for a Qt6 client as well. Qt6 requires the C++17 language standard (source: https://www.qt.io/blog/qt-6.0-released ).


-- 
Ticket information of Freeciv project
Freeciv Project is hosted on OSDN

Project URL: https://osdn.net/projects/freeciv/
OSDN: https://osdn.net

URL for this Ticket:
    https://osdn.net/projects/freeciv/ticket/42402
RSS feed for this Ticket:
    https://osdn.net/ticket/ticket_rss.php?group_id=12505&tid=42402



More information about the Freeciv-tickets mailing list
Back to archive index