Linux: incorrect symbolic links to shared libraries

Issue #62 closed
djcj created an issue

When building on Linux, the following shared lib files will be created:

  • libx265.so.1.1 (file)
  • libx265.so.22 (link)
  • libx265.so (link)

But as far as I know the number after the .so extension should only be the soversion:

  • libx265.so.22 (file)
  • libx265.so (link)

I was able to achieve this by patching source/CMakeLists.txt:

--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -282,11 +282,13 @@
         set_target_properties(x265-shared PROPERTIES OUTPUT_NAME x265)
     endif()
     if(UNIX AND NOT APPLE)
-        set_target_properties(x265-shared PROPERTIES LINK_FLAGS "-Wl,-Bsymbolic,-znoexecstack")
+        set_target_properties(x265-shared PROPERTIES VERSION ${X265_BUILD} LINK_FLAGS "-Wl,-Bsymbolic,-znoexecstack")
+    else()
+        set_target_properties(x265-shared PROPERTIES VERSION ${X265_LATEST_TAG})
     endif()
     if(X265_LATEST_TAG)
         # shared library is not installed if a tag is not found
-        set_target_properties(x265-shared PROPERTIES VERSION ${X265_LATEST_TAG} SOVERSION ${X265_BUILD})
+        set_target_properties(x265-shared PROPERTIES SOVERSION ${X265_BUILD})
         install(TARGETS x265-shared
                 LIBRARY DESTINATION ${LIB_INSTALL_DIR}
                 ARCHIVE DESTINATION ${LIB_INSTALL_DIR})

The binaries were still linked properly:

djcj: x265 $ readelf -d libx265.so.22 | grep -e SONAME
 0x000000000000000e (SONAME)             soname der Bibliothek: [libx265.so.22]
djcj: x265 $ readelf -d x265 | grep -e NEEDED
 0x0000000000000001 (NEEDED)             Gemeinsame Bibliothek [libx265.so.22]
 0x0000000000000001 (NEEDED)             Gemeinsame Bibliothek [libpthread.so.0]
 0x0000000000000001 (NEEDED)             Gemeinsame Bibliothek [libstdc++.so.6]
 0x0000000000000001 (NEEDED)             Gemeinsame Bibliothek [libc.so.6]

Comments (4)

  1. djcj reporter

    No, it still doesn't work. It created libx265.so.1.2 (file), libx265.so (link) and libx265.so.27 (link). But if I apply the changes from my first post it does work.

  2. Log in to comment