[gnutls-dev] Re: gnutls 1.5.1 C++ library not built if CXX=g++ is set

Simon Josefsson jas at extundo.com
Mon Sep 25 12:48:53 CEST 2006


Andreas Metzler <ametzler at downhill.at.eu.org> writes:

> Hello,
> setting CXX=g++ breaks the building of the C++ library.
>
> (SID)ametzler at argenau:/tmp/gnutls-1.5.1$ ./configure 2>&1 |\
>         grep 'checking whether to build C++ library'
> checking whether to build C++ library... yes
>
> (SID)ametzler at argenau:/tmp/gnutls-1.5.1$ CXX=g++ ./configure 2>&1 |\
>         grep 'checking whether to build C++ library'
> checking whether to build C++ library... no
>
> Afaict this change to configure.in should fix it
>
> -if test -z "$ac_cv_prog_ac_ct_CXX"; then
> +if test -z "$CXX"; then

That wouldn't work if the system doesn't have a usable C++ compiler:
for some reason, AC_PROG_CXX will set CXX to g++ in that case.

I have installed the following instead, which actually tries to
compile a C++ program before deciding whether the C++ library should
be built.

--- configure.in	24 Sep 2006 10:22:17 +0200	2.440
+++ configure.in	25 Sep 2006 12:30:34 +0200	
@@ -93,17 +93,6 @@
 AC_PROG_LN_S
 GTK_DOC_CHECK(1.1)
 
-AC_ARG_ENABLE(cxx,
-       AS_HELP_STRING([--disable-cxx],
-               [unconditionally disable the C++ library]),
-       ac_enable_cxx=$enableval, ac_enable_cxx=yes)
-if test -z "$ac_cv_prog_ac_ct_CXX"; then
-  ac_enable_cxx=no
-fi
-AM_CONDITIONAL(ENABLE_CXX, test "$ac_enable_cxx" != "no")
-AC_MSG_CHECKING([whether to build C++ library])
-AC_MSG_RESULT($ac_enable_cxx)
-
 AC_MSG_RESULT([***
 *** Detecting compiler options...
 ])
@@ -112,6 +101,19 @@
 AC_C_CONST
 AC_C_INLINE
 
+AC_ARG_ENABLE(cxx,
+       AS_HELP_STRING([--disable-cxx],
+               [unconditionally disable the C++ library]),
+       use_cxx=$enableval, use_cxx=yes)
+if test "$use_cxx" != "no"; then
+  AC_LANG_PUSH(C++)
+  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])], use_cxx=yes, use_cxx=no)
+  AC_LANG_POP(C++)
+fi
+AM_CONDITIONAL(ENABLE_CXX, test "$use_cxx" != "no")
+AC_MSG_CHECKING([whether to build C++ library])
+AC_MSG_RESULT($use_cxx)
+
 AC_MSG_CHECKING([whether C99 macros are supported])
 AC_TRY_COMPILE(,[ 
 #define test_mac(...) 

> BTW, shouldn't the C++ library use symbol versioning, too?

Yes, I've tried to add this.

Thanks,
Simon



More information about the Gnutls-dev mailing list