Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#2356 closed defect (fixed)

configure fails in examples/ because it doesn't find the boost header

Reported by: jreed Owned by: jinmei
Priority: medium Milestone: Sprint-20121106
Component: build system Version:
Keywords: Cc:
CVSS Scoring: Parent Tickets:
Sensitive: no Defect Severity: N/A
Sub-Project: DNS Feature Depending on Ticket:
Estimated Difficulty: 3 Add Hours to Ticket: 0
Total Hours: 5.05 Internal?: no

Description

The ./configure failed for me in examples because it couldn't find the boost header when checking the libdns++ header and then couldn't find the dns library. Here is my patch for:

Use SAVED instead of SAVES. There was at least one case that
it didn't get defined correctly.

Use BOOST_CPPFLAGS.

Fix minor grammar issue in error output.

Get rid of unused assignment.

diff --git a/examples/m4/ax_boost_include.m4 b/examples/m4/ax_boost_include.m4
index e41614d..77d19ca 100644
--- a/examples/m4/ax_boost_include.m4
+++ b/examples/m4/ax_boost_include.m4
@@ -34,7 +34,7 @@ if test -z "$with_boost_include"; then
 		fi
 	done
 fi
-CPPFLAGS_SAVES="$CPPFLAGS"
+CPPFLAGS_SAVED="$CPPFLAGS"
 if test "${boost_include_path}" ; then
 	BOOST_CPPFLAGS="-I${boost_include_path}"
 	CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
@@ -57,7 +57,7 @@ AC_TRY_COMPILE([
  CPPFLAGS_BOOST_THREADCONF="-DBOOST_DISABLE_THREADS=1"],
 [AC_MSG_RESULT(yes)])
 
-CPPFLAGS="$CPPFLAGS_SAVES $CPPFLAGS_BOOST_THREADCONF"
+CPPFLAGS="$CPPFLAGS_SAVED $CPPFLAGS_BOOST_THREADCONF"
 AC_SUBST(BOOST_CPPFLAGS)
 
 AC_LANG_RESTORE
diff --git a/examples/m4/ax_isc_bind10.m4 b/examples/m4/ax_isc_bind10.m4
index 63e028c..12847c6 100644
--- a/examples/m4/ax_isc_bind10.m4
+++ b/examples/m4/ax_isc_bind10.m4
@@ -42,19 +42,19 @@ if test "$bind10_inc_path" = "no"; then
 	fi
    done
 fi
-CPPFLAGS_SAVES="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
+CPPFLAGS_SAVED="$CPPFLAGS"
 if test "${bind10_inc_path}" != "no"; then
    BIND10_CPPFLAGS="-I${bind10_inc_path}"
    CPPFLAGS="$CPPFLAGS $BIND10_CPPFLAGS"
 fi
 AC_CHECK_HEADERS([util/buffer.h],,
-  AC_MSG_ERROR([Missing a commonly used BIND 10 header files]))
-CPPFLAGS="$CPPFLAGS_SAVES"
+  AC_MSG_ERROR([Missing a commonly used BIND 10 header file]))
+CPPFLAGS="$CPPFLAGS_SAVED"
 AC_SUBST(BIND10_CPPFLAGS)
 
 # Check for BIND10 libraries
-CPPFLAGS_SAVED="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $BIND10_CPPFLAGS"
+CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS $BIND10_CPPFLAGS"
 
 AC_ARG_WITH(bind10-lib,
   AS_HELP_STRING([--with-bind10-lib=PATH],
@@ -94,7 +94,7 @@ else
 fi
 
 # restore LIBS once at this point
-LIBS="$LIBS_SAVES"
+LIBS="$LIBS_SAVED"
 
 AC_SUBST(BIND10_LDFLAGS)
 AC_SUBST(BIND10_COMMON_LIB)
@@ -111,12 +111,12 @@ isc::dns::RRType rrtype(1);
 ], [BIND10_DNS_LIB="-lb10-dns++"
     AC_MSG_RESULT(yes)],
    [AC_MSG_RESULT(no)])
-LIBS="$LIBS_SAVES"
+LIBS="$LIBS_SAVED"
 AC_SUBST(BIND10_DNS_LIB)
 
 # Restore other flags
 CPPFLAGS="$CPPFLAGS_SAVED"
-LDFLAGS="$LDFLAGS_SAVES"
+LDFLAGS="$LDFLAGS_SAVED"
 
 AC_LANG_RESTORE
 ])dnl AX_ISC_BIND10

The above fixes it for me on two different systems.

The next problem is that on some systems it can't run b10-host since can't find the library. We have a rpath_flag in the base configure.ac which could be reused -- we should abstract that out.

Subtickets

Change History (18)

comment:1 Changed 7 years ago by jinmei

  • Milestone changed from New Tasks to Next-Sprint-Proposed

comment:2 Changed 7 years ago by muks

  • Summary changed from examples autoconf m4 to configure fails in examples/ because it doesn't find the boost header

comment:3 Changed 7 years ago by jelte

  • Milestone changed from Next-Sprint-Proposed to Sprint-20121106

comment:4 Changed 7 years ago by jinmei

  • Owner changed from UnAssigned to jinmei
  • Status changed from new to accepted

comment:5 Changed 7 years ago by jinmei

trac2356 is ready for review.

I believe I've addressed all issues including the rpath hack.
For the rpath, I've extracted the checks in the top level configure.ac
into a single helper m4 file defined in example/m4 and used it for
both the top level and example configure.ac's. This way we can avoid
duplicates, and it will also make the top level configure.ac more
concise.

I think we need a changelog here. This is the proposal:

499.?	[bug]		jinmei
	Corrected the autoconf example in the examples directory so it can
	use the configured path to Boost to check availability of the BIND
	10 library.  Previously the sample configure script could fail if
	Boost is installed in an uncommon place.  Also, it now provides a
	helper m4 function and example usage for embedding the library
	path to executable (using linker options like -R) to help minimize
	post-build hassles.
	(Trac #2356, git TBD)

comment:6 Changed 7 years ago by jinmei

  • Owner changed from jinmei to UnAssigned
  • Status changed from accepted to reviewing

comment:7 Changed 7 years ago by vorner

  • Owner changed from UnAssigned to vorner

comment:8 Changed 7 years ago by jreed

I tested the branch and it works for me. Thanks

comment:9 follow-up: Changed 7 years ago by vorner

Hello

I didn't find anything wrong when reading the code, but the example does not compile for me now. Configure run well, but it fails when I do make:

make  all-recursive
make[1]: Entering directory `/home/vorner/work/bind10/examples'
Making all in host
make[2]: Entering directory `/home/vorner/work/bind10/examples/host'
g++ -DHAVE_CONFIG_H -I. -I..   -I/home/vorner/testing/bind10/include/bind10-devel   -g -O2 -MT host.o -MD -MP -MF .deps/host.Tpo -c -o host.o host.cc
mv -f .deps/host.Tpo .deps/host.Po
g++  -g -O2 -L/home/vorner/testing/bind10/lib/ -R/home/vorner/testing/bind10/lib/ -o b10-host host.o -lb10-dns++ 
g++: error: unrecognized option ‘-R’
make[2]: *** [b10-host] Error 1
make[2]: Leaving directory `/home/vorner/work/bind10/examples/host'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/vorner/work/bind10/examples'
make: *** [all] Error 2

comment:10 Changed 7 years ago by vorner

  • Owner changed from vorner to jinmei

comment:11 in reply to: ↑ 9 ; follow-up: Changed 7 years ago by jreed

Replying to vorner:

g++  -g -O2 -L/home/vorner/testing/bind10/lib/ -R/home/vorner/testing/bind10/lib/ -o b10-host host.o -lb10-dns++ 
g++: error: unrecognized option ‘-R’

Should try -Wl,-R I think. That is tried first in the test.

comment:12 in reply to: ↑ 11 Changed 7 years ago by jinmei

Replying to jreed:

Thanks for the review.

g++  -g -O2 -L/home/vorner/testing/bind10/lib/ -R/home/vorner/testing/bind10/lib/ -o b10-host host.o -lb10-dns++ 
g++: error: unrecognized option ‘-R’

Should try -Wl,-R I think. That is tried first in the test.

Initially I didn't understand why it failed, because the check is
basically a verbatim copy from the original configure.ac. I then
found several issues:

  • "-R" was actually hardcoded in ax_isc_bind10.m4. This is a clear bug and was fixed.
  • I'm not sure if that was your case, but I've noticed the position of LDFLAGS is different when used in AC_TRY_LINK and in the Makefile (generated by automake). Some version of g++ only complains about the latter case. So it's possible that AC_TRY_LINK thinks -R is usable but it causes build time failure. So, to make it safer, I used CXXFLAGS instead of LDFLAGS in the m4 check (and also set CCFLAGS in case the main script uses C). And, it may still not be a complete solution because yet other versions of g++ only complains about it but doesn't treat it as an error. So, as a final defense I actually changed the order of the check: -Wl,-R first and then -R.
  • I've updated the result message when -R is chosen with a note about the possible issue - even though it's less likely people actually read it.

comment:13 Changed 7 years ago by jinmei

  • Owner changed from jinmei to vorner

comment:14 follow-up: Changed 7 years ago by vorner

  • Owner changed from vorner to jinmei

It works now. So I think it can be merged.

comment:15 in reply to: ↑ 14 Changed 7 years ago by jinmei

Replying to vorner:

It works now. So I think it can be merged.

Thanks, merge done, closing.

comment:16 Changed 7 years ago by jinmei

  • Total Hours changed from 0 to 3.25

comment:17 Changed 7 years ago by jinmei

  • Resolution set to fixed
  • Status changed from reviewing to closed

comment:18 Changed 7 years ago by vorner

  • Total Hours changed from 3.25 to 5.05
Note: See TracTickets for help on using tickets.