Try adding -Wl,no-as-needed, and moving ldlibs to the end of the line