Skip to content

Commit 434b47a

Browse files
committed
Allow mongo-c and json-c drivers installation at custom locations.
autogen.sh helps in avoiding manual installation and automates the download and installation of the appropriate drivers and libraries including mongo-c and json-c driver. But, these drivers get installed at the default locations e.g. /usr/lib/, and user might not have permission to write in this directory. This results in autogen.sh failure. Use environment variables MONGOC_INSTALL_DIR and JSONC_INSTALL_DIR in autogen.sh to set CMAKE_INSTALL_PREFIX to allow custom directory installation for these drivers where the user might have permission. Reported on GitHub through issue #152 by user pgloader. FDW-406, Vaibhav Dalvi, reviewed by Jeevan Ladhe, tested by Rajkumar Raghuwanshi.
1 parent 3d43081 commit 434b47a

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

README.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,34 @@ different type of MongoDB drivers and supported libraries. If you want
9696
to avoid the manual steps, there is a shell script available which will
9797
download and install the appropriate drivers and libraries for you.
9898
99-
Here is how it works :
99+
Here is how it works:
100+
101+
To install mongo-c and json-c libraries at custom locations, you need to
102+
export environment variables `MONGOC_INSTALL_DIR` and `JSONC_INSTALL_DIR`
103+
respectively. If these variables are not set then these libraries will be
104+
installed in the default location. Please note that you need to have the
105+
required permission to install the directory whether it is custom or default.
106+
107+
The `PKG_CONFIG_PATH` environment variable must be set to mongo-c-driver source
108+
directory for successful compilation as shown below,
109+
110+
```sh
111+
export PKG_CONFIG_PATH=$YOUR_MONGO_FDW_SOURCE_DIR/mongo-c-driver/src/libmongoc/src:$YOUR_MONGO_FDW_SOURCE_DIR/mongo-c-driver/src/libbson/src
112+
```
113+
114+
The `LD_LIBRARY_PATH` environment variable must include the path to the mongo-c
115+
installation directory containing the libmongoc-1.0.so and libbson-1.0.so
116+
files. For example, assuming the installation directory is /home/mongo-c and
117+
the libraries were created under it in lib64 sub-directory, then we can define
118+
the `LD_LIBRARY_PATH` as:
119+
120+
```sh
121+
export LD_LIBRARY_PATH=/home/mongo-c/lib64:$LD_LIBRARY_PATH
122+
```
123+
124+
Note: This `LD_LIBRARY_PATH` environment variable setting must be in effect
125+
when the `pg_ctl` utility is executed to start or restart PostgreSQL or
126+
EDB Postgres Advanced Server.
100127

101128
Build with [MongoDB][1]'s legacy branch driver
102129
* autogen.sh --with-legacy

autogen.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
MONGOC_VERSION=1.17.3
1818
JSONC_VERSION=0.15-20200726
19+
MONGOC_INSTALL="${MONGOC_INSTALL_DIR}"
20+
JSONC_INSTALL="${JSONC_INSTALL_DIR}"
1921

2022
if [ "$#" -ne 1 ]; then
2123
echo "Usage: autogen.sh --[with-legacy | with-master]"
@@ -71,7 +73,7 @@ function checkout_json_lib
7173
function install_json_lib
7274
{
7375
cd json-c &&
74-
$CMAKE_COMMAND $JSONC_CFLAGS . &&
76+
$CMAKE_COMMAND -DCMAKE_INSTALL_PREFIX=$JSONC_INSTALL $JSONC_CFLAGS . &&
7577
make install &&
7678
cd ..
7779
}
@@ -82,7 +84,7 @@ function install_json_lib
8284
function install_mongoc_driver
8385
{
8486
cd mongo-c-driver &&
85-
$CMAKE_COMMAND -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF -DENABLE_SSL=AUTO . &&
87+
$CMAKE_COMMAND -DCMAKE_INSTALL_PREFIX=$MONGOC_INSTALL -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF -DENABLE_SSL=AUTO . &&
8688
make install &&
8789
cd ..
8890
}

0 commit comments

Comments
 (0)