OCaml graphics package - graphics

I have installed OCaml on my xfce and now I want to do some graphics program.
The problem is that I don't know how I can install graphics.cma ( I think it's this file that I need but i'm not sure ).
I have research on Google and in This forum but I can't find it..
After little search, I see that i have graphics.cma and graphics.cmxa .
I found this with ls $(ocamlc -where) | egrep cmx?a
I don't know why but yet, my graphics function work at all.
Sorry for inconvenience.
Thanks for helping me guys.
Have a nice day

I would suggest installing and using ocamlfind in order to not have to worry about library location:
ocamlfind ocamlc -package graphics -linkpkg test.ml
will compile your file with the right files loaded.
You can also load the package in the toplevel using
#use "topfind";;
#require "graphics";;

You have already installed the graphics module.
On Debian based systems the ocaml package is split into ocaml-base-nox and ocaml-base. The later contains the graphics module while the former is trimmed down.
The ocaml package is a meta package that depends on both of those and the description says (at the end):
This package contains everything needed to develop OCaml applications,
including the graphics libraries.
So you are all set to play with graphics. Juliens answere of installing ocamlfind is a good idea though as it makes using graphics and other modules easier.

Related

Haskell Platform Installation

I tried to install Haskell Platform from the official website and they asked me to configure Chocolatey on my computer and then to run choco install haskell-dev refreshenv, so I did it and installed:
ghc v8.10.1
chocolatey-core.extension v1.3.5.1
haskell-dev v0.0.1
msys2 v20190524.0.0.20191030
cabal v3.2.0.0
and now i have no idea how to get started with the Haskell and whether I've installed everything I needed, could somebody help me?
This looks like pretty much everything you need. It looks like you’re struggling a bit to understand what everything is for, so I’ll explain the purpose of each component:
ghc is the Glasgow Haskell Compiler a.k.a. GHC, which compiles your code to an executable. Also included in this package is ghci, the GHC interpreter a.k.a. GHCi, which you can use to interactively enter and execute code.
haskell-dev appears to be an auxiliary package to get msys2 properly set up.
msys2 is MSYS2, which provides an environment allowing access to Unix-like tools. You won’t need it for simple stuff, but it can be invaluable when trying to build some Haskell packages.
cabal is the Haskell package manager. (Well, one Haskell package manager: the alternative is Stack, which is compatible with Cabal.) You’ll be using this to develop, build and install Haskell packages.
As for ‘how to get started with Haskell’, this isn’t really the place to ask (maybe try Reddit /r/haskell), but off the top of my head I can think of http://learnyouahaskell.com/ and https://haskellbook.com/ as well-known resources for learning the basics. If you already know the basics and want to start learning more advanced features, try What I Wish I Knew When Learning Haskell.

How to make library installed from OPAM available to OCaml?

I followed this tutorial on OCaml FFI and installed Ctypes through OPAM:
opam install ctypes
However, OCaml does not find the module:
open Ctypes
(* ... *)
I receive the error:
Unbound module Ctypes
It looks like I need to let OCaml know where my Ctypes installation is? Do I need to update some path variable to let OCaml look for my libraries installed through OPAM?
This is Ubuntu 15.04, OCaml 4.01.0, OPAM 1.2.0.
Installing something on your system doesn't make it automatically visible for the compiler, this is true not only for OCaml, but for most conventional systems, like C or C++ to name a few.
That means that you need to pass some flags to the compiler, or to write Makefiles, or to use some project management systems.
In OCaml we have quite a mature infrastructure that plays very well with opam in particular. I do not want to go very deeply in explanations, just a fast overview.
ocamlfind tool is used to find libraries on your system. It is somewhat close to pkg-config in idea, but quite different in design. It wraps compiler tools in order to pass options to them.
ocamlbuild is a fancy swiss-knife that is a must have in the arsenal of every OCamler. It is a tool that knows all other tools, and how to glue them together. I would say that it is the preferred way to compile your projects, especially small one.
oasis is close to autotools in the spirit, but not that generic and is written in the premise, that it should be very easy to use. And indeed it is very easy, but still quite flexible and powerful.
With this overview in mind, we can go directly to your problem. So you've installed ctypes. Now let's take a look on how ctypes package is visible in your system from the ocamlfind perspective. The easiest way would be to list all packages, visible to ocamlfind and find ctypes there:
$ ocamlfind list | grep ctypes
ctypes (version: 0.4.1)
ctypes.foreign (version: 0.4.1)
ctypes.stubs (version: 0.4.1)
ctypes.top (version: 0.4.1)
So, it looks like, that under the ctypes umbrella there're 4 libraries. One basic library, and some extra libraries, that provides some functionality, that is not needed by default.
No let's try to use them with ocamlbuild
ocamlbuild -package ctypes yourprogram.native
Or, without ocamlbuild directly with ocamlfind:
ocamlfind ocamlopt -package ctypes yourprogram.ml -o yourprogram.native
As you may see, there is a package option, to which you can pass a name of the package as found by ocamlfind, and it will be automagically made visible to the compiler.

How to upgrade Haskell Platform

I have the Haskell Platform 2012.4 installed on Windows. I would like to try the new extensions in GHC 7.6.2. It looks like the GHC 7.6.2 x86_64 download does not include an installer and is just the binaries. What is the proper way to get the latest version installed and set as the default for building Haskell projects? Thanks.
If you download GHC itself, you just get GHC and a tiny handful of libraries. If you download the Haskell Platform, you get GHC plus a much bigger collection of libraries. However, the Haskell Platform is updated infrequently, so you'll get an older version of GHC.
If you're asking "how do I install the Haskell Platform and then make it work with a newer GHC?", then the answer is "you don't". Haskell libraries have to be compiled for the specific version of GHC you're using.
You basically have two options:
Use the Haskell Platform, together with the version of GHC that it supplies.
Use the latest GHC, and compile whatever libraries you want manually.
On Linux it's not too bad, but Haskell libraries that bind to external C code tend to be fiddly to build on Windows. (Stuff like OpenGL, zlib, etc.) Packages that are 100% vanilla Haskell code are drop-dead easy to compile on any system.
I haven't done this and I'm at work so I can't test it out, but looking at the GHC docs I would think you can use the --with-compiler=path flag to select which version of GHC to use?
See also this question, related to using cabal with multiple versions of ghc installed. I would guess that you probably want to use cabal-dev or something to sandbox this, otherwise your package database may become a mess.
EDIT: As far as a default, I think you can set that in a cabal configuration file. See the comments to the accepted answer in that question I linked.
The other answers here are great, and I wanted to add that the current best way to get the latest version of GHC installed is to look at haskell.org's installation instructions. I bounced between lots of different options before I landed there, and I think it's the best source of truth from what I can tell.
To summarize the current instructions: if you already have chocolately set up, "at an elevated command prompt, run choco install haskell-dev, followed by refreshenv."

Porting VisualStudio (2008) Project to Linux

I'm trying to port a wide Visual Studio (2008) Project to Linux System.
Do somebody know if it exist a way to easly "transform" the .vcproj file into a makefile?
Easiest would be to just learn how to write your own Makefile. It's quite simple.
But other than that you could try http://www.codeproject.com/Articles/28908/Tool-for-Converting-VC-2005-Project-to-Linux-Makef
Maybe this can help you, but you need to handle whit you outputs in the original code
Make-It-so
http://code.google.com/p/make-it-so/
or
sln2mak
http://www.codeproject.com/Articles/28908/Tool-for-Converting-VC-2005-Project-to-Linux-Makef
i hope this can help you
You can use Winemaker, which is part of WINE: something all major distributions already include.
On Fedora, which use yum, you can, as root, run yum install /usr/bin/winemaker to install it. This will probably also work on other yum based operating system, but you may have to provide another path, if winemaker is packaged to install in /usr/bin (which I doubt will be the case).
Once you have converted the project, consider using Autotools instead -- it's, in my experience, by far the simplest build tool available and is very easy to learn and use. Just don't be scared to poor documentation you will often find lying around. The only files you have to edit are configure.ac and Makefile.am files.

How to compile Intel Mac binaries on Linux?

I was reading an article about cross-compiling for OSX on linux, but it was quite hard to understand.
What tools do I need? And what configurations are necessary?
Are there any tools for creating packages too?
First you need odcctools, which contains assembler and linker and such (like binutils but capable of handling the Mach-O object format). Then you need the system libraries from the official SDK. You can download it from Apple, but must agree to some stuff and become a member to do so. And finally good old gcc. Quite easy in theory, but in reallity a horrible mess. The easiest way to go (that I know of) is to use I'm Cross!.
Update: I found a newer and better updated method called xchain. It requires more manual work than I'm Cross! thou.

Resources