From: Aziem Chawdhary <aziem@chawdhary.co.uk>
To: Alexey Egorov <electreg@list.ru>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Linking with zlib on ubuntu
Date: Tue, 02 May 2017 21:40:09 +0100 [thread overview]
Message-ID: <87y3uf3sd2.fsf@aziem-ThinkPad-X230> (raw)
In-Reply-To: <1493755180.672071950@f413.i.mail.ru>
When using ocamlbuild, I find it much easier to pass things like linker
flags via tags, rather than passing it via the command line, as
mentioned in the ocamlbuild manual:
https://github.com/ocaml/ocamlbuild/blob/master/manual/manual.adoc#tags-and-the-code-_tags-code-file
As a side-note, for building mixed C/OCaml projects, I highly recommend
looking at OCaml-Ctypes (https://github.com/ocamllabs/ocaml-ctypes): it
has really made interfacing OCaml with C much more pleasant in my
experience.
Hope that helps!
Aziem
Alexey Egorov <electreg@list.ru> writes:
> Thanks, it solves the problem!
>
> Unfortunately, ocamlbuild adds lflags at the beggining of ocamlopt invocation, so a little hacking required to make it work.
>
>
>>Среда, 3 мая 2017, 0:28 +05:00 от Aziem Chawdhary <aziem@chawdhary.co.uk>:
>>
>>
>>I think the linker flag is in the wrong place. So (from the
>>github gist), instead of doing:
>>
>>ocamlopt -cclib -lz main.cmx test.o -o binary
>>
>>do the following:
>>
>>ocamlopt test.o -cclib -lz main.cmx -o binary
>>
>>This passes the linker flags to gcc in the correct order (i.e -lz before
>>test.o). You can see the gcc commands invoked by adding the -verbose option
>>to ocamlopt.
>>
>>
>>Thanks,
>>Aziem
>>
>>
>>Alexey Egorov < electreg@list.ru > writes:
>>
>>> Hello,
>>>
>>> I'm trying to create mixed OCaml + C binary and got strange linker errors: https://gist.github.com/anonymous/cc2b69c9e86ff2213e03f59a1ac5494b
>>> I have zlib1g-dev installed and linking pure C executable with gcc is working.
>>> Also I have no problem compiling this example on Centos 7.
>>>
>>> Any suggestions?
>>> Thanks.
>>
>>
>>--
--
prev parent reply other threads:[~2017-05-02 20:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-02 18:19 Alexey Egorov
2017-05-02 19:28 ` Aziem Chawdhary
2017-05-02 19:59 ` Alexey Egorov
2017-05-02 20:40 ` Aziem Chawdhary [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=87y3uf3sd2.fsf@aziem-ThinkPad-X230 \
--to=aziem@chawdhary.co.uk \
--cc=caml-list@inria.fr \
--cc=electreg@list.ru \
/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;
as well as URLs for NNTP newsgroup(s).