From: Paul Snively <psnively@mac.com>
To: Ranjan Bagchi <ranjan.bagchi@frotz.com>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Building ocaml-mysql on Mac OS X
Date: Sat, 16 Jul 2005 18:46:27 -0700 [thread overview]
Message-ID: <D30ABEFF-F34F-44C1-87D0-C71305E58C2B@mac.com> (raw)
In-Reply-To: <7BA340B3-F9B9-4E8E-9936-5F179B637A5C@frotz.com>
-----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 <mysql/mysql.h>", 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 <path>/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 <mysql/...> 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-----
prev parent reply other threads:[~2005-07-17 1:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-16 19:51 Ranjan Bagchi
2005-07-17 1:46 ` Paul Snively [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=D30ABEFF-F34F-44C1-87D0-C71305E58C2B@mac.com \
--to=psnively@mac.com \
--cc=caml-list@inria.fr \
--cc=ranjan.bagchi@frotz.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox