[CDRIVER-3941] Attempt to load libbson-1.0.so.0 when statically linked Created: 30/Mar/21 Updated: 27/Oct/23 Resolved: 28/Apr/21 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | None |
| Affects Version/s: | 1.17.4 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Thijs Cadier | Assignee: | Kevin Albertson |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Linux |
||
| Description |
|
I can successfully compile and link When using -DENABLE_STATIC=ON. When running the executable on a different system it still tries to load a dynamic libbson: error while loading shared libraries: libbson-1.0.so.0: cannot open shared object file: No such file or directory |
| Comments |
| Comment by Kevin Albertson [ 28/Apr/21 ] | |||||||||||||||||||||
|
I am glad to hear thijs@appsignal.com! Closing. | |||||||||||||||||||||
| Comment by Thijs Cadier [ 28/Apr/21 ] | |||||||||||||||||||||
|
Thanks for figuring this out. Based on this tip I made a few changes and it now works. | |||||||||||||||||||||
| Comment by Kevin Albertson [ 22/Apr/21 ] | |||||||||||||||||||||
|
Hi thijs@appsignal.com! I was able to reproduce this using a simple Rust project that includes a dependency for mongo_driver on macOS 11.2. The output of otool -l shows the produced target has a dependency on the dylibs:
I am not too familiar with the Rust build process, but applying this change worked for me:
The static and non-static package config scripts are separately named. pkg-config --static libmongoc-1.0 is equivalent to pkg-config libmongoc-1.0. To get the static build flags, use pkg-config libmongoc-static-1.0. | |||||||||||||||||||||
| Comment by Kevin Albertson [ 19/Apr/21 ] | |||||||||||||||||||||
|
Thank you for the additional information thijs@appsignal.com. We should have time to attempt to reproduce and investigate this issue this week. | |||||||||||||||||||||
| Comment by Thijs Cadier [ 18/Apr/21 ] | |||||||||||||||||||||
|
Any news on this? | |||||||||||||||||||||
| Comment by Thijs Cadier [ 01/Apr/21 ] | |||||||||||||||||||||
|
You can see the used options here. I know this option is picked up for mongoc itself correctly. Without this option it will also try to load that dynamically. I think you can reproduce this by compiling statically and trying to use the binary on a system that does not have the dynamic libs installed. | |||||||||||||||||||||
| Comment by Kevin Albertson [ 31/Mar/21 ] | |||||||||||||||||||||
|
Hi thijs@appsignal.com, thank you for the bug report! We will look into this soon. The cmake option ENABLE_STATIC should enable static libbson / libmongoc targets (libmongoc-static-1.0.a and libbson-static-1.0.a on Unix) to build and install. How are you configuring and building the application that is using libbson / libmongoc? Can you include the commands you are using to build your application (whether that is using cmake, pkg-config, etc.) |