yes, this is expected. ld --as-needed is now the default.
On 4/18/20 3:05 AM, Michael T. Kloos wrote:
> On Debian Unstable(gcc v9.3.0), gcc won't link libraries that are passed via
> "-l" before the source file. This does NOT happen on Debian Stable(gcc
> v8.3.0)
> or on my Gentoo system(gcc v9.2.0). Is this expected behavior?
>
> Example:
>
> Works:
> $ gcc ./simple_app.c -lX11 -o ./simple_app.out
>
> Broken:
> $ gcc -lX11 ./simple_app.c -o ./simple_app.out
> /usr/bin/ld: /tmp/ccCCBBZ5.o: in function `main':
> simple_app.c:(.text+0x1c): undefined reference to `XOpenDisplay'
> /usr/bin/ld: simple_app.c:(.text+0xdc): undefined reference to
> `XCreateSimpleWindow'
> /usr/bin/ld: simple_app.c:(.text+0xfc): undefined reference to `XSelectInput'
> /usr/bin/ld: simple_app.c:(.text+0x10f): undefined reference to `XMapWindow'
> /usr/bin/ld: simple_app.c:(.text+0x125): undefined reference to `XNextEvent'
> /usr/bin/ld: simple_app.c:(.text+0x177): undefined reference to
> `XFillRectangle'
> /usr/bin/ld: simple_app.c:(.text+0x1cc): undefined reference to `XDrawString'
> /usr/bin/ld: simple_app.c:(.text+0x1ed): undefined reference to
> `XCloseDisplay'
> collect2: error: ld returned 1 exit status
>
> I am not subscribed to this list. Please send replies directly to my E-mail.
>