The following is a sample bash session which demonstrates the problem. $ cat << EOF > main.cpp > #include <boost/filesystem.hpp> > int main() > { > boost::filesystem::path r(""); > return 0; > } > EOF $ g++ main.cpp -lboost_filesystem $ ldd a.out |grep boost libboost_filesystem-1_42.so.1.42.0 => /usr/lib/libboost_filesystem-1_42.so.1.42.0 (0x00007f8b704bc000) libboost_system-1_42.so.1.42.0 => /usr/lib/libboost_system-1_42.so.1.42.0 (0x00007f8b6f794000) $ ldd /usr/lib/libboost_filesystem-1_42.so.1.42.0 |grep boost libboost_system-1_42.so.1.42.0 => /usr/lib/libboost_system-1_42.so.1.42.0 (0x00007ff9008d1000) $ g++ -Wl,--as-needed main.cpp -lboost_filesystem /tmp/ccuL8xmr.o: In function `__static_initialization_and_destruction_0(int, int)': main.cpp:(.text+0x52): undefined reference to `boost::system::get_system_category()' main.cpp:(.text+0x5e): undefined reference to `boost::system::get_generic_category()' main.cpp:(.text+0x6a): undefined reference to `boost::system::get_generic_category()' main.cpp:(.text+0x76): undefined reference to `boost::system::get_generic_category()' main.cpp:(.text+0x82): undefined reference to `boost::system::get_system_category()' collect2: ld returned 1 exit status $ $ nm -CD /usr/lib/libboost_system-1_42.so.1.42.0 |grep boost::system::get_system_category 0000000000001a80 T boost::system::get_system_category() Reproducible: Always $ g++ --version g++ (Gentoo 4.4.4-r1 p1.0, pie-0.4.5) 4.4.4 $ ld --version GNU ld (GNU Binutils) 2.20.1.20100303 $ uname -a Linux blackbox 2.6.34-gentoo-r2 #1 SMP PREEMPT Wed Jul 14 12:14:21 MSD 2010 x86_64 Intel(R) Core(TM) i5 CPU 750 @ 2.67GHz GenuineIntel GNU/Linux
what exactly is your point ? dont use --as-needed with your C++ apps that require specific behavior. this has been discussed to death (simply google/read gentoo-dev mailing list). there isnt really anything that can be done in the linker to detect this small corner case.
The point is that --as-needed is now enabled by default. Paludis (or portage) can no longer build my application.
(In reply to comment #2) > The point is that --as-needed is now enabled by default. Paludis (or portage) > can no longer build my application. > Sure it can, read the documentation: http://www.gentoo.org/proj/en/qa/asneeded.xml "Code Listing 1.5: correct filter for --as-needed behaviour"
Thanks. Nice to know you already took care about it.