Runtime error: libtinfo.so.5 not found

Linux specific questions.
Post Reply
xlucas
Posts: 334
Joined: May 09, 2014 21:19
Location: Argentina

Runtime error: libtinfo.so.5 not found

Post by xlucas »

I've been compiling my programs in the last months from my Linux Mint 64 bit distribution. Now I've installed standard Ubuntu (although I don't like it as much, but anyway) and I'm trying to run them and they all give me this message that libtinfo.so.5 is not found. I'm concerned... not just because I'm having trouble finding that lib, but because I had assumed that the libraries that FreeBasic programs required by default were usually all found in most distros, and when one says "most distros" nowadays, you have to include Ubuntu.

Is there a way I can compile my programs so that libraries like these get staticly linked?

EDIT: I just realised there are older threads about this and the solution is not simple :( Has anything changed that got this simpler recently? Please let me know.
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Re: Runtime error: libtinfo.so.5 not found

Post by srvaldez »

just do sudo apt install libtinfo5
caseih
Posts: 2157
Joined: Feb 26, 2007 5:32

Re: Runtime error: libtinfo.so.5 not found

Post by caseih »

I don't know why you're having trouble finding that library. It's in the repos as @srvaldez says. Linux Mint is based on Ubuntu, so Ubuntu instructions work there as well. Just install the libtinfo5 package (and the 32-bit version if you're trying to run 32-bit binaries). Does this not work for you?

Of course if you just recompile your .bas files, the new executables will work with your system ncurses6 and tinfo6 libraries.

Older distros of the long-term support variety, such as Ubuntu 18.04 or CentOS 7, are very much still using the older ncurses libraries. So keep compatibility with those, the FB binaries available for download tend to be build with those older libraries. Fortunately they are still available as optional installs on newer distros. I note that if you compile a .bas file on a system that defaults to the newer ncurses libraries, your binaries will depend on those instead of version 5. Such binaries will not run on the older LTS distros though.
xlucas
Posts: 334
Joined: May 09, 2014 21:19
Location: Argentina

Re: Runtime error: libtinfo.so.5 not found

Post by xlucas »

Thanks, guys. Yes, I understand that part. I wasn't finding the library because I was trying this:

Code: Select all

sudo apt-get install libtinfo
... assuming it would imply libtinfo.5 would be installed.

But my real concern is not about being able to compile my programs now or to run the programs I compiled before. As was said in another thread, this is an OS problem, not a FB problem. What I don't like is that now my old programs won't run in new distros and my new programs won't run in old distros, so users will be forced to recompile, which means downloading and installing FreeBasic and all the necessary development libraries, even though they are not programmers.

If there is one thing that GNU/Linux has always done wrong is this dependency problem. One should be able to download the binaries and just run them like in DOS or Windows.

Is there a way I can compile my programs so that they will look for version 6 and if it's not there, fall back to version 5 or something?
caseih
Posts: 2157
Joined: Feb 26, 2007 5:32

Re: Runtime error: libtinfo.so.5 not found

Post by caseih »

Having experience Windows DLL hell without versioning, I wouldn't say things are better on Windows! If Linux has always done it wrong, then Windows has always definitely done it wrong. It's an incredibly difficult problem to solve. Windows has only recently even attempted to solve it. Every proposal has pros and cons, usually a lot of cons.

You certainly could ship a specific shared library with a binary in Linux. When you download firefox from their web site, it comes with the shared libraries that it depends on, but which might not be on the destination system.

Supporting multiple distributions and older distributions is the main reason flatpak and snap were created. Or there's the AppImage project. Flatpak has a repository of standard runtimes you can depend on when making a flatpak of your app.

Windows has tried various solutions without much success, and Apple has application bundles but also installers and versioned framework bundles. There are pros and cons of each system. Certainly the best way--but not the most practical--is to have your software package officially maintained in the distros' official repositories. But that isn't an option for most of us with our hobby projects. Personally I'd lean towards making flatpaks if you want to distribute your software to most distributions. Or AppImage.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: Runtime error: libtinfo.so.5 not found

Post by D.J.Peters »

The linker option -static does the trick :)
(I use it for all C/C++ stuff for my customers.)

For examples it exists Firefox binaries they are linked static makes it much bigger and will run on 90% of all Linux distro.
(of course a running X-Server and a FLTK, GTK .. GUI must installed)

Not tested but FreeBASIC used -Wl to set options for the gcc linking stage.

Joshy
Landeel
Posts: 777
Joined: Jan 25, 2007 10:32
Location: Brazil
Contact:

Re: Runtime error: libtinfo.so.5 not found

Post by Landeel »

I just copy "libtinfo.a" to "/usr/local/lib/freebasic/linux-x86_64", and it gets statically linked.
xlucas
Posts: 334
Joined: May 09, 2014 21:19
Location: Argentina

Re: Runtime error: libtinfo.so.5 not found

Post by xlucas »

Thank you, guys. I'll try that. Linking statically would be great. If I should use FlatPak/Snap/AppImage, the one I like the most of the three is AppImage, but these things, I have to read more about to learn to make packages. I think I should learn this even if I weren't going to use it right now, because they're good things.

And if I'm going to carry the shared libraries with my software? Can I just copy them (with a compatible license) with my programs? Do I just put them in the same directory as the executable and the program will read them from there instead of looking them up in the OS?
Landeel
Posts: 777
Joined: Jan 25, 2007 10:32
Location: Brazil
Contact:

Re: Runtime error: libtinfo.so.5 not found

Post by Landeel »

Do I just put them in the same directory as the executable and the program will read them from there instead of looking them up in the OS?
No, that doesn't work on Linux. You would need a script to export 'LD_LIBRARY_PATH' and run your program. Not a very elegant solution, but many programs use it.
Libraries depend on other libraries, so make sure all dependencies are met. Use 'ldd'.
caseih
Posts: 2157
Joined: Feb 26, 2007 5:32

Re: Runtime error: libtinfo.so.5 not found

Post by caseih »

If you do want to ship shared libraries with a binary, you will need to write a small start script to set LD_LIBRARY_PATH before running the real executable. As an example (a complicated example), take a look at /usr/bin/firefox, which is just a script on most distros. Usually programs install to /opt, or if you're making a package, often they put things in /usr/lib/progname (for example on Fedora /usr/lib64/firefox/).

Alternatively (and probably better for you) one coudl make an AppImage bundle, or a flatpak.
xlucas
Posts: 334
Joined: May 09, 2014 21:19
Location: Argentina

Re: Runtime error: libtinfo.so.5 not found

Post by xlucas »

Yes, I agree. I think the AppImage would be the best, but I have to learn to make those packages. Anyway, it's interesting to find out how to go with each of the options and understand the system better. I've been reading AppImage online manual, but it's a long thing and I should make tests to make sure I'm understanding what I'm reading correctly. Also, I need to have several distros to test my package after I make it.
Post Reply