From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 89C71BCAF for ; Sun, 17 Jul 2005 03:47:11 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j6H1lApe017572 for ; Sun, 17 Jul 2005 03:47:11 +0200 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id DAA08689 for ; Sun, 17 Jul 2005 03:47:10 +0200 (MET DST) Received: from smtpout.mac.com (smtpout.mac.com [17.250.248.89]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j6H1l9We017567 for ; Sun, 17 Jul 2005 03:47:09 +0200 Received: from mac.com (smtpin01-en2 [10.13.10.146]) by smtpout.mac.com (Xserve/8.12.11/smtpout02/MantshX 4.0) with ESMTP id j6H1l0qm012355; Sat, 16 Jul 2005 18:47:01 -0700 (PDT) Received: from [192.168.0.100] (dsl092-032-215.lax1.dsl.speakeasy.net [66.92.32.215]) (authenticated bits=0) by mac.com (Xserve/smtpin01/MantshX 4.0) with ESMTP id j6H1kwbR001455 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NO); Sat, 16 Jul 2005 18:46:59 -0700 (PDT) In-Reply-To: <7BA340B3-F9B9-4E8E-9936-5F179B637A5C@frotz.com> References: <7BA340B3-F9B9-4E8E-9936-5F179B637A5C@frotz.com> Mime-Version: 1.0 (Apple Message framework v733) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Cc: caml-list Content-Transfer-Encoding: 7bit From: Paul Snively Subject: Re: [Caml-list] Building ocaml-mysql on Mac OS X Date: Sat, 16 Jul 2005 18:46:27 -0700 To: Ranjan Bagchi X-Pgp-Agent: GPGMail 1.1 (Tiger) X-Gpgmail-State: signed X-Mailer: Apple Mail (2.733) X-Miltered: at concorde with ID 42D9B89E.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 42D9B89D.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocaml-mysql:01 hash:01 ocaml-mysql:01 makefile:01 toplevel:01 ocaml:01 foo:01 ocamlfind:01 -package:01 -custom:01 ocaml:01 foo:01 topfind:01 findlib:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi Ranjan, On Jul 16, 2005, at 12:51 PM, Ranjan Bagchi wrote: > Hi -- > > Curious if anyone has had luck buildling ocaml-mysql on OS X ( it > seem to be fine on linux). > Funny you should ask: I just went through this process today, actually. > I had to mess with the Makefile so it would find the mysql > libraries in /opt/local (I use darwin ports), and did the obvious > things, but when I build a toplevel and try to bring in the mysql > stuff I get the following error: > > Ranjan-Bagchis-Computer:~/ocaml/foo ranjan$ ocamlfind mktop -o > topmysql -package mysql -custom > > Ranjan-Bagchis-Computer:~/ocaml/foo ranjan$ ./topmysql > Objective Caml version 3.08.3 > > # #use "topfind";; > - : unit = () > Findlib has been successfully loaded. Additional directives: > #require "package";; to load a package > #list;; to list the available packages > #camlp4o;; to load camlp4 (standard syntax) > #camlp4r;; to load camlp4 (revised syntax) > #predicates "p,q,...";; to set these predicates > Topfind.reset();; to force that packages will be reloaded > #thread;; to enable threads > > - : unit = () > # #require "mysql";; > /opt/local/lib/site-lib/mysql: added to search path > /opt/local/lib/site-lib/mysql/mysql.cma: loaded > The external function `db_connect' is not available > This is because your stub library wasn't linked with the MySQL client library. > Any hints on getting this built successfully? > Absolutely. I'll tell you what I did, and offer a suggestion as to what you'll likely have to do based on where your MySQL installation is. First, I retrieved ocaml-mysql 1.0.3. Unfortunately, the OCamlMakefile it includes is fairly old, so I downloaded the current OCamlMakefile release as of today and replaced ocaml-mysql's with the new one. My MySQL installation is from the .dmg from the MySQL.com site, which puts everything in the traditional place. Unfortunately, ocaml-mysql (and apparently lots of other MySQL client code) expects to be able to include headers of the form "#include ", so I had to "cd /usr/local/mysql/include; sudo ln -s . mysql" in order to have a "mysql/*.h" path. Your milage may vary depending upon your installation. My first attempts to configure failed, and examining the config.log revealed that this was because of missing "compress" and "uncompress" functions, so I edited configure.in's "Checking for MySQL Library" section, the for... loop through the various possible library directories, to read: test -f "$d/libmysqlclient.a" && LDFLAGS="-L$d -lz" That is, I added the "-lz" link to the LDFLAGS to have it link with zlib, and then ran "autoreconf --install". Note that I had installed a recent autoconf/automake/libtool a few months back, on general principles (Apple, for some reason, consistently ships outdated autoconf/automake/libtools). Now configuration worked, but "make" failed with: ocamlmklib \ -o mysql_stubs mysql_stubs.o -lz - lmysqlclient \ /usr/bin/ld: can't locate file for: -lmysqlclient collect2: ld returned 1 exit status make[1]: *** [dllmysql_stubs.so] Error 2 No surprise there; I sure don't see any reference to /usr/local/mysql/ lib anywhere. Examining the generated Makefile revealed that LDFLAGS correctly has the -L/usr/local/mysql/lib, but examination of the OCamlMakefile revealed that the non-Windows DLLSONAME rule lacked a reference to LDFLAGS. I edited the rule to read: $(DLLSONAME): $(OBJ_LINK) $(OCAMLMKLIB) $(INCFLAGS) $(CLIBFLAGS) $ (LDFLAGS) \ -o $(CLIB_BASE) $(OBJ_LINK) $(CLIBS:% =-l%) \ $(OCAMLMKLIB_FLAGS) That is, I added $(LDFLAGS) after $(CLIBFLAGS). This resulted in "make" and "make opt" running to completion. "sudo make install" then put everything where it belongs. Then: >ocaml Objective Caml version 3.08.3 # #use "topfind";; - - : unit = () Findlib has been successfully loaded. Additional directives: #require "package";; to load a package #list;; to list the available packages #camlp4o;; to load camlp4 (standard syntax) #camlp4r;; to load camlp4 (revised syntax) #predicates "p,q,...";; to set these predicates Topfind.reset();; to force that packages will be reloaded #thread;; to enable threads - - : unit = () # #require "mysql";; /usr/local/lib/ocaml/site-lib/mysql: added to search path /usr/local/lib/ocaml/site-lib/mysql/mysql.cma: loaded Success. Now for the additional steps that you'll almost certainly need: In the AC_CHECKING(for MySQL library) section, you'll need to add / opt/local/mysql/lib or whatever the actual path to your MySQL client libraries is. Similarly, in the header section just below that, you'll need to add the path to your MySQL includes. Note that if your layout isn't of the form /mysql/*.h, you'll need to perform a trick similar to the one I did, or edit the mysql_stubs.c file to remove the part of the #include directives. It bothers me a bit that I had to edit the current OCamlMakefile release to make this work, but I just couldn't see any way around it. At least it was just that and a minor fix to the configure.in script in the end. > Thanks, > > Ranjan Bagchi > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs Best regards, Paul Snively -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (Darwin) iEYEARECAAYFAkLZuIwACgkQO3fYpochAqI6qQCgmy8kag4RW5IyTWtiavpOZHCZ 0r0AnRoPgvV3Y9XuLatgD/R3gGUICgv+ =v2+R -----END PGP SIGNATURE-----