Skip to content

[openctm] Cannot link with both 7zip and openctm #44085

@Tradias

Description

@Tradias

Is your feature request related to a problem? Please describe.

Openctm vendors parts of 7zip (LZMA-SDK to be precise). To avoid ODR violations it changes function names. Unfortunately it does not change all names and we end up with conflicts like these:

/usr/bin/ld.gold: error: /g/mr/vcpkg_installed/x64-linux-cxx20-rel/lib/lib7zip.a(LzmaEnc.c.o): multiple definition of 'LzmaEncode'
/usr/bin/ld.gold: /g/mr/vcpkg_installed/x64-linux-cxx20-rel/lib/libopenctm.a(LzmaEnc.c.o): previous definition here

For projects that use both openctm and 7zip.

Proposed solution

Patch openctm (which is unmaintained btw., so no use in creating upstream ticket) such that it uses the 7zip library provided by vcpkg. The patch is rather simple (see below)

Describe alternatives you've considered

No response

Additional context

To patch openctm:

Remove LZMA_PREFIX_CTM and add find_package etc. for 7zip in CMakeLists.txt

Adjust source code to the more recent version of 7zip:

diff --git a/lib/stream.c b/lib/stream.c
index 53b1b72..bb47c3b 100644
--- a/lib/stream.c
+++ b/lib/stream.c
@@ -310,8 +310,7 @@ int _ctmStreamWritePackedInts(_CTMcontext * self, CTMint * aData,
                          outProps,
                          &outPropsSize,
                          self->mCompressionLevel, // Level (0-9)
-                         0, -1, -1, -1, -1, -1,   // Default values (set by level)
-                         lzmaAlgo                 // Algorithm (0 = fast, 1 = normal)
+                         0, -1, -1, -1, -1, -1   // Default values (set by level)
                         );
 
   // Free temporary array
@@ -477,8 +476,7 @@ int _ctmStreamWritePackedFloats(_CTMcontext * self, CTMfloat * aData,
                          outProps,
                          &outPropsSize,
                          self->mCompressionLevel, // Level (0-9)
-                         0, -1, -1, -1, -1, -1,   // Default values (set by level)
-                         lzmaAlgo                 // Algorithm (0 = fast, 1 = normal)
+                         0, -1, -1, -1, -1, -1   // Default values (set by level)
                         );
 
   // Free temporary array

Metadata

Metadata

Assignees

Labels

category:port-featureThe issue is with a library, which is requesting new capabilities that didn’t exist

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions