[MONGOCRYPT-70] libmongocrypt: Build static link of libbson by default Created: 21/May/19  Updated: 28/Oct/23  Resolved: 24/May/19

Status: Closed
Project: Libmongocrypt
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Roberto Sanchez Assignee: Roberto Sanchez
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by MONGOCRYPT-51 Publishing task for libmongocrypt Jav... Closed
Epic Link: Build libmongocrypt library

 Description   

In CDRIVER-2973, the linkage of libmongocrypt to libbson was changed from static to dynamic in order to prevent problems with symbol clashes when a libmongocrypt consumer also links directly to libbson. However, there are instances where the static linkage is preferable. Specifically the libmongocrypt Java implementation, which loads a .so/.dll via JNA, is drastically simplified by only requiring the loading of a single library file. The dynamic linkage situation forces users of the Java bindings to either install libbson in a system-wide location or to set the LD_LIBRARY_PATH environment variable to the location of libbson in order to enable the dynamic linker to satisfy the dependencies.

The desired approach is instead to make a static linkage of libbson the default (most consumers of this library will never have a need to link directly to libbson) and to allow dynamic linkage based on a build flag for those consumers which require it (i.e., the C driver, which links directly to both libmongocrypt and libbson).

The artifacts published by this ticket's parent (CDRIVER-3133) will be the static-linked version.



 Comments   
Comment by Githook User [ 24/May/19 ]

Author:

{'name': 'Roberto C. Sánchez', 'email': 'roberto@connexer.com', 'username': 'rcsanchez97'}

Message: CDRIVER-3140 statically link to libbson by default
Branch: master
https://github.com/10gen/libmongocrypt/commit/2d5c4951f227ab7e9718da6140806a02e7f28ac7

Comment by Roberto Sanchez [ 21/May/19 ]

Is it expected that users of the Java bindings will have other mongo-c libraries installed on their systems? Based on our discussion in the stand up today I thought that the Java bindings ought to be self-contained. Even if other libraries are shipped within the same JAR, what you are suggesting would require that the JAR be unpacked somewhere on the system in order for the dynamic linker to find the libraries. I do not think that would be considered desirable.

Comment by Andrew Morrow (Inactive) [ 21/May/19 ]

Wouldn't this be fixed if libmongocrypt simply had a DT_RUNPATH entry pointing to where the other mongo-c libraries are installed? Potentially using $ORIGIN if you intend that location to be relocatable?

Generated at Thu Feb 08 09:07:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.