0

I am building ncurses from source (and then linking my application to it) as part of the build process for my application, and I have observed that the built binaries have the absolute path of the custom terminfo hardcoded into them.

This absolute path does not make sense in the deployed environment, forcing the user to set TERMINFO before the program is able to run.

Is there some configuration option to force ncurses to hardcode a path relative to the executable instead?

Alternately, is there a more "standard" way to deploy simple command line applications with custom terminfo libraries, if I wish to avoid heavyweight tools like Docker?


Here are the commands I use to download and build ncurses:

pushd lib
curl -L -o ncurses-6.3.tar.gz         https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.3.tar.gz
tar xf ncurses-6.3.tar.gz
pushd ncurses-6.3
./configure --prefix=`pwd`/dist --enable-widec && make && make install
popd
popd

Here's a minimum program:

#include <curses.h>

int main(){
  initscr();
}

Here's the command I use to compile it:

g++ -std=c++17 -o MWE MWE.cc  -Ilib/ncurses-6.3/dist/include  lib/ncurses-6.3/dist/lib/libncursesw_g.a

Here's how I found the hardcoded path:

strings MWE | grep ncurses
/Users/merlin2011/Code/MWE/lib/ncurses-6.3/dist/share/terminfo
merlin2011
  • 71,677
  • 44
  • 195
  • 329
  • Am I missing something or are you _telling_ it to hardcode that path? --prefix=`pwd` – Emanuel P Mar 01 '23 at 23:08
  • Oh that's an interesting hypothesis. I thought that path only affected where the files lives, not the hardcoding of the terminfo path. – merlin2011 Mar 01 '23 at 23:15
  • I can try to change that to a relative path, but then I'd imagine it's relative to the `lib` directory instead of the binary's path... – merlin2011 Mar 01 '23 at 23:16
  • That's not so much an hypothesis, but what is explained in the install instructions that come with it. It is an absolute path where terminfo will be installed. It sets some other absolute paths as well. – Emanuel P Mar 01 '23 at 23:17
  • Okay, I guess I'm stuck with using a wrapper script to set TERMINFO in the deployed environment. Thanks! – merlin2011 Mar 02 '23 at 01:28
  • https://stackoverflow.com/a/40269919/15381660 – Emanuel P Mar 02 '23 at 02:13
  • the answer literally came as an auto-related question. I don't have the rep, but I suggest you close this as a duplicate – Emanuel P Mar 02 '23 at 02:18
  • 1
    This answers your question: [How to set custom search paths for the terminfo database when building ncurses from source](https://stackoverflow.com/questions/7158602/how-to-set-custom-search-paths-for-the-terminfo-database-when-building-ncurses-f). Use `configure --help`, or read `INSTALL`. – Thomas Dickey Mar 02 '23 at 08:56

0 Answers0