From: Dan Benjamin <dbenjamin@janestreet.com>
To: Bruno Deferrari <utizoc@gmail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Static linking via Ctypes?
Date: Tue, 25 Mar 2014 11:11:50 -0400 [thread overview]
Message-ID: <CACKEwpZdHFz+poeBtF2TdL0DPUVh+Ogrfs_91rnhpet_Qp1XKA@mail.gmail.com> (raw)
In-Reply-To: <CACnPB4rWZdOfTr6vrEZapz1GrM_Tqde8jJwt9MXR8LoicK-UUw@mail.gmail.com>
I am passing -force_load, as well as --whole-archive (in case that
makes a difference), and I have the following situation:
- readelf -s shows that the function that I wish to call exists in the
executable
- running the executable results in Dl.DL_error("undefined symbol")
for the same function, corresponding to the line of code where I call
Foreign.foreign.
Am I going about this wrongly?
On Tue, Mar 25, 2014 at 11:04 AM, Bruno Deferrari <utizoc@gmail.com> wrote:
> On Tue, Mar 25, 2014 at 11:54 AM, <dbenjamin@janestreet.com> wrote:
>> I'm using Ctypes to interface with a dynamic library, but in addition to the
>> interface provided the library I have some helper functions (written in C,
>> against the same library) that I'd also like to call via Ctypes. Is there any
>> way to achieve this via static linking or am I required to build another
>> shared object?
>>
>
> Static linking works. I was in this same situation yesterday, and
> adding the .o files that were generated from C sources to the linking
> step did the trick.
>
> If you are trying to link a .a file, you may have to pass the
> -force_load option to the linker to force it to include it, otherwise
> it may see that none of the symbols there are being referenced
> directly and decide to not include it (this happened to me when using
> clang in OSX).
>
>> --
>> Caml-list mailing list. Subscription management and archives:
>> https://sympa.inria.fr/sympa/arc/caml-list
>> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
>> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>
>
> --
> BD
next prev parent reply other threads:[~2014-03-25 15:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-25 14:54 dbenjamin
2014-03-25 15:04 ` Bruno Deferrari
2014-03-25 15:11 ` Dan Benjamin [this message]
2014-03-25 15:24 ` David Sheets
2014-03-25 17:55 ` Dan Benjamin
2014-03-25 21:19 ` Jeremy Yallop
2014-03-25 21:37 ` Milan Stanojević
2014-03-25 23:14 ` Jeremy Yallop
2014-03-26 16:24 ` Travis Brady
2014-03-26 17:17 ` Daniel Bünzli
2014-03-26 17:25 ` Milan Stanojević
2014-03-25 15:10 ` Daniel Bünzli
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=CACKEwpZdHFz+poeBtF2TdL0DPUVh+Ogrfs_91rnhpet_Qp1XKA@mail.gmail.com \
--to=dbenjamin@janestreet.com \
--cc=caml-list@inria.fr \
--cc=utizoc@gmail.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