Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could this library optionally use static linking? #36

Closed
hdgarrood opened this issue Nov 14, 2019 · 6 comments
Closed

Could this library optionally use static linking? #36

hdgarrood opened this issue Nov 14, 2019 · 6 comments

Comments

@hdgarrood
Copy link

It seems like dynamically linking libtinfo / libncurses / etc can cause problems when trying to ship software to users. In my case, I would like to be able to ship purescript compiler binaries which work out of the box on as many linux distributions as possible, and it seems that the dynamic linking of ncurses is the main difficulty right now; see e.g. purescript/purescript#3696 and commercialhaskell/stack#1012 and potentially even #15 and #17?

I'm not sure how feasible this is, but do you think it would be possible for this package to provide a flag which would cause libncurses to be linked statically?

@judah
Copy link
Collaborator

judah commented Nov 16, 2019

That's an interesting idea. Terminfo's main purpose is to read a binary database with information about the various known terminals. Unfortunately, as far as I'm aware, the location of that file may be system-dependent; and the binary format might be as well. So I don't think a single binary statically linking in just ncurses (or the equivalent) would work on all machines.

I've had the idea in the past to distribute the terminfo database itself, or maybe embed it in the final binary somehow. Unfortunately, the copyright around that database seems fairly complicated, so I've avoided touching it directly:
https://invisible-island.net/ncurses/ncurses.faq.html#terminfo_copying

@hdgarrood
Copy link
Author

I see - thanks very much, this is really useful info! I might look into distributing the database itself then.

@hdgarrood
Copy link
Author

I guess another drawback of distributing a terminfo database would be that it would not be able to use local overrides, which people sometimes will want to use, e.g. https://sw.kovidgoyal.net/kitty/faq.html#i-get-errors-about-the-terminal-being-unknown-or-opening-the-terminal-failing-when-sshing-into-a-different-computer

@andys8
Copy link

andys8 commented Jan 10, 2020

I'm trying to statically link an application on manjaro/arch.
Looks like several libs are missing on arch. I installed ncurses5-compat-libs, but there are still issues.

Is this related the topic?

Linking .stack-work/dist/x86_64-linux-tinfo6/Cabal-2.4.0.1/build/git-brunch/git-brunch ...
/usr/bin/ld.gold: error: cannot find -ltinfo
/home/andreas/.stack/snapshots/x86_64-linux-tinfo6/a3c8d66310de3716e4203f48af80ca4601881ab90edbbb80c5f8856db8fa5738/8.6.5/lib/x86_64-linux-ghc-8.6.5/vty-5.25.1-JvGBbdahzLA8CfqyZv6RWk/libHSvty-5.25.1-JvGBbdahzLA8CfqyZv6RWk.a(Terminfo.o)(.text+0xdb): error: undefined reference to 'set_curterm'
/home/andreas/.stack/snapshots/x86_64-linux-tinfo6/a3c8d66310de3716e4203f48af80ca4601881ab90edbbb80c5f8856db8fa5738/8.6.5/lib/x86_64-linux-ghc-8.6.5/vty-5.25.1-JvGBbdahzLA8CfqyZv6RWk/libHSvty-5.25.1-JvGBbdahzLA8CfqyZv6RWk.a(Terminfo.o)(.text+0x10b): error: undefined reference to 'set_curterm'
/home/andreas/.stack/snapshots/x86_64-linux-tinfo6/a3c8d66310de3716e4203f48af80ca4601881ab90edbbb80c5f8856db8fa5738/8.6.5/lib/x86_64-linux-ghc-8.6.5/vty-5.25.1-JvGBbdahzLA8CfqyZv6RWk/libHSvty-5.25.1-JvGBbdahzLA8CfqyZv6RWk.a(Terminfo.o)(.text+0x14c): error: undefined reference to 'set_curterm'
/home/andreas/.stack/snapshots/x86_64-linux-tinfo6/a3c8d66310de3716e4203f48af80ca4601881ab90edbbb80c5f8856db8fa5738/8.6.5/lib/x86_64-linux-ghc-8.6.5/vty-5.25.1-JvGBbdahzLA8CfqyZv6RWk/libHSvty-5.25.1-JvGBbdahzLA8CfqyZv6RWk.a(Terminfo.o)(.text+0x263): error: undefined reference to 'set_curterm'
/home/andreas/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/lib/ghc-8.6.5/terminfo-0.4.1.2/libHSterminfo-0.4.1.2.a(Base.o)(.text.r9zE_info+0x102): error: undefined reference to 'tigetnum'
/home/andreas/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/lib/ghc-8.6.5/terminfo-0.4.1.2/libHSterminfo-0.4.1.2.a(Base.o)(.text.r9zG_info+0xfa): error: undefined reference to 'tigetstr'
/home/andreas/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/lib/ghc-8.6.5/terminfo-0.4.1.2/libHSterminfo-0.4.1.2.a(Base.o)(.text.s9Kw_info+0x132): error: undefined reference to 'del_curterm'
/home/andreas/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.5/lib/ghc-8.6.5/terminfo-0.4.1.2/libHSterminfo-0.4.1.2.a(Base.o)(.text.s9Kw_info+0x241): error: undefined reference to 'setupterm'
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)

--  While building package git-brunch-1.0.6.0 using:
      /home/andreas/.stack/setup-exe-cache/x86_64-linux-tinfo6/Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.5 --builddir=.stack-work/dist/x86_64-linux-tinfo6/Cabal-2.4.0.1 build exe:git-brunch --ghc-options " -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1

@judah
Copy link
Collaborator

judah commented Jan 10, 2020

@andys8 yes, git-brunch depends transitively on the terminfo package. It looks like stack isn't doing the right thing here, picking a GHC build ("ghc-tinfo6-8.6.5") whose terminfo package doesn't link against the libraries available on your machine. Or, possibly, you have a shared library version of libtinfo but not a static one. I found this past discussion which seems relevant:

commercialhaskell/stack#2302

If you still can't get it to work, I suggest filing an issue in the stack bugtracker.

@hdgarrood
Copy link
Author

I’m going to close this, as the discussion seems to have ended and the answer to the original question appears to be “no”. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants