# Error while loading linux shared libraries



## Deleted member 62382 (Sep 1, 2020)

Hello,

I'm trying to use a linux binary on FreeBSD. 
I've followed the instructions from the handbook. 

When I tried to run the binary, I got this error message: 


```
/lib64/libc.so.6: version `GLIBC_2.18' not found (required by ./deno)
```

I then launched a CentOS instance and copied `/lib64/libc-2.28.so` to my FreeBSD system.
I then created a new symlink and have these two files in `/compat/linux/lib64`


```
...
-rwxr-xr-x  1 root  wheel  4176104 Sep  1 10:04 libc-2.28.so
lrwxr-xr-x  1 root  wheel       12 Sep  1 10:06 libc.so.6 -> libc-2.28.so
...
```


When I try to execute the binary, I now have this error message: 

```
./deno: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
```

It seems the symlink is not working for whatever reason. Does someone has any idea why?


----------



## st1905 (Sep 1, 2020)

```
strings /lib64/libstdc++.so.6 | grep GLIBC
```

Probably there is no GLIBC_2.18 in the output so that`s why you are getting "cannot open shared object file"


----------



## Deleted member 62382 (Sep 1, 2020)

You're right, there's no GLIBC_2.18 when I run your command.
Why using this commande on `libstdc++.so.6` though?

When i run:

```
strings /compat/linux/lib64/libc.so.6 | grep GLIBC
```

there's GLIBC_2.18 in the output


----------



## st1905 (Sep 1, 2020)

hugues said:


> You're right, there's no GLIBC_2.18 when I run your command.
> Why using this commande on `libstdc++.so.6` though?
> 
> When i run:
> ...



If there is GLIBC_2.18 there, there could be a symlink issue. Not sure, please discard my previous message, i wrote it wrong.

Can you move the symlink to a backup file then hard copy libc-2.28.so to libc.so.6 and try running ./deno


----------



## Deleted member 62382 (Sep 3, 2020)

I get the same error when I copy (with either `cp` or `ln`) libc-2.28.so to libc.so.6


----------



## ekvz (Sep 3, 2020)

If i remeber correctly (at least under linux) "cannot open shared object file" might as well mean that some dependencies could not be satisfied but then libc.so shouldn't really have any? Might still be worth checking what `ldd` thinks of libc.so.6.


----------



## Deleted member 62382 (Sep 3, 2020)

I can't use `ldd` because it only works on FreeBSD binaries.
The linux one (`/compat/linux/usr/bin/ldd`) doesn't work: same error message than when trying to run ./deno


----------



## ekvz (Sep 3, 2020)

hugues said:


> I can't use `ldd` because it only works on FreeBSD binaries.



Oh, that's interesting. I thought ELF file would be ELF file in this regard.



hugues said:


> The linux one (`/compat/linux/usr/bin/ldd`) doesn't work: same error message than when trying to run ./deno



Did you pass a full path to the library? Can you run other binaries from /compat/linux/usr/bin?


----------



## acheron (Sep 4, 2020)

This is what I've done recently to run an recent linux binary (don't do this on a production server, do some tests before):


```
# as a normal user:
mkdir update_centos8
cd update_centos8
fetch http://mirror.centos.org/centos-8/8.2.2004/BaseOS/x86_64/os/Packages/glibc-2.28-101.el8.x86_64.rpm

tar xf glibc-2.28-101.el8.x86_64.rpm ./lib64/ld-2.28.so
tar xf glibc-2.28-101.el8.x86_64.rpm ./lib64/libc-2.28.so
tar xf glibc-2.28-101.el8.x86_64.rpm ./lib64/libpthread-2.28.so

# as root (replace "/home/user" with the correct path):
cd /compat/linux/lib64
cp -f /home/user/update_centos8/lib64/* .

rm libc.so.6 ld-linux-x86-64.so.2 libpthread.so.0
ln -s ld-2.28.so ld-linux-x86-64.so.2
ln -s libc-2.28.so libc.so.6
ln -s libpthread-2.28.so libpthread.so.0

# then this command should work
/compat/linux/bin/ls
```

EDIT: fix various mistakes


----------



## acheron (Sep 4, 2020)

hugues said:


> When I try to execute the binary, I now have this error message:
> 
> ```
> ./deno: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
> ```


Are you trying to run this program https://github.com/denoland/deno/ ?


----------



## Deleted member 62382 (Sep 4, 2020)

acheron said:


> Are you trying to run this program https://github.com/denoland/deno/ ?


Yes, it's deno.



acheron said:


> This is what I've done recently to run an recent linux binary (don't do this on a production server, do some tests before):
> 
> 
> ```
> ...




Thanks for you answer. I've tried to run what you wrote but I get `FATAL: kernel too old` whenever I try to run any binary from `/compat/linux`.
Is there any step you forgot to mention?


----------



## acheron (Sep 4, 2020)

I'm running 13-current, try to bump compat.linux.osrelease to 3.10.0 (with `sysctl compat.linux.osrelease=3.10.0`

Or you can use my not yet committed ports: https://github.com/MikaelUrankar/deno-ports (make sure to checkout the latest version: 1.3.2). It doesn't require linux.


----------



## Deleted member 62382 (Sep 6, 2020)

I've tried to run the same command on 13-current. `/compat/linux/bin/ls` and the other linux binaries are working fine. However, I get `Segmentation fault (core dumped)` when running `./deno`. Do you have any idea why?
Thanks for the link. I'll try your port later, but I'd also like to make the linux `./deno` binary work on FreeBSD.


----------



## acheron (Sep 9, 2020)

hugues said:


> I've tried to run the same command on 13-current. `/compat/linux/bin/ls` and the other linux binaries are working fine. However, I get `Segmentation fault (core dumped)` when running `./deno`. Do you have any idea why?


Probably some incompatible old libs, it seems to work if you update the whole glibc, ie something like that `tar xpf /root/update_centos8/glibc-2.28-101.el8.x86_64.rpm -C /compat/linux/` (or use rsync if you have some symlink errors)


----------



## Deleted member 62382 (Sep 10, 2020)

It's finally working. Thanks a lot for your help and explanations, I really appreciate it


----------



## acheron (Sep 10, 2020)

Were you able to test my port?


----------



## Deleted member 62382 (Sep 10, 2020)

The compilation just finished and it's working. Thanks for you work!
Please note I had to delete the if line 22 and 349 of the Makefile, because I had this error message: `line 23: Malformed conditional`.
I also had to run `portsnap fetch extract` because of this error message: `make: "/usr/share/mk/bsd.port.mk" line 32: Cannot open /usr/ports/Mk/bsd.port.mk`


----------



## acheron (Sep 11, 2020)

hugues said:


> The compilation just finished and it's working. Thanks for you work!
> Please note I had to delete the if line 22 and 349 of the Makefile, because I had this error message: `line 23: Malformed conditional`.
> I also had to run `portsnap fetch extract` because of this error message: `make: "/usr/share/mk/bsd.port.mk" line 32: Cannot open /usr/ports/Mk/bsd.port.mk`


Weird, I don't have this error. Do you build with poudriere? Do you have a build log available?
Thanks for testing!


----------



## Deleted member 62382 (Sep 11, 2020)

You're welcome! I built it with `sudo make`. I haven't had time to use poudriere yet. And no sorry I don't have the build log availables


----------



## acheron (Sep 16, 2020)

Committed: https://svnweb.freebsd.org/ports?view=revision&revision=548789


----------

