Skip to content

Instantly share code, notes, and snippets.

@lewdlime
Last active March 2, 2016 18:24
Show Gist options
  • Save lewdlime/62e0db70f1cab956837c to your computer and use it in GitHub Desktop.
Save lewdlime/62e0db70f1cab956837c to your computer and use it in GitHub Desktop.
Notes for building Git from source tarball or repository

Build Configurations

If you're building Git from it's latest source tarball or from the repository, remember to not use --with-shell="shell" if building with ./configure. Or at least don't use ZSH as the shell specified. Different shells cause errors due to differences in how variables are set and used during the build chain.

README - MongoDB Drivers

C Driver

version 1.3.3

From tarball:

NOTE: Check what the current release is first, and insert that version number for where $ver is below.

$ wget https://github.com/mongodb/mongo-c-driver/releases/download/$ver/mongo-c-driver-$ver.tar.gz
$ tar xzf mongo-c-driver-$ver.tar.gz
$ cd mongo-c-driver-$ver
$ ./configure
$ make
$ sudo make install

From git:

$ git clone https://github.com/mongodb/mongo-c-driver.git
$ cd mongo-c-driver
$ [git checkout x.y.z]  # To build a particular release
$ ./autogen.sh --with-libbson=bundled [--prefix=CDRIVER-INSTALL-PATH]
$ make
$ sudo make install

C++ Driver

version 3.0.0

NOTES: Requires the following:

  • CMake version 3.2+
  • automake
  • autoconf
  • libtool
  • Clang version 3.5+, Apple Clang version 5.1+, GCC version 4.8.2+, or VC2015 Update 1+
  • MongoDB C driver version 1.3.1+
$ git clone https://github.com/mongodb/mongo-c-driver.git
$ cd mongo-c-driver
$ ./autogen.sh --with-libbson=bundled [--prefix=CDRIVER-INSTALL-PATH]
$ [sudo] make && sudo make install
$ cd ..
$ git clone https://github.com/mongodb/mongo-cxx-driver.git
$ cd mongo-cxx-driver/build
$ [PKG_CONFIG_PATH=CDRIVER_INSTALL_PATH/lib/pkgconfig] cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local ..
$ [sudo] make && sudo make install

To test:

hellomongo.cpp:

#include <iostream>
#include <bsoncxx/builder/stream/document.hpp>
#include <bsoncxx/json.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/instance.hpp>

int main(int, char**) {
    mongocxx::instance inst{};
    mongocxx::client conn{mongocxx::uri{}};

    bsoncxx::builder::stream::document document{};

    auto collection = conn["testdb"]["testcollection"];
    document << "hello" << "world";

    collection.insert_one(document.view());
    auto cursor = collection.find({});

    for (auto&& doc : cursor) {
        std::cout << bsoncxx::to_json(doc) << std::endl;
    }
}
$ c++ --std=c++11 hellomongo.cpp -o hellomongo $(pkg-config --cflags --libs libmongocxx)
$ ./hellomongo

C# Driver

version 2.2.3

NOTE: Use NuGet to install.

<packages>
    <package id="MongoDB.Driver" version="2.2.0" />
    <package id="MongoDB.Driver.Core" version="2.2.0" />
    <package id="MongoDB.Bson" version="2.2.0" />
</packages>

Java Driver

version 3.2.2

$ git clone https://github.com/mongodb/mongo-java-driver.git
$ cd mongo-java-driver
$ ./gradlew check

Maven Install:

<dependencies>
    <dependency>
        <groupId>org.mongodb</groupId>
        <artifactId>mongodb-driver</artifactId>
        <version>3.2.2</version>
    </dependency>
</dependencies>

Gradle Install:

  dependencies {
    compile 'org.mongodb:mongodb-driver:3.2.2'
  }

Python Driver

version 3.2.1

NOTES: In addition to the standard driver, the following community drivers are also available:

[sudo] pip install [-U] pymongo

Node.JS Driver

version 2.1.7

[sudo] npm i [-g] mongodb

Ruby Driver

version 2.2.4

[sudo] gem install mongo

Scala Driver

version 1.1.0

SBT Install:

libraryDependencies += "org.mongodb.scala" %% "mongo-scala-driver" % "1.1.0"

Maven Install:

<dependencies>
    <dependency>
        <groupId>org.mongodb</groupId>
        <artifactId>mongo-scala-driver</artifactId>
        <version>1.1.0</version>
    </dependency>
</dependencies>

PHP Driver

version 1.1.2

$ pecl install mongodb
$ echo "extension=mongodb.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`

Perl Driver

version

Dist::Zilla Install:

$ cpanm --installdeps .
$ # using CPAN.pm, but bypassing non-functional pod tests
$ cpan TAP::Harness::Restricted
$ PERL_MM_USE_DEFAULT=1 HARNESS_CLASS=TAP::Harness::Restricted cpan Dist::Zilla
$ cpan `dzil authordeps`
$ dzil authordeps | cpanm
$ [dzil build]
$ [dzil test]
$ [dzil xtest]

cpanm Install:

$ # using cpanm, bypassing *all* tests
$ cpanm -n Dist::Zilla

Go Driver

version 2.0.0

[sudo] go get gopkg.in/mgo.v2
[sudo] go get gopkg.in/mgo.v2/bson
[sudo] go get gopkg.in/mgo.v2/txn

Erlang Driver

version 0.9.4

$ git clone git://github.com/comtihon/mongodb-erlang.git
$ cd mongodb-erlang
$ make

General Notes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment