1BSON_INCLUDE_AND_LINK(3)            libbson           BSON_INCLUDE_AND_LINK(3)
2
3
4

INCLUDE BSON.H

6       All  libbson's  functions  and  types are available in one header file.
7       Simply include bson.h:
8
9       hello_bson.c
10
11          #include <stdio.h>
12          #include <bson/bson.h>
13
14          int
15          main (int argc, const char **argv)
16          {
17             bson_t *b;
18             char *j;
19
20             b = BCON_NEW ("hello", BCON_UTF8 ("bson!"));
21             j = bson_as_canonical_extended_json (b, NULL);
22             printf ("%s\n", j);
23
24             bson_free (j);
25             bson_destroy (b);
26
27             return 0;
28          }
29
30

CMAKE

32       The libbson installation includes a CMake config-file package,  so  you
33       can  use  CMake's find_package command to import libbson's CMake target
34       and link to libbson (as a shared library):
35
36       CMakeLists.txt
37
38          # Specify the minimum version you require.
39          find_package (bson-1.0 1.7 REQUIRED)
40
41          # The "hello_bson.c" sample program is shared among four tests.
42          add_executable (hello_bson ../../hello_bson.c)
43          target_link_libraries (hello_bson PRIVATE mongo::bson_shared)
44
45
46       You can  also  use  libbson  as  a  static  library  instead:  Use  the
47       mongo::bson_static CMake target:
48
49          # Specify the minimum version you require.
50          find_package (bson-1.0 1.7 REQUIRED)
51
52          # The "hello_bson.c" sample program is shared among four tests.
53          add_executable (hello_bson ../../hello_bson.c)
54          target_link_libraries (hello_bson PRIVATE mongo::bson_static)
55
56

PKG-CONFIG

58       If  you're  not  using CMake, use pkg-config on the command line to set
59       header and library paths:
60
61          gcc -o hello_bson hello_bson.c $(pkg-config --libs --cflags libbson-1.0)
62
63
64       Or to statically link to libbson:
65
66          gcc -o hello_bson hello_bson.c $(pkg-config --libs --cflags libbson-static-1.0)
67
68

AUTHOR

70       MongoDB, Inc
71
73       2017-present, MongoDB, Inc
74
75
76
77
781.25.1                           Nov 08, 2023         BSON_INCLUDE_AND_LINK(3)
Impressum