re: binutils-2.15.92.0.2-r7.ebuild invoking ld via gcc/g++ in the following form: gcc <compiler options, object files, etc> -shared <libpaths, libs, etc> -Wl,-Bstatic <more libs to be linked statically> causes the linker to exit with the error: /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.5-20050130/../../../../i686-pc-linux-gnu/bin/ld: -static and -shared may not be used together This error should *not* occur. The '-shared' directive indicates that a shared object target is desired and the '-Wl,-Bstatic' option states that libraries following this option on the command line should be linked in statically. This is just a guess but some patcher appears to be assuming that '-shared' and '-static' (a synonym for '-Wl,-Bstatic') both refer to the output target. This is not the case and the docs for both gcc and ld bear this out. Reverting to binutils-2.15.92.0.2-r1.ebuild (the previous currently available stable release) fixes the issue (removes the patch presumably). From the gcc-3.3.5 docs online at (http://gcc.gnu.org/onlinedocs/gcc-3.3.5/gcc/Link-Options.html#Link-Options) -static On systems that support dynamic linking, this prevents linking with the shared libraries. On other systems, this option has no effect. -shared Produce a shared object which can then be linked with other objects to form an executable. Not all systems support this option. For predictable results, you must also specify the same set of options that were used to generate code (-fpic, -fPIC, or model suboptions) when you specify this option.1 From the binutils docs online at (http://sourceware.org/binutils/docs-2.15/ld/Options.html#Options) -Bstatic -dn -non_shared -static Do not link against shared libraries. This is only meaningful on platforms for which shared libraries are supported. The different variants of this option are for compatibility with various systems. You may use this option multiple times on the command line: it affects library searching for -l options which follow it. This option also implies --unresolved-symbols=report-all. -shared -Bshareable Create a shared library. This is currently only supported on ELF, XCOFF and SunOS platforms. On SunOS, the linker will automatically create a shared library if the -e option is not used and there are undefined symbols in the link. Reproducible: Always Steps to Reproduce: 1.create a dummy.o object file 2.gcc dummy.o -shared -Wl,-Bstatic -lstdc++ 3.watch the error Actual Results: /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.5-20050130/../../../../i686-pc-linux-gnu/bin/ld: -static and -shared may not be used together collect2: ld returned 1 exit status Expected Results: no error output
*** Bug 89920 has been marked as a duplicate of this bug. ***
*** Bug 89922 has been marked as a duplicate of this bug. ***
Apologies for that - I'll take more care refreshing the correct browser window next time.
if the last arg is -Wl,-Bstatic then the linker will assume the final binary is supposed to be static which conflicts with the request to build a -shared binary if you want to statically link in just some libs, then you need to declare when you're done linking static libs: gcc -shared <source code> -Wl,-Bstatic -lncurses -Wl,-Bdynamic -lreadline this will link ncurses statically but link readline dynamically