Skip to content

Change library ordering when testing for library availability with autoconf

Daniel Lenski requested to merge change_library_ordering_in_configure.ac into master

As discussed in #371 (closed), the order in which libraries must be listed on the compiler command-line has changed in recent versions of GCC, in order for linking to succeed. This is because the --as-needed option has become enabled by default: https://sigquit.wordpress.com/2011/02/16/why-asneeded-doesnt-work-as-expected-for-your-libraries-on-your-autotools-project

A succinct explanation of the required changes in library-ordering from https://wiki.ubuntu.com/NattyNarwhal/ToolchainTransition by way of https://stackoverflow.com/a/69795683:

"The --as-needed option also makes the linker sensitive to the ordering of libraries on the command-line. You may need to move some libraries later in the command-line, so they come after other libraries or files that require symbols from them." [3]

It appears that both Debian-based and Fedora-based distributions are moving towards this as the new default behavior:

Merge request reports