Skip to content

Unreliable method for determining C++ compiler #559

Open

Description

@ryandesign

The configure script does different things depending on whether $CXX is g++:

unicon/configure.ac

Lines 652 to 657 in a47bdfc

# A C++ compiler must be present and usable
if test "x$CXX" = "xg++" -a "x$GXX" = "xyes"; then
CHECK_FTGL()
else
echo "FTGL: missing or untrusted C++; CXX is $CXX and GXX is $GXX"
fi

It's unclear what you're trying to do here, but whatever it is, I don't think you're succeeding.

Are you trying to verify that $CXX points to a working C++ compiler? If so, you're unnecessarily excluding all working compilers whose names are not g++. For example, clang++ is a commonly used C++ compiler.

Are you trying to check whether $CXX is specifically the GNU C++ compiler? If so, you're unnecessarily excluding GNU C++ compilers that are not called g++. For example, it might be called /usr/bin/g++. Or it might be called g++-15. It could also be called kevin.

The configure script can even add flags to $CXX; on my system I did not specify CXX in my environment and here's what the configure script did:

checking for g++... g++
...
checking for g++ option to enable C++11 features... -std=gnu++11
...
FTGL: missing or untrusted C++; CXX is g++ -std=gnu++11 and GXX is yes

The name of the compiler executable doesn't tell you what it is. For example, on macOS, /usr/bin/g++ is clang++. And if you think that $GXX will only be yes with the GNU C++ compiler, it is also yes with clang++. The configure script just checks if __GNUC__ is defined, and it is in clang.

Instead of checking the executable name, or trying to determine if the compiler is the GNU C++ compiler, ask the compiler if it supports whatever features you need.

Activity

  1. Jafaral commented on Mar 31, 2026

    @Jafaral
    Member

    It's been a long time, but at the time, I think clang++ was failing, so that was a quick bandaid solution. I forgot if that was before or after adding full CI coverage. In all cases. If you have a good fix, please submit and see how it goes through the CI we have now.

  2. ryandesign commented on Mar 31, 2026

    @ryandesign
    ContributorAuthor

    The fix I'm currently trying is just to remove the check for the g++ name:

    --- configure.ac.orig	2020-12-20 23:08:43.000000000 -0600
    +++ configure.ac	2026-03-30 02:56:12.000000000 -0500
    @@ -532,7 +532,7 @@
               CHECK_OPENGL()
            fi
            # A C++ compiler must be present and usable
    -       if test "x$CXX" = "xg++" -a "x$GXX" = "xyes"; then
    +       if test "x$GXX" = "xyes"; then
              CHECK_FTGL()
            else
              echo "FTGL: missing or untrusted C++; CXX is $CXX and GXX is $GXX"
    @@ -636,7 +636,7 @@
     
     if ! test "x$voip" = "xno"; then
         # A C++ compiler must be present and usable
    -    if test "$CXX" = "g++" -a "$GXX" = "yes"; then
    +    if test "$GXX" = "yes"; then
           CHECK_VOICE()
         else
              echo "VOIP: missing or untrusted C++; CXX is $CXX and GXX is $GXX"

    but I'm still working on overcoming other hurdles (#562) to see if these features will build successfully.

  3. marcespie commented on Jul 15, 2026

    @marcespie

    I can confirm that the problem also exists on OpenBSD (and probably on FreeBSD as well).

    Clang works just fine for compiling FTGL, I can't comment on the voice part, since the voip parts haven't been ported yet.

    The fix from ryandesign is correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions