I noticed that the build of Hadoop trunk (0.24) and the 1.0/0.20.20x branches fail on Ubuntu 11.10 when trying to include the native code in the build. The reason is that the default behavior of ld was changed in Ubuntu 11.10.
This was apparently planned to be changed already back in 11.04 but was eventually reverted in the final release. From 11.04 Toolchain Transition:
Also in Natty, ld runs with the --as-needed option enabled by default. This means that, in the example above, if no symbols from libwheel were needed by racetrack, then libwheel would not be linked even if it was explicitly included in the command-line compiler flags. NOTE: The ld --as-needed default was reverted for the final natty release, and will be re-enabled in the o-series.
I already run into the same issue with Hadoop-LZO (https://github.com/kevinweil/hadoop-lzo/issues/33). See the link and the patch for more details. For Hadoop, the problematic configure script is native/configure.
How to reproduce
There are two ways to reproduce, depending on the OS you have at hand.
1. Use a stock Ubuntu 11.10 box and run a build that also compiles the native libs:
2. If you do not have Ubuntu 11.10 at hand, simply add -Wl,--as-needed explicitly to LDFLAGS. This configures ld to work like Ubuntu 11.10's default behavior.
Error message (for trunk/0.24)
Running the above build command will produce the following output (I added -e -X switches to mvn).
How to fix
The fix involves adding proper settings for LDFLAGS to the build config. In trunk, this is hadoop-common-project/hadoop-common/pom.xml. In branches 1.0 and 0.20.20x, this is build.xml.
Basically, the fix explicitly adds -Wl,--no-as-needed to LDFLAGS. Special care must be taken not to add this option when running on Mac OS as its version of ld does not support this option (and does not need it because by default it behaves as desired).