I'm trying to install a linear programming solver in ocaml, but i can't get any modules to work
I found this : https://github.com/Gbury/Ocaml-simplex
and this : https://github.com/smimram/ocaml-glpk
I'm just following what's written to do (make / make install) but evertytime after the installation, when i try to open Glpk or open Simplex it's not working. In fact even the examples files included are not working
I don't know if I'm doing something wrong or if those modules are just not working
Please help me I'm becoming mad.
Additional information on my problem:
I'm on Debian, the last version I guess. To install the modules, I downloaded the zip files, i installed the required modules, then unzipped, ./configure, make, make install, just what's written on GitHub.
But then when i open an example test files, which begins by open Glpk (the module I'm trying to install), when i try to compile i've an error :
open Glpk
^^^^
Error: Unbound module Glpk
I mean I've found 3 modules to make linear programming solver:
https://github.com/OCamlPro-Iguernlala/ocplib-simplex
https://github.com/Gbury/Ocaml-simplex
https://github.com/smimram/ocaml-glpk
And I can't get any of them to work.
From your description, your issue is not installing libraries but using them. Once you have installed a library, you still need to inform the compiler on where are the compiled interfaces files (.cmi) for this library, and which object files should be linked (aka .cm(x)o and .cm(x)a) .
It will be much easier to let a package manager (like opam) and a build tool (like dune) take care of those minutiæ.
For instance, with opam and dune, you can first install ocplib-simplex:
opam install simplex
Then building a executable from a main.ml file using this library can be done with a dune file
(executable (name main) (libraries ocplib-simplex) )
and a call to
dune build main.exe
I managed to get Glpk working in no time. I think you should learn a bit about OPAM, the OCaml Package Manager. Its purpose is exactly to make library installation as easy as possible. Here's a step-by-step:
Prerequisites
I'm going to assume you have OPAM installed. If this is not the case, you'll find the information you need here. The easiest way to get OPAM working is to execute the following in a shell:
sh <(curl -sL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh) && \
opam init && \
eval $(opam env)
Installing Glpk
First, I tried to install Glpk as is.
opam install glpk
This failed with following error:
<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build glpk 0.1.8
└─
╶─ No changes have been performed
The packages you requested declare the following system dependencies. Please make sure they are installed before retrying:
libglpk-dev
This is because the OCaml library Glpk is actually a binding to a system library which needs to be installed separately. On Debian, you can use apt to do this.
sudo apt install libglpk-dev
Then I retried installing Glpk.
opam install glpk
It succeeded. Great.
Requiring Glpk
Now that the Glpk library is installed, you need to require it in order to make it available.
In a REPL
When using the OCaml toplevel, you need to use the following commands in order to require Glpk.
#use "topfind";;
#require "glpk";;
In a project
If you want to use libraries in a fully-fledged project (with multiple files, executables and whatnot), you should use a build system. The most popular OCaml build system today is Dune, which Octachron covered in his answer.
Further considerations
You should consider reading Real World OCaml, a great book that teaches from the ground up everything you need to know to build software with OCaml.
Related
I would like to use Ipopt in a CMake-based project using ExternalProject. The library should be installed locally and automatically in the build folder so that the user must not go through any hassle.
I can do this for simple enough repositories that do not have many dependencies; unfortunately, this is not the case for Ipopt, whose installation requires a set of packages to be installed first.
How can install and use Ipopt in a local, self-contained way using CMake ExternalProject? If this cannot be done, is there an approach that would make the process at least partially self-contained? I would be very grateful for any answer with a working CMake script!
I have recently started learning meson and I am testing switching to it (from CMake) in one of my projects. The problem is that I usually use cpack to build the project's packages/installers, and after scouring the meson docs for something similar to cpack I am unable to find anything.
Requirements/what I currently use cpack for
Single script to automatically build and package binary releases (such as deb, rpm, windows installer, etc)
Integrates with the build system - Picks up targets automatically, doesn't require redefining installation logic or structure
Supports building at least deb packages and a windows installer (don't care which)
There is the information on building release archives and then using scripts to process them with packaging tools (such as inno). However, this is not really what I am looking for as it is far more awkward and inflexible than cpack (i.e I have to change 3 different scripts if the directory structure changes).
Ultimately I can learn to use the meson system and manually write packaging scripts, no doubt it will make me a better scripter, however, I am eager to know if there is a better way of doing this which is not advertised in the docs or if there is some unofficial project which will automate the process.
Edit
By package I mean like a deb package - a package for a system package manager, not something like conan
I suggest that you use conan. Please take a look at conan configuration in the Meson.
It might be worth considering using meson rpm packaging module RPM module:
It autodetects installed files, dependencies and so on
This module as of now supports only generation of RPM spec file:
rpm = import('rpm')
rpm.generate_spec_template()
I'm trying to install Loris package link which is a library also for Python (my language). I have installed the package through bash commands in my OSX 10.12 system following these steps:
cd to the directory containing the package's source code and type
./configure to configure the package for your system. If you're
using csh on an old version of System V, you might need to type
sh ./configure instead to prevent csh from trying to execute
configure itself.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
Type `make' to compile the package.
Optionally, type `make check' to run any self-tests that come with
the package.
Type `make install' to install the programs and any data files and
documentation.
You can remove the program binaries and object files from the
source code directory by typing make clean. To also remove the
files that configure created (so you can compile the package for
a different kind of computer), type make distclean. There is
also a make maintainer-clean target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
The problem is that when I run both python 2.7 IDLE and the Atom editor it says that the module named Loris was not found. By default, make install will install the package's files in
/usr/local/bin,/usr/local/man.
Is this the problem? How can I install properly this library?
I wrote two libraries (Bson.ml and Mongo.ml) in ocaml.
I wish to enable it for opam.
In the instruction of opam, it says it needs make build and make install.
I am always using ocamlbuild and ocamlfind to build and install my library locally.
How can I produce a make file for opam?
Just do it the way other packages do it. For example the sequence package also uses vanilla ocamlbuild and ocamlfind. Here's the opam package description for it: https://github.com/OCamlPro/opam-repository/tree/master/packages/sequence.0.3.4 The opam file specifically.
I am new in Ubuntu/Linux and I've been working with java using the NetBeans IDE, so I don't have much experience with building c++ projects. But now I have to provide a proof of concept and I need to connect a C++ client with my ActiveMQ server. I downloaded The ActiveMQ-CPP API from this link, but I can't build/run it.
The download came with the files: Maklefile.am and Makefile.in. I searched it and I found that I need automake/autoconf to build it. I tried running ./configure but it says that it couldn't find such file or directory. I tried
sudo apt-get update
sudo apt-get install automake
sudo apt-get install autoconf
and a lot of other commands that I found on the Internet. None of then worked. I know that this question is really basic and it seems to be already answered somewhere else, but every attempt I've made failed. I think I'm missing something. I even tried the solution provided in the last message in this topic but it didn't work either.
Can anyone help me install autoconf/automake, or tell me how to use Makefile.am / Makefile.in to build the project I downloaded, or even suggest me some other way of building it?
Since you're open to other methods of building your project, I'm going to suggest CMake. It is a far better build system than autotools (at least from where I stand).
#CMakeLists.txt
project(MyProject CXX)
set_minimum_required(VERSION 2.8)
add_executable(foobar foo.cpp bar.cpp)
That example will build an executable called "foobar" by compiling and linking foo.cpp and bar.cpp. Put the above code in a file called CMakeLists.txt, then run the following commands:
cmake <path to project> #run in the folder you want to build in
make #this does the actual work
The really cool thing about CMake is that it generates a build system (Makefiles by default) but you can use it to generate project files for Eclipse, a Visual Studio solution, and a bunch of other things. If you want more information, I'd check out their documentation.
The "configure" script should be in your ActiveMQ-cpp source directory. From the Linux command line, you should be able to:
1) "cd" into your ActiveMQ* directory
2) "ls -l" to see the "configure" script
3) "./configure" to set things up for building the library\
4) "make" to actually build the library
This is mentioned in comments, but this particular point of confusion has been common for well over a decade and I think needs to be clarified as often as possible. You DO NOT need to have autoconf or automake installed to build a project that used those tools. The entire point of the autotools is to generate a build system that will build on a system using only the standard tools (make, a c compiler, sh, and few others.) Unfortunately, many developers release tarballs that do not build cleanly. If you unpack the tarball and it does not contain a configure script, or if the configure script is broken, that is a bug in the package. The solution is absolutely not to install autoconf/automake/libtool and try to produce a working configure script. The solution is to report the build error as a bug to the package maintainer.
The world would be a better place if Linux distributions stopped installing multiple versions of the autotools by default as less than .002% of the population needs those tools, and anyone who actually needs to have the tools should be capable of installing it themselves. Anyone incapable of acquiring and installing the tools has no business using them.