From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 376267FF37 for ; Sun, 31 Jul 2016 12:22:22 +0200 (CEST) IronPort-PHdr: 9a23:yHQMox0Kp0JYxBs4smDT+DRfVm0co7zxezQtwd8ZsegTKvad9pjvdHbS+e9qxAeQG96Ks7Qb0KGM7+jJYi8p2d65qncMcZhBBVcuqP49uEgeOvODElDxN/XwbiY3T4xoXV5h+GynYwAOQJ6tL2PbrnD61zMOABK3bVMzfbWtXNGJxJ7rn8mJuLTrKz1SgzS8Zb4gZD6Xli728vcsvI15N6wqwQHIqHYbM85fxGdvOE7B102kvpT4yrc4rH8V465pt5MYEPayQ6NtRrVdCHEiMnspzMztrxjKCwWVtVUGVWBDvhNOBRmN0xD+Wpr0qWOuve17xCCRIeX6RLYySHG97qNvRRrzzi0KYW1quFrLg9B92foI6CmqoAZyltOMbQ== Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=contact@danny-willems.be; spf=Pass smtp.mailfrom=contact@danny-willems.be; spf=None smtp.helo=postmaster@7.mo2.mail-out.ovh.net Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of contact@danny-willems.be) identity=pra; client-ip=188.165.48.182; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="contact@danny-willems.be"; x-sender="contact@danny-willems.be"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of contact@danny-willems.be designates 188.165.48.182 as permitted sender) identity=mailfrom; client-ip=188.165.48.182; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="contact@danny-willems.be"; x-sender="contact@danny-willems.be"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@7.mo2.mail-out.ovh.net) identity=helo; client-ip=188.165.48.182; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="contact@danny-willems.be"; x-sender="postmaster@7.mo2.mail-out.ovh.net"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0CEAgBE0J1Xh7YwpbxdhBsqUqUElgMkhx88EAEBAQEBAQEBEQEBAQoLCQkZL0EQAYFgBAMJgkYEEXYCJgJsCAEBiDEKoCePY49/gQGEMYJwCIdZgjWCWgWTcIVDVYVDiyCHGoVskCc1gWxFEQuBTmyFNYJOAQEB X-IPAS-Result: A0CEAgBE0J1Xh7YwpbxdhBsqUqUElgMkhx88EAEBAQEBAQEBEQEBAQoLCQkZL0EQAYFgBAMJgkYEEXYCJgJsCAEBiDEKoCePY49/gQGEMYJwCIdZgjWCWgWTcIVDVYVDiyCHGoVskCc1gWxFEQuBTmyFNYJOAQEB X-IronPort-AV: E=Sophos;i="5.28,449,1464645600"; d="scan'208";a="228537170" Received: from 7.mo2.mail-out.ovh.net ([188.165.48.182]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Jul 2016 12:22:21 +0200 Received: from player771.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo2.mail-out.ovh.net (Postfix) with ESMTP id 20FC9FF9D12 for ; Sun, 31 Jul 2016 12:22:21 +0200 (CEST) Received: from [192.168.1.40] (LFbn-1-2789-184.w86-252.abo.wanadoo.fr [86.252.217.184]) (Authenticated sender: contact@danny-willems.be) by player771.ha.ovh.net (Postfix) with ESMTPSA id 104ED840072 for ; Sun, 31 Jul 2016 12:22:21 +0200 (CEST) To: caml-list@inria.fr From: Danny Willems Message-ID: Date: Sun, 31 Jul 2016 12:22:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Ovh-Tracer-Id: 15086214329212937503 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 50 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeeltddrjeefgddvjecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecuogetfeejfedqtdegucdlhedtmd Subject: [Caml-list] OCaml-ctypes compilation with library in a different directory Hello, I'm writing a binding OCaml to the C library "minilibx", here a mirror of the library https://github.com/dannywillems/minilibx. The Makefile installs the library file libmlx.a in /usr/local/lib and you have to add the flags -lmlx -lX11 and -lXext to compile. So you have something like that to compile a test file written in C: ``` gcc -I /usr/local/include -L/usr/local/lib test.c -lmlx -lX11 -lXext ``` I wrote a simple binding to mlx_init, mlx_new_window and mlx_loop in minilibx.ml: ``` open Ctypes open Foreign type mlx_ptr = unit ptr type mlx_win = unit ptr let mlx_ptr : mlx_ptr typ = ptr void let mlx_win : mlx_win typ = ptr void let mlx_init = foreign "mlx_init" (void @-> returning mlx_ptr) let mlx_new_window = foreign "mlx_new_window" (mlx_ptr @-> int @-> int @-> string @-> returning mlx_win) let mlx_loop = foreign "mlx_loop" (mlx_ptr @-> returning void) ``` with the corresponding interface in minilibx.mli and compile it with ``` ocamlfind ocamlc -c -package ctypes.foreign -linkpkg minilibx.mli ocamlfind ocamlc -c -package ctypes.foreign -linkpkg minilibx.ml ``` Now I wrote a test file named hello.ml ``` let () = let i = Minilibx.mlx_init () in let w = Minilibx.mlx_new_window i 640 480 "Hello, World" in Minilibx.mlx_loop i ``` and compile it with ``` ocamlfind ocamlc -o hello -ccopt -L/usr/local/lib -cclib -lmlx -cclib -lX11 -cclib -lXext minilibx.cmo -package ctypes.foreign -linkpkg hello.ml ``` and when I execute hello, I have ``` Fatal error: exception Dl.DL_error("/home/dannywillems/.opam/ctypes/lib/stublibs/dllctypes-foreign-base_stubs.so: undefined symbol: mlx_init") ``` So linking seems not working. But I can't find why. If I try to compile in native with ocamlopt (cmo -> cmx), linking is not done at compile time: ``` /usr/bin/ld: cannot find -lmlx collect2: error: ld returned 1 exit status File "caml_startup", line 1: Error: Error during linking ``` Am I using the right option (-ccopt -L/usr/local/lib)? And why ocamlc doesn't output the error linking message? Thank you for you help.