Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Fussy, pedantic issue with ncurses libraries
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
lars_the_bear
Guru
Guru


Joined: 05 Jun 2024
Posts: 452

PostPosted: Sun Sep 22, 2024 11:19 am    Post subject: Fussy, pedantic issue with ncurses libraries Reply with quote

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
View user's profile Send private message
sam_
Developer
Developer


Joined: 14 Aug 2020
Posts: 1886

PostPosted: Sun Sep 22, 2024 11:24 am    Post subject: Reply with quote

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
View user's profile Send private message
lars_the_bear
Guru
Guru


Joined: 05 Jun 2024
Posts: 452

PostPosted: Sun Sep 22, 2024 4:57 pm    Post subject: Reply with quote

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
View user's profile Send private message
sam_
Developer
Developer


Joined: 14 Aug 2020
Posts: 1886

PostPosted: Sun Sep 22, 2024 5:07 pm    Post subject: Reply with quote

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
View user's profile Send private message
eschwartz
Developer
Developer


Joined: 29 Oct 2023
Posts: 154

PostPosted: Sun Sep 22, 2024 5:42 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
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