[CDRIVER-4813] Document library consumption from Scons & meson Created: 12/Jan/24 Updated: 06/Feb/24 Resolved: 06/Feb/24 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | None |
| Affects Version/s: | 1.21.0 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | LIU Hao | Assignee: | Unassigned |
| Resolution: | Gone away | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
Updated description: Based on the discussion in this ticket, it is apparent that we need to document the proper way to consume libbson and libmongoc from some build systems. We currently provide pkg-config and CMake scripts which can be used directly by autotools and CMake, respectively. However, for other build systems it is necessary to document that consumption of libbson and libmongoc requires leveraging the build system's pkg-config compatibility features. See the discussion in this ticket for details and pointers. Original description follows: First of all, thank you. I appreciate your great work! I am using the prebuilt libmongoc from Ubuntu Jammy, installable with APT. I notice that libmogoc and libbson headers are installed to `/usr/include/libmongoc-1.0/mongoc/` and `/usr/include/libbson-1.0/bson/`, instead of the conventional `/usr/include/`. So when I do
I get errors such as
The documentation only mentions cmake and pkg-config. For other build systems, such scons and meson, I have to hard-code the include path, by passing
This is not only inconvenient, but also prevents overriding the system library with a custom one, typically installed into `/usr/local/include`. So, are there any reasons why these headers are not installed to `/usr/include/libmongoc-1.0/mongoc/` instead of the more conventional `/usr/include/mongoc/`? Thanks in advance. |
| Comments |
| Comment by LIU Hao [ 27/Jan/24 ] |
|
Apologies for the confusion; forgot to attach the dependency to the program. |
| Comment by Roberto Sanchez [ 27/Jan/24 ] |
|
That is a good point about the difference between -I and -isystem. I will raise the issue within the team to see if we might be able to change our generated .pc files. |
| Comment by LIU Hao [ 26/Jan/24 ] |
|
Well, using a standard include path has a side effect: GCC knows it is a system header and suppress warnings.
For mongoc, pkg-config gives two directories using -I instead of -isystem: $ pkg-config --cflags libmongoc-1.0
If I add -Werror=sign-conversion then I get errors from bson headers: /usr/include/libbson-1.0/bson/bson-iter.h: In function ‘uint32_t bson_iter_utf8_len_unsafe(const bson_iter_t*)’: |
| Comment by LIU Hao [ 26/Jan/24 ] |
|
Thanks! This works for me: project('mongoc_version', 'c') |
| Comment by Roberto Sanchez [ 25/Jan/24 ] |
|
lh_mouse@126.com, have you considered making use of the facilities available in SCons and meson for this particular need? From the SCons documentation:
From the Meson documentation:
Consuming the libmongoc and libbson in this way will also ensure that you have the correct linker flags, preprocessor definitions, etc. Please let us know if this works for you. |
| Comment by LIU Hao [ 24/Jan/24 ] |
Proposed solutionInstall two additional symbol links, which point to directories of the latest version: bson => libbson-1.0/bson |
| Comment by PM Bot [ 12/Jan/24 ] |
|
Hi lh_mouse@126.com, thank you for reporting this issue! The team will look into it and get back to you soon. |