[CDRIVER-2603] Remove shared lib dependencies from pkg-config link line Created: 10/Apr/18  Updated: 28/Oct/23  Resolved: 25/Apr/18

Status: Closed
Project: C Driver
Component/s: libmongoc
Affects Version/s: 1.9.4
Fix Version/s: 1.10.0

Type: Bug Priority: Major - P3
Reporter: Remi Collet Assignee: A. Jesse Jiryu Davis
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

/usr/lib64/pkgconfig/libmongoc-1.0.pc contains:

Libs: -L${libdir} -lmongoc-1.0 -lsasl2  -lssl -lcrypto  -lrt -lresolv -lz  -lsnappy 

But applications linked against libmongoc probably don't need these library.

Reported as https://bugzilla.redhat.com/1560611



 Comments   
Comment by Githook User [ 25/Apr/18 ]

Author:

{'email': 'jesse@mongodb.com', 'username': 'ajdavis', 'name': 'A. Jesse Jiryu Davis'}

Message: CDRIVER-2603 no shared libs in libmongoc-1.0.pc
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/3dde5391d56dc39dd092916da70889d2ec3fbc6a

Comment by A. Jesse Jiryu Davis [ 18/Apr/18 ]

"private" does not, in my experience, actually work for static libraries. So for static libs we ship an entirely separate pkg-config file, libmongoc-static-1.0.

Comment by Remi Collet [ 18/Apr/18 ]

> ... we can remove the dependency libraries ....

Rather move them to "private" (as in libzip example above), so people can use them for static build

With

Libs: -L${libdir} -lmongoc-1.0
Libs.private: -lsasl2  -lssl -lcrypto  -lrt -lresolv -lz  -lsnappy

You can use

$ pkg-config --libs libmongoc-1.0 
-lmongoc-1.0 -lbson-1.0 
$ pkg-config --libs --static libmongoc-1.0 
-lmongoc-1.0 -lsasl2 -lssl -lcrypto -lrt -lresolv -lz -lsnappy -lbson-1.0 

Comment by A. Jesse Jiryu Davis [ 17/Apr/18 ]

Thanks for the explanation, it seems we can remove the dependency libraries from the pkg-config output for libmongoc-1.0. Thanks.

Comment by Remi Collet [ 17/Apr/18 ]

From a quick try, manually changing libmongoc-1.0.pc to

Libs: -L${libdir} -lmongoc-1.0

Then building pecl/mongdb extension

./configure   --with-libbson --with-libmongoc --with-mongodb-sasl --enable-mongodb}}
   ...
   MONGODB_SHARED_LIBADD                            : -lsasl2  -lbson-1.0 -lmongoc-1.0 -lbson-1.0 -lrt

Build is ok, and test suite passes.
So pecl/mongdb doesn't need this private libaries

Comment by Remi Collet [ 17/Apr/18 ]

> Fedora packages should depend on OpenSSL, zLib, SASL, and Snappy.

Indeed, this is now fixed.

But having some library used by mongo-c-driver, doesn't mean that every client application will use symbols from this library, so that the have to be linked against this "private" library.

Comment by A. Jesse Jiryu Davis [ 13/Apr/18 ]

OK, I think the answer is, our Fedora packages should depend on OpenSSL, zLib, SASL, and Snappy. I don't think this is a bug in our code. See Roberto's explanation in the linked ticket, his comment here:

https://jira.mongodb.org/browse/CDRIVER-2610?focusedCommentId=1863425&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-1863425

Comment by A. Jesse Jiryu Davis [ 12/Apr/18 ]

Remi, our latest Debian package configuration does depend on zlib and snappy:

https://github.com/mongodb/mongo-c-driver/blob/debian/debian/control

It maybe should also depend on libresolv (I've opened CDRIVER-2610 to investigate). I believe our Fedora package should depend on zlib, snappy, and libresolv as well.

Comment by A. Jesse Jiryu Davis [ 10/Apr/18 ]

Thanks Remi, we'll take a look.

Comment by Remi Collet [ 10/Apr/18 ]

Same issue affects some other projects, for ex, see how this was fixed in libzip
https://github.com/nih-at/libzip/commit/ab8a9984c26d748773751881094ddc5ed2426ca5

Generated at Wed Feb 07 21:15:45 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.