bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to create symlinks for shared library with soname


From: lijh8
Subject: How to create symlinks for shared library with soname
Date: Mon, 1 Jan 2024 04:20:37 +0800

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]