How to fix the Unbound module Graphics in an ocaml project

Image
From ~/pr/gitl/ocaml-gol In a constant effort to learn new programming languages, I'm currently trying to use ocaml , a free and open-source general-purpose, multi-paradigm programming language maintained at the Inria . It's basically an extension of Caml with object-oriented features. I'm mostly interested by its functionnal and pattern matching features but the module part of the language can be a bit difficult to understand for someone with little to none ML (Meta Language) background.   The error When trying to use the graphics module to create a graphical window and go just a little further than the simplest helloworld program, here is the result : If the project uses dune : (executable (name ocaml_project) (libraries lwt.unix graphics) ) with this code : let () = Printf.printf "Hello, world!\n";; Lwt_io.printf "Hello, world!\n";; Graphics.open_graph " 800x600";; The first times I built this project running the du

How to use MongoDB on travis-ci

Using continuous integration for rainbrurph, I need the mongodb database and C libraries. Unfortunately, I had issue using it on Ubuntu Precise 12.04 LTS, the distribution used on travis-ci.

To make it work, we'll have to :
  1. install database components from the official MongoDB repositories;
  2. manually build the latest release of the official C libraries;
  3. add /usr/local/ to ld.conf to make your build system discover the newly installed library.


Note: I use the \ character to split long lines here, please concatenate splitted lines.
The travis.yml file at github

Install the database

We have to install the official package from the mongodb.org servers :

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 \
  --recv EA312927
echo "deb http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.2 \
  multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
sudo apt-get update
sudo apt-get install -y mongodb-org

Build the driver library

To be able to use mongodb in C programming language, we need a C library. We'll use the 1.4.0 version :

git clone https://github.com/mongodb/mongo-c-driver.git
cd mongo-c-driver
git checkout 1.4.0
./autogen.sh
make
sudo make install

Handle ld.conf

And to handle mongodb library linking, we must update ldconfig:
grep local /etc/ld.so.conf || (sudo echo "/usr/local/lib" >> \
  /etc/ld.so.conf && sudo ldconfig)

Conclusion

Finally, here is the .travis.yml file:
sudo: required
os:
- linux
branches:
  only:
    - master
    - mongodb-script


before_install: ./CI/before_install.sh
The CI/before_install.sh file will look like this:
#!/bin/sh

# Install the mongodb components and the C client library

## Install the mongo Database
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 \
  --recv EA312927
echo "deb http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.2 \
  multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
sudo apt-get update
sudo apt-get install -y mongodb-org

## Install the C library
git clone https://github.com/mongodb/mongo-c-driver.git
cd mongo-c-driver
git checkout 1.4.0
./autogen.sh
make
sudo make install

## Handle linking from /usr/local
sudo echo "/usr/local/lib" > /etc/ld.so.conf.d/mongodb.conf
sudo ldconfig

Comments

  1. CI and CD are two acronyms that are regularly made reference to when individuals discuss present day advancement hones. CI is clear and stands for persistent combination, I find a very good website for the Travis CI Build Monitoring , If you want you can visit this site.

    ReplyDelete

Post a Comment

Popular posts from this blog

How to make a map of variant in C++