(L)Ubuntu Focal Fossa (20.04) and libtinfo.so.5

Linux specific questions.
Landeel
Posts: 735
Joined: Jan 25, 2007 10:32
Location: Brazil
Contact:

(L)Ubuntu Focal Fossa (20.04) and libtinfo.so.5

Postby Landeel » Apr 07, 2020 20:10

Hello,
I'm testing Lubuntu 20.04 Focal Fossa beta, and I have bumped into a small problem running my fbc compiled programs.
They all need 'libtinfo.so.5', but *Ubuntu 20.04 ships with 'libtinfo.so.6'.
It's still possible to install package libtinfo5 and satisfy the requirement, but this could be a pain for end users when distributing compiled programs.
People tend to just give up when the program doesn't run.
How to deal with that?
D.J.Peters
Posts: 8023
Joined: May 28, 2005 3:28
Contact:

Re: (L)Ubuntu Focal Fossa (20.04) and libtinfo.so.5

Postby D.J.Peters » Apr 07, 2020 20:43

Often you need only a symbolic link that points to libtinfo.so (in case the libtinfo.so.6 is in /usr/lib/)

sudo ln -s /usr/lib/libtinfo.so.5 /usr/lib/libtinfo.so.6

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

Re: (L)Ubuntu Focal Fossa (20.04) and libtinfo.so.5

Postby Landeel » Apr 07, 2020 21:17

D.J.Peters wrote:Often you need only a symbolic link that points to libtinfo.so (in case the libtinfo.so.6 is in /usr/lib/)

sudo ln -s /usr/lib/libtinfo.so.5 /usr/lib/libtinfo.so.6

Joshy

Good suggestion! I thought about that too, and did it, but I got:

./yagac-linux-x86_64: /lib/x86_64-linux-gnu/libtinfo.so.5: version `NCURSES_TINFO_5.0.19991023' not found (required by ./yagac-linux-x86_64)



I could install fbc on 20.04, and got it to compile both 32-bit and 64-bit, by installing all those libs:
sudo apt-get install gcc-multilib libncurses-dev libncurses-dev:i386 libx11-dev libx11-dev:i386 libxext-dev libxext-dev:i386 libxpm-dev libxpm-dev:i386 libxrandr-dev libxrandr-dev:i386 libxrender-dev libxrender-dev:i386 libzip-dev libzip-dev:i386 libgl-dev libgl-dev:i386


But then, the resulting executables will require libtinfo.so.6 instead of libtinfo.so.5.
So they won't work on previous Ubuntu versions. :~(

I love Linux, but what a mess.
badidea
Posts: 2000
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: (L)Ubuntu Focal Fossa (20.04) and libtinfo.so.5

Postby badidea » Apr 07, 2020 22:08

Thinking out loud here. What if you ship 'libtinfo.so.5' with the game, would that work?
Landeel
Posts: 735
Joined: Jan 25, 2007 10:32
Location: Brazil
Contact:

Re: (L)Ubuntu Focal Fossa (20.04) and libtinfo.so.5

Postby Landeel » Apr 08, 2020 0:05

badidea wrote:Thinking out loud here. What if you ship 'libtinfo.so.5' with the game, would that work?

Yes, I think I'll need to do that. It means I'll have to ship it with a runner script to set the libpath and load.
Also if I'm going to stick to 20.04, I need to figure out how to compile using the older libs. The glibc that ships with 20.04 is not backwards compatible it seems.
I remember having to do that years ago. I think I have just dropped the '.a' libs in /usr/local/lib/freebasic/..., not sure. I'll test it.
marcov
Posts: 2939
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: (L)Ubuntu Focal Fossa (20.04) and libtinfo.so.5

Postby marcov » Apr 08, 2020 9:45

I used to try to do this in the past too. Now I only make multiple builds in VMs for the various LTSes, and don't even attempt to support all distros. Much less work, and the experience is better.
Landeel
Posts: 735
Joined: Jan 25, 2007 10:32
Location: Brazil
Contact:

Re: (L)Ubuntu Focal Fossa (20.04) and libtinfo.so.5

Postby Landeel » Apr 08, 2020 11:27

Couldn't get it to compile with a different glibc.
I miss the old standalone fbc.
When I compile from 18.04, the executables are compatible down tô 14.04 if I'm not mistaken.
It's been a while since such breakage hapenned.
A VM is a solution. I will only need it for the final buils anyway.
Maybe I can setup a minimal container or a chroot.
Hm. a fbc snap with older libs could work.
caseih
Posts: 1489
Joined: Feb 26, 2007 5:32

Re: (L)Ubuntu Focal Fossa (20.04) and libtinfo.so.5

Postby caseih » Apr 08, 2020 19:57

I just built FBC 1.07 on my Centos 8 machine. I had to install the ncurses compatibility libraries to get my old bootstrap version of fbc to run. After building, the fbc compiler, runtime, and subsequent compiled executables all link against libtinfo.so.6, as I would expect. FBC is using the system GCC 8.3.1 compiler.

Note that while the CentOS 8 ncurses-compat-libs rpm supplies libtinfo.so.5 to make existing programs work, it does not provide header files, so the older fbc binaries will not be able to make working executables (no matter what the emitter is) since the new binaries will want to link against libtinfo.so.6 and the FB runtime will want libtinfo.so.5. Bootstrapping the latest fbc from an older version of fbc isn't too difficult.

On Ubuntu 20.04, either look for a compatibility library, or copy libtinfo.so.5 from another machine and use it just long enough to bootstrap a working version of the latest FBC that targets your system library versions.

I'm not quite sure what you meant when you miss the old standalone FBC. The problem with libtinfo.so.5 has nothing to do with FBC and everything to do with changes in the OS. You'd still encounter this problem even with the 32-bit assembly emitter version of FBC.

Note that all new distros are shipping libtinfo.so.6 now, and not all ship compatibility for libtinfo.so.5. So any binaries you ship will have to take that into account.
Landeel
Posts: 735
Joined: Jan 25, 2007 10:32
Location: Brazil
Contact:

Re: (L)Ubuntu Focal Fossa (20.04) and libtinfo.so.5

Postby Landeel » Apr 08, 2020 21:11

caseih wrote:I just built FBC 1.07 on my Centos 8 machine. I had to install the ncurses compatibility libraries to get my old bootstrap version of fbc to run. After building, the fbc compiler, runtime, and subsequent compiled executables all link against libtinfo.so.6, as I would expect. FBC is using the system GCC 8.3.1 compiler.

Note that while the CentOS 8 ncurses-compat-libs rpm supplies libtinfo.so.5 to make existing programs work, it does not provide header files, so the older fbc binaries will not be able to make working executables (no matter what the emitter is) since the new binaries will want to link against libtinfo.so.6 and the FB runtime will want libtinfo.so.5. Bootstrapping the latest fbc from an older version of fbc isn't too difficult.

On Ubuntu 20.04, either look for a compatibility library, or copy libtinfo.so.5 from another machine and use it just long enough to bootstrap a working version of the latest FBC that targets your system library versions.

I'm not quite sure what you meant when you miss the old standalone FBC. The problem with libtinfo.so.5 has nothing to do with FBC and everything to do with changes in the OS. You'd still encounter this problem even with the 32-bit assembly emitter version of FBC.

Note that all new distros are shipping libtinfo.so.6 now, and not all ship compatibility for libtinfo.so.5. So any binaries you ship will have to take that into account.


The thing I miss about the standalone fbc is that it helped me avoid the GLIBC compatibility issue. I used to drop older .a libs (mostly libc.a) in /usr/local/lib/freebasic/... and could get it to compile executables compatible with older distros. I couldn't make this work with current fbc, but it's been a while so I really can't remember the details.

The libtinfo is a different thing. I think I can statically link libtinfo into my executables by dropping the libtinfo.a into /usr/local/lib/freebasic/... , but I'm not sure that's allowed.

I'm trying to build a FreeBASIC snap with a 18.04 (core18) environment. No luck so far.
caseih
Posts: 1489
Joined: Feb 26, 2007 5:32

Re: (L)Ubuntu Focal Fossa (20.04) and libtinfo.so.5

Postby caseih » Apr 09, 2020 1:50

Are you talking about building a binary on 20.04 and wanting to run it on older distros?

What problems are you having building fbc on 18.04?

I think statically linking libtinfo is just fine.
Landeel
Posts: 735
Joined: Jan 25, 2007 10:32
Location: Brazil
Contact:

Re: (L)Ubuntu Focal Fossa (20.04) and libtinfo.so.5

Postby Landeel » Apr 09, 2020 2:00

caseih wrote:Are you talking about building a binary on 20.04 and wanting to run it on older distros?

What problems are you having building fbc on 18.04?

I think statically linking libtinfo is just fine.


Soon I will have to drop 18.04 and use only 20.04.
But I still need my binaries to run on 18.04 and older.

Making slow progress on the FreeBASIC snap. I could get a "hello world" to compile and run.
caseih
Posts: 1489
Joined: Feb 26, 2007 5:32

Re: (L)Ubuntu Focal Fossa (20.04) and libtinfo.so.5

Postby caseih » Apr 09, 2020 2:25

Yeah the only way to keep binary compatibility with older systems is to build against those older libraries. Glibc is backwards compatible, so linking against an older version of glibc will obviously still work on the newer versions. Glibc tries hard to keep the ABI backwards compatible.
Landeel
Posts: 735
Joined: Jan 25, 2007 10:32
Location: Brazil
Contact:

Re: (L)Ubuntu Focal Fossa (20.04) and libtinfo.so.5

Postby Landeel » Apr 10, 2020 14:06

I think I have figured out a solution without snap:

1) Copy 'libtinfo.a' to '/usr/local/lib/freebasic/linux-x86_64', so this will trick ld into statically linking it;

2) Call fbc like that:

Code: Select all

env LD_LIBRARY_PATH=/media/user/18.04/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH   fbc   foo.bas   -Wl --library-path=/media/user/18.04/usr/lib/x86_64-linux-gnu:/media/user/18.04/lib/x86_64-linux-gnu


Where '/media/user/18.04/' is my 18.04 installation mounted.

I think I can create a smaller environment for that, by copying all '.a' and '.so' libraries the compiler needs in a directory, and using that instead of a full 18.04 installation.

I will try to execute it and post the results.

EDIT:
Hm, couldn't get this to work yet.
Some libraries like 'libm.so' are just script files pointing to an absolute path, and that makes a mess.
Landeel
Posts: 735
Joined: Jan 25, 2007 10:32
Location: Brazil
Contact:

Re: (L)Ubuntu Focal Fossa (20.04) and libtinfo.so.5

Postby Landeel » Apr 10, 2020 19:04

And finally, it works.
The problem was all about libm, not libc.
Here's what I did:

1) Copied the following files from my 18.04 installation to '/usr/local/lib/freebasic/linux-x86_64' :

Code: Select all

-rw-r--r-- 1 root root 3570098 abr 10 15:40 libm-2.27.a
-rw-r--r-- 1 root root     249 abr 10 15:42 libm.a
-rw-r--r-- 1 root root     377 abr 10 15:45 libm.so
-rw-r--r-- 1 root root 1700792 abr 10 15:46 libm.so.6
-rw-r--r-- 1 root root  344348 abr 10 15:41 libmvec.a
-rw-r--r-- 1 root root    5974 abr 10 15:43 libmvec_nonshared.a
-rw-r--r-- 1 root root  170360 abr 10 15:47 libmvec.so.1
-rw-r--r-- 1 root root  279586 abr 10 10:30 libtinfo.a


2) The files 'libm.a' and 'libm.so' are not actual libraries, but scripts with hardcoded paths. I had to edit them and change the paths as follow:

libm.a:

Code: Select all

/* GNU ld script
*/
OUTPUT_FORMAT(elf64-x86-64)

 GROUP ( /usr/local/lib/freebasic/linux-x86_64/libm-2.27.a /usr/local/lib/freebasic/linux-x86_64/libmvec.a )


libm.so:

Code: Select all

/* GNU ld script
*/
OUTPUT_FORMAT(elf64-x86-64)

 GROUP ( /usr/local/lib/freebasic/linux-x86_64/libm.so.6  AS_NEEDED ( /usr/local/lib/freebasic/linux-x86_64/libmvec_nonshared.a /usr/local/lib/freebasic/linux-x86_64/libmvec.so.1 ) )


Now the programs I compile on 20.04 can also run on 18.04.

No more "version `GLIBC_2.29' not found".

No more "/usr/lib/x86_64-linux-gnu/libtinfo.so.6: version `NCURSES6_TINFO_5.0.19991023' not found".
Landeel
Posts: 735
Joined: Jan 25, 2007 10:32
Location: Brazil
Contact:

Re: (L)Ubuntu Focal Fossa (20.04) and libtinfo.so.5

Postby Landeel » Apr 11, 2020 16:19

I have made an experimental fbc snap: https://www.freebasic.net/forum/viewtopic.php?f=5&t=28447

Return to “Linux”

Who is online

Users browsing this forum: No registered users and 2 guests