Public bug reported: Testing a package build on upcoming trusty, I encountered a rather strange issue.
Given this simple program: #include <amqp_tcp_socket.h> int main () { return amqp_tcp_socket_new (0); } I installed "librabbitmq-dev" which provides amqp_tcp_socket.h, and then ran "gcc -o /tmp/test -g -O2 -lrabbitmq -ldl amqp.c", which fails with: /tmp/amqp.c:2: undefined reference to `amqp_tcp_socket_new' collect2: error: ld returned 1 exit status Using "gcc -v", I discovered that if /usr/lib/gcc/x86_64-linux- gnu/4.8/collect2 was called without the --as-needed option, the program builds fine. I'm actually opening this bug against gcc and not librabbitmq-dev for a reason: this simple C program builds perfectly on debian jessie/sid. librabbitmq-dev/librabbitmq1 are exactly identical between trusty and debian unstable. The problem also occurs when manually building librabbitmq from the upstream source tarball. Also, it's not just a matter of fixing my broken program or calling gcc with some other option. This program actually is a stripped down version of what is generated by autoconf (also same version and output on sid and trusty, BTW) with this macro: AC_CHECK_FUNC(amqp_tcp_socket_new, [with_amqp_tcp_socket="yes"], [with_amqp_tcp_socket="no"]) Attaching the output of "gcc -v" on both trusty and jessie. Apart from a couple of paths and version strings, collect2 is called with "--as- needed" and "-z relro" on trusty but not on debian jessie. "--as-needed" is what makes the difference between failing to build (on trusty) or not (on jessie). Thanks for taking a look at this ! ** Affects: gcc-4.8 (Ubuntu) Importance: Undecided Status: New ** Attachment added: "gcc -v on trusty" https://bugs.launchpad.net/bugs/1271468/+attachment/3954218/+files/gcc-v-trusty.txt -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1271468 Title: collect2 --as-needed option causes build failure To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/gcc-4.8/+bug/1271468/+subscriptions -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs