[Bug driver/109217] failure statically linking shared lib

stsp at users dot sourceforge.net gcc-bugzilla@gcc.gnu.org
Tue Mar 21 08:21:48 GMT 2023


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109217

--- Comment #4 from Stas Sergeev <stsp at users dot sourceforge.net> ---
(In reply to Richard Biener from comment #3)
> -static-pie is now marked as the negative of -shared, so it works with that
> (the later cancelling out the earlier).  It isn't handled that way for
> -static vs. -shared, not sure if we can use Negative() with multiple options.

So could you please suggest the exact
command line that works?
I tried:

$ LC_ALL=C cc -Wall -o libmain.so main.c -shared -static-pie
/usr/bin/ld:
/usr/lib/gcc/x86_64-linux-gnu/12/../../../x86_64-linux-gnu/rcrt1.o: in function
`_start':
(.text+0x1b): undefined reference to `main'
collect2: error: ld returned 1 exit status


So obviously -static-pie just indeed, as you
say, cancels -shared. Is there any -static-solib
or alike, to produce the solib at the end?


More information about the Gcc-bugs mailing list