How to create symlinks for shared library with soname

2023-12-31 Thread lijh8
Hi community,


I just happen to notice that how symbolic links are created for library with 
soname.


libtool creates both symlinks to the real library file. 
But CMake creates one symlink to the real file and another symlink to the first 
symlink.


I'm sticking with manual Makefile but which way should I follow?


Thanks.


# my make script
define makever
@ $(MAKE) -C $@ soname=lib$@.so.$(word 1,$(subst ., ,$(1)))


@ cp $@/$@ $@/lib$@.so.$(1)


@ ( cd $@; \
ln -f -s lib$@.so.$(1) lib$@.so.$(word 1,$(subst ., ,$(1))) ; )


@ ( cd $@; \
ln -f -s lib$@.so.$(1) lib$@.so ; )
endef


---


Method 1: Autotools (libtool)


$ ls -l src/foo/.libs/
total 28
lrwxrwxrwx 1 ljh ljh    12 Jan  1 03:29 libfoo.la -> 
../libfoo.la
-rw-r--r-- 1 ljh ljh  3512 Jan  1 03:29 libfoo_la-foo.o
-rw-r--r-- 1 ljh ljh   916 Jan  1 03:29 libfoo.lai
lrwxrwxrwx 1 ljh ljh    15 Jan  1 03:29 libfoo.so -> 
libfoo.so.5.2.3
lrwxrwxrwx 1 ljh ljh    15 Jan  1 03:29 libfoo.so.5 -> 
libfoo.so.5.2.3
-rwxr-xr-x 1 ljh ljh 16480 Jan  1 03:29 libfoo.so.5.2.3
$ 




Method 2: CMake


$ ls -l foo/
total 32
drwxr-xr-x 3 ljh ljh  4096 Jan  1 03:56 CMakeFiles
-rw-r--r-- 1 ljh ljh  1254 Jan  1 03:56 cmake_install.cmake
lrwxrwxrwx 1 ljh ljh    11 Jan  1 03:56 libfoo.so -> 
libfoo.so.1
lrwxrwxrwx 1 ljh ljh    15 Jan  1 03:56 libfoo.so.1 -> 
libfoo.so.1.2.3
-rwxr-xr-x 1 ljh ljh 15368 Jan  1 03:56 libfoo.so.1.2.3
-rw-r--r-- 1 ljh ljh  7605 Jan  1 03:51 Makefile
$ 

?????? How to create symlinks for shared library with soname

2023-12-31 Thread lijh8
Hi, Paul!
Thank you and happy new year!

Re:How to create symlinks for shared library with soname

2023-12-31 Thread lijh8
sorry, I was meant to send it to the help-make list.

Re: How to create symlinks for shared library with soname

2024-01-02 Thread lijh8
Hi Paul,


I just come across the ldconfig manual. It seems it prefers the chained links 
like the CMake does too.


```
ldconfig expects a certain pattern to how the symbolic links are set up, 
like this example, where the middle file (libfoo.so.1 here)  is  the 
SONAME for the library:
    libfoo.so -> libfoo.so.1 -> libfoo.so.1.12

```