Unable to install ctypes using opam - ocaml

I wish to install ctypes on my Ubuntu 14.04 computer. I am trying to do so using opam but its failing. Here's the response that I get :-
opam install ctypes
The following actions will be performed:
∗ install conf-ncurses 1 [required by ocamlfind]
∗ install ocamlfind 1.6.2 [required by ctypes]
∗ install base-bytes base [required by ctypes]
∗ install ctypes 0.5.1
===== ∗ 4 =====
Do you want to continue ? [Y/n] Y
=-=- Gathering sources =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[ctypes] Archive in cache
[ocamlfind] Archive in cache
=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[ERROR] The compilation of conf-ncurses failed at "pkg-config ncurses".
#=== ERROR while installing conf-ncurses.1 ====================================#
# opam-version 1.2.2
# os linux
# command pkg-config ncurses
# path ~/.opam/4.02.1/build/conf-ncurses.1
# compiler 4.02.1
# exit-code 1
# env-file ~/.opam/4.02.1/build/conf-ncurses.1/conf-ncurses-3089-ccabea.env
# stdout-file ~/.opam/4.02.1/build/conf-ncurses.1/conf-ncurses-3089-ccabea.out
# stderr-file ~/.opam/4.02.1/build/conf-ncurses.1/conf-ncurses-3089-ccabea.err
=-=- Error report -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
The following actions were aborted
∗ install base-bytes base
∗ install ctypes 0.5.1
∗ install ocamlfind 1.6.2
The following actions failed
∗ install conf-ncurses 1
No changes have been performed
=-=- conf-ncurses.1 troobleshooting -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
=> This package relies on external (system) dependencies that may be missing. `opam depext conf-ncurses.1' may help you find the correct installation for your system.
I have already installed the dependencies but still I am unable to install ncurses.
~$ opam depext conf-ncurses.1
# Detecting depexts using flags: x86_64 linux ubuntu
# The following system packages are needed:
# - ncurses-dev
# - pkg-config
# The following new OS packages need to be installed: ncurses-dev
Not running as root, the following command will be run through "sudo":
apt-get install -qq -yy ncurses-dev
[sudo] password for ask:
# OS packages installation successful
I wonder why I am facing these issues, ncurses-dev and pkg-config is already installed on my system.
Update on performing suggestions by Tobias :-
# Detecting depexts using flags: x86_64 linux ubuntu
# The following system packages are needed:
# - m4
# - ncurses-dev
# - pkg-config
# The following new OS packages need to be installed: ncurses-dev
Not running as root, the following command will be run through "sudo":
apt-get install -qq -yy ncurses-dev
# OS packages installation successful
The following actions will be performed:
∗ install conf-pkg-config 1.0 [required by ctypes]
∗ install conf-m4 1 [required by ocamlfind]
∗ install conf-ncurses 1 [required by ocamlfind]
∗ install ocamlfind 1.6.2 [required by ctypes]
∗ install base-bytes base [required by ctypes]
∗ install ctypes 0.5.1
===== ∗ 6 =====
Do you want to continue ? [Y/n] Y
=-=- Gathering sources =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[ctypes] Archive in cache
[ocamlfind] Archive in cache
=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
∗ installed conf-pkg-config.1.0
∗ installed conf-m4.1
[ERROR] The compilation of conf-ncurses failed at "pkg-config ncurses".
#=== ERROR while installing conf-ncurses.1 ====================================#
# opam-version 1.2.2
# os linux
# command pkg-config ncurses
# path ~/.opam/4.03.0/build/conf-ncurses.1
# compiler 4.03.0
# exit-code 1
# env-file ~/.opam/4.03.0/build/conf-ncurses.1/conf-ncurses-10261-9b8556.env
# stdout-file ~/.opam/4.03.0/build/conf-ncurses.1/conf-ncurses-10261-9b8556.out
# stderr-file ~/.opam/4.03.0/build/conf-ncurses.1/conf-ncurses-10261-9b8556.err
=-=- Error report -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
The following actions were aborted
∗ install base-bytes base
∗ install ctypes 0.5.1
∗ install ocamlfind 1.6.2
The following actions failed
∗ install conf-ncurses 1
The following changes have been performed
∗ install conf-m4 1
∗ install conf-pkg-config 1.0
=-=- conf-ncurses.1 troobleshooting -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
=> This package relies on external (system) dependencies that may be missing.
`opam depext conf-ncurses.1' may help you find the correct installation for
your system.
The former state can be restored with:
opam switch import "~/.opam/4.03.0/backup/state-20160410155208.export"
There's still no text in the error files.
Thanks.

When you are dealing with such erros, you can get more detail by looking the whole errors in the error file pointed out by opam, which is here :
cat /home/ask/.opam/4.02.1/build/conf-ncurses.1/conf-ncurses-3089-ccabea.err
Please note that you also have classical output here :
cat /home/ask/.opam/4.02.1/build/conf-ncurses.1/conf-ncurses-3089-ccabea.out
You may have additional informations that will allow you to end your installation. Sometimes some deps are forgotten in the depext command.
PS : I write here because I don't have enough reputation to ask precision in comment

try the following:
$ apt-get install libncurses5-dev
$ pkg-config --print-provides ncurses
to verify that both ncurses and pkg-config are installed and working correctly.
further diagnostics:
$ dpkg-query -L libncurses5-dev | grep pc$
# results for my machine
/usr/lib/x86_64-linux-gnu/pkgconfig/form.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/ncurses++.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/panel.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/ncurses.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/menu.pc
$ pkg-config --variable pc_path pkg-config
# results for my machine
/usr/local/lib/x86_64-linux-gnu/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig
note that libncurses5-dev has installed its ncurses.pc file in a directory that is in pkg-config's default search path.
If that is not true for your system, try setting $PKG_CONFIG_PATH explicitly to point to where libncurses5-dev has installed ncurses.pc. (Also check that the file actually is there!)
This discussion may be helpful too: https://askubuntu.com/questions/210210/pkg-config-path-environment-variable/373217

In my system if I add
export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig/
and then execute
opam install conf-ncurses
it works

Related

conan system_requirements auto install

While installing xorg with conan install .. command,
system requirements are checked in conan receipe using pkg-config tool.
Each missing system package raises an exception, and thus stop the conan install command.
ERROR: xorg/system: Error in package_info() method, line 97
self._fill_cppinfo_from_pkgconfig(name)
while calling '_fill_cppinfo_from_pkgconfig', line 24
if not pkg_config.provides:
ConanException: pkg-config command ['pkg-config', '--print-provides', 'xcb-renderutil', '--print-errors'] failed with error: Command 'pkg-config --print-provides xcb-renderutil --print-errors' returned non-zero exit status 1.
Package xcb-renderutil was not found in the pkg-config search path.
Perhaps you should add the directory containing `xcb-renderutil.pc'
to the PKG_CONFIG_PATH environment variable
No package 'xcb-renderutil' found
I cannot get those system packages to be installed by conan tool, am I missing a command line argument while invoking conan ?
you can ask conan to install binary packages into your system ( sudo apt-get install ... ) by himself. See my example:
sudo conan install /home/username/QtProj/console_test1/QCoreApplication_quit_example/conanfile.txt --build=qt -c tools.system.package_manager:mode=install
To use it your conan version must be installed using sudo. If you get:
sudo: conan: command not found
You should do:
pip uninstall conan
sudo pip install conan
There are usually distribution-specific package manager warnings listing what dependencies need to be installed above this line:
ERROR: xorg/system:...
For example, on Ubuntu 22.04 I got the following after adding opencv/4.5.5 to my conanfile.txt:
...
dpkg-query: no packages found matching libx11-xcb-dev
dpkg-query: no packages found matching libfontenc-dev
dpkg-query: no packages found matching libxaw7-dev
dpkg-query: no packages found matching libxkbfile-dev
dpkg-query: no packages found matching libxmu-dev
dpkg-query: no packages found matching libxmuu-dev
...
ERROR: xorg/system:...
You can resolve this by installing the listed dependencies. In my case this is what solved it:
sudo apt-get install -y xorg openbox xauth libx11-xcb-dev libx11-xcb-dev libfontenc-dev libxaw7-dev libxkbfile-dev libxmu-dev libxmuu-dev libxpm-dev libxres-dev libxss-dev libxt-dev libxtst-dev libxv-dev libxvmc-dev libxxf86vm-dev

Graphics Installation in Opam

I am trying to install graphics using opam install graphics, but I get the following error
message:
$ opam install graphics
The following actions will be performed:
∗ install graphics 5.1.1
↻ recompile ocamlfind 1.9.1 [uses graphics]
↻ recompile base-bytes base [uses ocamlfind]
↻ recompile ounit2 2.2.4 [uses base-bytes]
↻ recompile ANSITerminal 0.8.2 [uses base-bytes]
===== ∗ 1 ↻ 4 =====
Do you want to continue? [Y/n] y
<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><> 🐫
[ANSITerminal.0.8.2] found in cache
[graphics.5.1.1] found in cache
[ocamlfind.1.9.1] found in cache
[ounit2.2.2.4] found in cache
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><> 🐫
[ERROR] The compilation of graphics failed at "/Users/traviszhang/.opam/opam-init/hooks/sandbox.sh build dune
build -p graphics -j 3 #install".
#=== ERROR while compiling graphics.5.1.1 =====================================#
# context 2.0.8 | macos/x86_64 | ocaml-base-compiler.4.11.1 | https://opam.ocaml.org#7e6a6dcc
# path ~/.opam/cs3110-2021sp/.opam-switch/build/graphics.5.1.1
# command ~/.opam/opam-init/hooks/sandbox.sh build dune build -p graphics -j 3 #install
# exit-code 1
# env-file ~/.opam/log/graphics-9364-8b8a2d.env
# output-file ~/.opam/log/graphics-9364-8b8a2d.out
### output ###
# [...]
# In file included from src/unix/subwindow.c:16:
# src/unix/libgraph.h:17:10: fatal error: 'X11/Xlib.h' file not found
# #include <X11/Xlib.h>
# ^~~~~~~~~~~~
# 1 error generated.
# cc src/text.o (exit 1)
# (cd _build/default/src && /usr/bin/cc -O2 -fno-strict-aliasing -fwrapv -D_FILE_OFFSET_BITS=64 -D_REENTRANT -g -I /Users/traviszhang/.opam/cs3110-2021sp/lib/ocaml -o text.o -c text.c)
# In file included from src/unix/text.c:16:
# src/unix/libgraph.h:17:10: fatal error: 'X11/Xlib.h' file not found
# #include <X11/Xlib.h>
# ^~~~~~~~~~~~
# 1 error generated.
<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><> 🐫
┌─ The following actions failed
│ λ build graphics 5.1.1
└─
╶─ No changes have been performed
I have tried the following solutions, but none of them seem to work:
https://github.com/ocaml/graphics/issues/16 (running export LIBRARY_PATH=/opt/X11/lib)
Also adding export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig" to my .zshrc file (this is mentioned in the same thread as 1.
When I run pkg-config --list-all | grep x11 the x11 libraries pop up, but for some reason spam can't seem to find it when trying to install graphics. Any suggestions would be helpful!
Here is my current computer configuration:
macOS BigSur Version 11.2.1
Ocaml Compiler 4.11.1
Update:
This issue has been brought up in the following thread (https://github.com/ocaml/graphics/pull/36#issuecomment-846827032), and will be updated in the new graphics release.
The easiest path to get the graphics package working on macOS is to install and properly setup homebrew, after that you can just do
opam depext --install graphics
and it should install the system dependencies via homebrew (xquartz and xorgproto) and install the OCaml library.

utop installation using opam fails in fedora 25

I have an error installing utop in fedora 25 when I run "opam install utop". The first time I ran the command some packages were installed, but not all. I ran the same command again and got the error message below. Any suggestion?
The following actions will be performed:
- install lambda-term 1.12.0 [required by utop]
- install utop 2.0.2
===== 2 to install =====
Do you want to continue ? [Y/n] y
=-=- Gathering sources =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[lambda-term] Archive in cache
[utop] Archive in cache
=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[ERROR] The compilation of lambda-term failed at "jbuilder build -p lambda-term
-j 4".
#=== ERROR while installing lambda-term.1.12.0 ================================#
# opam-version 1.2.2
# os linux
# command jbuilder build -p lambda-term -j 4
# path /home/se/.opam/4.05.0/build/lambda-term.1.12.0
# compiler 4.05.0
# exit-code 1
# env-file /home/se/.opam/4.05.0/build/lambda-term.1.12.0/lambda-term-1999-58c514.env
# stdout-file /home/se/.opam/4.05.0/build/lambda-term.1.12.0/lambda-term-1999-58c514.out
# stderr-file /home/se/.opam/4.05.0/build/lambda-term.1.12.0/lambda-term-1999-58c514.err
### stderr ###
# Warning 3: deprecated: module Lwt_sequence
# [...]
# File "src/lTerm_widget_callbacks.ml", line 48, characters 2-21:
# Warning 3: deprecated: module Lwt_sequence
# This module is an implementation detail of Lwt. See
# https://github.com/ocsigen/lwt/issues/361
# ocamlc src/lTerm_unix.{cmo,cmt} (exit 2)
# (cd _build/default && /home/se/.opam/4.05.0/bin/ocamlc.opt -w -40 -safe-string -g -bin-annot -I /home/se/.opam/4.05.0/lib/bytes -I /home/se/.opam/4.05.0/lib/camomile -I /home/se/.opam/4.05.0/lib/lwt -I /home/se/.opam/4.05.0/lib/lwt_react -I /home/se/.opam/4.05.0/lib/ocaml -I /home/se/.opam/4.05.0/lib/ocaml/threads -I /home/se/.opam/4.05.0/lib/react -I /home/se/.opam/4.05.0/lib/result -I /home/se/.opam/4.05.0/lib/zed -no-alias-deps -I src -o src/lTerm_unix.cmo -c -impl src/lTerm_unix.ml)
# File "src/lTerm_unix.ml", line 342, characters 32-51:
# Error: This expression has type bytes but an expression was expected of type
# string
=-=- Error report -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
The following actions were aborted
- install utop 2.0.2
The following actions failed
- install lambda-term 1.12.0
No changes have been performed
Problem fixed:
opam update
opam upgrade
and possibly
opam reinstall [whatever-was-not-installed-correctly]

Opam failures on macOS Sierra

I'm having problems very similar to this question.
I have a MacBook Pro on macOS Sierra. I've installed ocaml and opam via brew. (brew install ocaml, brew install opam) This installed ocaml 4.03.0, and it appears to work fine on its own.
I tried to install oasis (opam install oasis), but the installation failed due to a failure in installing ocamlfind:
➜ ~ opam install ocamlfind
The following actions will be performed:
∗ install ocamlfind 1.6.2
=-=- Gathering sources =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 🐫
[ocamlfind] Archive in cache
=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 🐫
[ERROR] The compilation of ocamlfind failed at "./configure -bindir /Users/drautb/.opam/system/bin -sitelib /Users/drautb/.opam/system/lib -mandir /Users/drautb/.opam/system/man -config /Users/drautb/.opam/system/lib/findlib.conf -no-custom -no-topfind".
Processing 1/1: [ocamlfind: rm]
#=== ERROR while installing ocamlfind.1.6.2 ===================================#
# opam-version 1.2.2
# os darwin
# command ./configure -bindir /Users/drautb/.opam/system/bin -sitelib /Users/drautb/.opam/system/lib -mandir /Users/drautb/.opam/system/man -config /Users/drautb/.opam/system/lib/findlib.conf -no-custom -no-topfind
# path /Users/drautb/.opam/system/build/ocamlfind.1.6.2
# compiler system (4.03.0)
# exit-code 1
# env-file /Users/drautb/.opam/system/build/ocamlfind.1.6.2/ocamlfind-41584-6d07ae.env
# stdout-file /Users/drautb/.opam/system/build/ocamlfind.1.6.2/ocamlfind-41584-6d07ae.out
# stderr-file /Users/drautb/.opam/system/build/ocamlfind.1.6.2/ocamlfind-41584-6d07ae.err
### stdout ###
# [...]
# Configuration for str written to site-lib-src/str/META
# Configuration for threads written to site-lib-src/threads/META
# Configuration for unix written to site-lib-src/unix/META
# Configuration for stdlib written to site-lib-src/stdlib/META
# Configuration for bigarray written to site-lib-src/bigarray/META
# Configuration for ocamldoc written to site-lib-src/ocamldoc/META
# Configuration for camlp4 written to site-lib-src/camlp4/META
# Configuration for compiler-libs written to site-lib-src/compiler-libs/META
# Configuration for bytes written to site-lib-src/bytes/META
# Detecting compiler arguments: FAILED (see the file ocargs.log for details)
### stderr ###
# ./configure: line 553: cd: src: No such file or directory
=-=- Error report -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 🐫
The following actions failed
∗ install ocamlfind 1.6.2
No changes have been performed
I thought it might be related to ocaml 4.03.0, so I tried switching to ocaml 4.02.1. (opam switch 4.02.1) This fails also:
➜ ~ opam switch 4.02.1
=-=- Installing compiler 4.02.1 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 🐫
[default.comp] http://caml.inria.fr/pub/distrib/ocaml-4.02/ocaml-4.02.1.tar.gz downloaded
Now compiling OCaml. This may take a while, please bear with us...
[ERROR] Compiler build failed at "./configure -prefix /Users/drautb/.opam/4.02.1 -with-debug-runtime":
# opam-version 1.2.2
# os darwin
# command ./configure -prefix /Users/drautb/.opam/4.02.1 -with-debug-runtime
# path /Users/drautb/.opam/4.02.1/build/ocaml
# exit-code 2
# env-file /Users/drautb/.opam/log/log-42620-d2c37b.env
# stdout-file /Users/drautb/.opam/log/log-42620-d2c37b.out
# stderr-file /Users/drautb/.opam/log/log-42620-d2c37b.err
### stdout ###
# [ERROR!]Cannot guess host type. You must specify one with the -host option.
### stderr ###
# ./configure: line 190: cd: config/auto-aux: No such file or directory
# ./configure: line 222: ../gnu/config.guess: No such file or directory
I've tried reinstalling XCode, I've tried reinstalling ocaml and opam via homebrew with the --build-from-source option, (including rm -rf ~/.opam) and the errors persist.
Has anyone else had issues like this?

camlzip: "This package relies on external (system) dependencies that may be missing."

I'm trying to install camlzip (an OCaml package housed in opam), but when I run opam install camlzip I get this:
The following actions will be performed:
∗ install camlzip 1.05
=-=- Gathering sources =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[camlzip] Archive in cache
=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[ERROR] The compilation of camlzip failed at "make all".
Processing 1/1: [camlzip: ocamlfind remove]
#=== ERROR while installing camlzip.1.05 ======================================#
# opam-version 1.2.2
# os linux
# command make all
# path /home/mttjone/.opam/system/build/camlzip.1.05
# compiler system (4.02.3)
# exit-code 2
# env-file /home/mttjone/.opam/system/build/camlzip.1.05/camlzip-3552-d2d111.env
# stdout-file /home/mttjone/.opam/system/build/camlzip.1.05/camlzip-3552-d2d111.out
# stderr-file /home/mttjone/.opam/system/build/camlzip.1.05/camlzip-3552-d2d111.err
### stdout ###
# ocamlc -g -c -ccopt -g -ccopt -I/usr/local/include zlibstubs.c
### stderr ###
# [...]
# zlibstubs.c:151: warning: comparison between pointer and integer
# zlibstubs.c: In function ‘camlzip_inflateEnd’:
# zlibstubs.c:165: warning: implicit declaration of function ‘inflateEnd’
# zlibstubs.c:165: error: ‘z_stream’ undeclared (first use in this function)
# zlibstubs.c:165: error: expected expression before ‘)’ token
# zlibstubs.c:165: error: invalid operands to binary * (have ‘int *’ and ‘int *’)
# zlibstubs.c:165: error: called object ‘<erroneous-expression>’ is not a function
# zlibstubs.c: In function ‘camlzip_update_crc32’:
# zlibstubs.c:172: warning: implicit declaration of function ‘crc32’
# make: *** [zlibstubs.o] Error 2
=-=- Error report -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
The following actions failed
∗ install camlzip 1.05
No changes have been performed
=-=- camlzip.1.05 troobleshooting -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
=> This package relies on external (system) dependencies that may be missing. `opam depext camlzip.1.05' may help you find the correct installation for your system.
Now I think it's clear the it isn't acctually missing dependencies, but I can the suggested command anyway and it said I wasn't missing any dependencies.
Presumably the problem is with the zlibstubs.c file, but I'm not exactly sure what's happening.
Can anyone hep me out?
TL;DR
opam install depext
opam depext camlzip
Explanations
The opam install depext command will install an opam plugin that is capable of installing external dependencies. It will add a depext command to opam tool.
The opam depext camlzip will install external dependencies, using system package manager. If your package manager is not supported, then the command will fail. In that case you can use
opam list --external --required-by=camlzip
to get all external dependencies of camlzip for all distributions and package management systems known to a package maintainer. From this information you can infer the names of packages for your distribution. Once you succeed, it is also a good idea to contribute this information back to the maintainer.