View previous topic :: View next topic |
Author |
Message |
lars_the_bear Guru
Joined: 05 Jun 2024 Posts: 454
|
Posted: Sun Sep 22, 2024 11:19 am Post subject: Fussy, pedantic issue with ncurses libraries |
|
|
Hi folks
It seems that the way I installed Gentoo, I ended up with libnursesw.so separated from libtinfow.so. I understand that ncurses can be built this way, or with these libraries combined. So far as I can see, most other Linux distributions have them combined.
My applications that use ncursesw have a single set of Makefiles that work on many Linux platforms -- Fedora, Ubuntu, Raspberry Pi at least -- but they don't work on Gentoo, because they don't explicitly link libtinfow.so, because they don't need to.
The solution is simple, in principle -- just modify all the Makefiles to have '-lncursesw -ltinfow', rather than just '-lnursesw'. But this means that I can no longer maintain a single set of Makefiles for all Linux platforms.
I'm curious whether this split between libncurses and libtinfo is peculiar to the way I set up Gentoo, or whether it will always be like that on a Gentoo system.
And if it will always be like that, I'm wondering if there's some non-ugly way I can modify my makefiles so that the link includes -ltinfow only on Gentoo. Or, perhaps, only on systems where this library exists. I can think of some ugly ways to do this, but surely there is some elegant way?
Incidentally, there seems to have been a fair bit of discussion of this point about ten years ago, and I don't think the Gentoo way of handling libncursesw is accidental. But it does seem to be out of line with other Linux variants.
BR, Lars. |
|
Back to top |
|
|
sam_ Developer
Joined: 14 Aug 2020 Posts: 1888
|
Posted: Sun Sep 22, 2024 11:24 am Post subject: |
|
|
You should use pkg-config instead, not hardcoding libraries: LIBS = $(pkg-config --libs ncursesw).
Anyway, see https://bugs.gentoo.org/457530. There's some more detailed discussion somewhere but I can't dig it up right now.
If you look at the Fedora packaging, they use a linker script hack to try to hide the issue.
Mod edit: Trailing period exorcised from the above URL. — JRG |
|
Back to top |
|
|
lars_the_bear Guru
Joined: 05 Jun 2024 Posts: 454
|
Posted: Sun Sep 22, 2024 4:57 pm Post subject: |
|
|
sam_ wrote: | You should use pkg-config instead, not hardcoding libraries: |
Thanks. It's good to know, I guess, that I'm not the first person to see this problem. It doesn't look like it's going to be fixed, however; from the discussion in the bug, it's not even clear to me what a fix would look like.
The problem with pkg-config is that it doesn't work on Raspberry Pi. Well, you can install the binary, but none of the .pc files are present, so it won't work. It doesn't work on Cygwin either, although I suspect I'm the only person on Earth still using Cygwin. So I'd still need different Makefiles for different platforms.
Oh, well. Not a show-stopper.
BR, Lars. |
|
Back to top |
|
|
sam_ Developer
Joined: 14 Aug 2020 Posts: 1888
|
Posted: Sun Sep 22, 2024 5:07 pm Post subject: |
|
|
The bug is discussion of moving towards the current setup, not away!
You can absolutely get pkg-config files on Raspbian and I'm 95+% sure they work on Cygwin.
(You can also do something like: LIBS = $(shell pkg-config --libs ... || echo -lncursesw ...) anyway.) |
|
Back to top |
|
|
eschwartz Developer
Joined: 29 Oct 2023 Posts: 154
|
Posted: Sun Sep 22, 2024 5:42 pm Post subject: |
|
|
lars_the_bear wrote: |
Thanks. It's good to know, I guess, that I'm not the first person to see this problem. It doesn't look like it's going to be fixed, however; from the discussion in the bug, it's not even clear to me what a fix would look like. |
The fix is to use either one of:
- a real build system
- a Makefile that runs a real dependency detector, that is to say, runs pkg-config
Many people have seen your problem, and solved it by using pkg-config. No one has had a problem of pkg-config, and solved it by hardcoding -lncurses, because that's not a solution.
Upstream ncurses implements this configuration and requires that you use pkg-config to correctly link.
Your option, if you do not wish to use pkg-config, is to run `ncurses6-config --cflags --libs`.
There is no third option.
lars_the_bear wrote: |
The problem with pkg-config is that it doesn't work on Raspberry Pi. Well, you can install the binary, but none of the .pc files are present, so it won't work. It doesn't work on Cygwin either, although I suspect I'm the only person on Earth still using Cygwin. So I'd still need different Makefiles for different platforms.
|
Certainly, Cygwin installs pkg-config files for ncurses. The Raspberry Pi doesn't, because the Raspberry Pi isn't an operating system, it's a hardware device upon which you *install* an operating system. If you mean to say it doesn't work on the Raspbian operating system, it is my pleasure to inform you that they, too, install pkg-config files for ncurses. It's right there in http://archive.raspbian.org/raspbian/pool/main/n/ncurses/libncurses-dev_6.5-2_armhf.deb
You mention "you can install the binary, but none of the .pc files are present, so it won't work". This comment alarms me, because it implies you installed the ncurses binary, but not the ncurses development package, including the ncurses *headers*. So how did you even compile your software against ncurses???
The same package provides both ncurses development headers and ncurses development pkg-config files (and the ncurses6-config script), so if you can compile against the headers you can also compile against the pkg-config files. |
|
Back to top |
|
|
lars_the_bear Guru
Joined: 05 Jun 2024 Posts: 454
|
Posted: Mon Sep 23, 2024 8:04 am Post subject: |
|
|
@eschwarz
Thank you. But the reason I don't use pkg-config is that I've spent too much time working on minimal and embedded platforms where it isn't present, or doesn't work. I can install gcc and make on Android, for example, but I don't want the hassle of installing all the extra infrastructure that would make pkg-config work. It didn't work properly with Cygwin when I last tried it, nor with the DietPi Raspberry Pi distribution. Admittedly, I haven't used either of these for some time, so the situation might have improved. Still, as a matter of principle, I don't put anything in a Makefile that couldn't be satisfied by Busybox.
In any case, I'm not really looking for a solution, because the solution is a one-line change in a few Makefiles. I appreciate that the use of pkg-config or other build infrastructure would relieve the problem for most users. I was just interested to know whether Gentoo was different in its ncurses provision from the other mainstream Linux distributions I've used, or whether I had just set something up wrongly. I certainly haven't used every Linux distribution that exists, and it's possible that they all differ from one another in this respect.
BR, Lars. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|