#18 libnewt.pc: added data for static linking
Closed by mlichvar. Opened by asheplyakov.
asheplyakov/newt pkg-config-static-link  into  master

Download 18.patch

With this patch I can statically link a binary with libnewt without listing
the required libraries manually:

gcc -o test_static test.c `pkg-config --libs --cflags --static libnewt`

Without this patch static linking fails due to multiple undefined
references:

/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libnewt.a(form.o): in function `Gpm_Open.part.0.constprop.0':
(.text+0x38c): warning: the use of `tempnam' is dangerous, better use `mkstemp'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libnewt.a(newt.o): in function `wchar_to_textmod_visual.constprop.0':
(.text+0xa53): undefined reference to `dlerror'
/usr/bin/ld: (.text+0xa72): undefined reference to `dlsym'
/usr/bin/ld: (.text+0xe55): undefined reference to `dlopen'
/usr/bin/ld: (.text+0xe6d): undefined reference to `dlerror'
/usr/bin/ld: (.text+0xe7e): undefined reference to `dlopen'
/usr/bin/ld: (.text+0xe96): undefined reference to `dlerror'
/usr/bin/ld: (.text+0xf83): undefined reference to `dlclose'
/usr/bin/ld: (.text+0xfa5): undefined reference to `dlerror'
/usr/bin/ld: (.text+0xfe1): undefined reference to `dlclose'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libnewt.a(newt.o): in function `write_string_int':
(.text+0x1267): undefined reference to `SLsmg_write_string'
/usr/bin/ld: (.text+0x12ae): undefined reference to `SLsmg_write_string'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libnewt.a(newt.o): in function `write_nstring_int':
(.text+0x1398): undefined reference to `SLsmg_write_nstring'
/usr/bin/ld: (.text+0x13e7): undefined reference to `SLsmg_write_nstring'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libnewt.a(newt.o): in function `newtFlushInput':
(.text+0x1523): undefined reference to `SLang_input_pending'
/usr/bin/ld: (.text+0x1531): undefined reference to `SLang_getkey'
/usr/bin/ld: (.text+0x153c): undefined reference to `SLtt_Screen_Rows'
/usr/bin/ld: (.text+0x1543): undefined reference to `SLsmg_touch_lines'
/usr/bin/ld: (.text+0x1548): undefined reference to `SLsmg_refresh'
[248 lines skipped]
collect2: error: ld returned 1 exit status

Closes: #17

Why -ldl in Libs.private? Shouldn't that come from the slang pc file?

Why -ldl in Libs.private? Shouldn't that come from the slang pc file?

I've added it because the shared library explicitly links with libdl:

$ objdump -p libnewt.so |grep NEEDED
  NEEDED               libslang.so.2
  NEEDED               libdl.so.2
  NEEDED               libc.so.6

Hm, I don't see that here. The newt Makefile doesn't specify -ldl.

rebased onto 292977e60962b71bf5217ed924c13c27077d14e8

Hm, I don't see that here. The newt Makefile doesn't specify -ldl.

Indeed. I was linking with system libnewt, which does use libdl (due to this patch). Therefore I've removed Libs.private.

Applied. Thanks.

Pull-Request has been closed by mlichvar

Metadata