From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 512D7BC37 for ; Tue, 23 Feb 2010 04:11:56 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AikCAE/WgkvRVdKukGdsb2JhbACPKotQCBUBAQEBCQkMBxMDH60WQIRfIohQAQEDBYRmBIMViHc X-IronPort-AV: E=Sophos;i="4.49,523,1262559600"; d="scan'208";a="57633003" Received: from mail-yx0-f174.google.com ([209.85.210.174]) by mail4-smtp-sop.national.inria.fr with ESMTP; 23 Feb 2010 04:11:56 +0100 Received: by yxe4 with SMTP id 4so42648yxe.27 for ; Mon, 22 Feb 2010 19:11:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; bh=/B6RcCC79YOdNN5h058B1wbg3p2jtzdf1t8VyRkYIFc=; b=nkxe9uqFlxACQWWtbZBaK+pl97ifpBvG5E2riX9TpDyIfgBenJHwQJDQokYgl3jTe2 lC5woyNrV1L2rLpXtp39Z/sZRARK3LqjhBxsRMijQDnKLzcbwu7wIWHS4exsDCXOmX6h 8ij/SC86ALafh+8HptCiTPlZw+diD63spFEt8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type:content-transfer-encoding; b=L7MSOghxVO8HDvQ7gso5pIuWjUx22JFVceQMYNzgcp36YdNxNA2tug1+TaAcmEBBJ3 VGmFrySbNFAWVSOKrYamaawFIjZJpeLF8FvmO6MoijDqiEXX4aTsqp6GhJ56tPrZa4/V 1Pm6eMS8A5XrQNFjqSXdor3sNsQr3As+tA1Zk= MIME-Version: 1.0 Sender: jianzhou.zh@gmail.com Received: by 10.101.210.15 with SMTP id m15mr1410045anq.111.1266894715134; Mon, 22 Feb 2010 19:11:55 -0800 (PST) Date: Mon, 22 Feb 2010 22:11:55 -0500 X-Google-Sender-Auth: 5faea90ef4711c87 Message-ID: <9dfe358d1002221911x27e70e1h7c1521b38184e372@mail.gmail.com> Subject: How to call OCaml from C++ From: Jianzhou Zhao To: caml-list@yquem.inria.fr Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; ocaml:01 ocaml:01 extern:01 alloc:01 libasmrun:01 libasmrun:01 alloc:01 zhao:98 upenn:01 functions:01 functions:01 interfaces:01 define:02 caml:02 caml:02 Hi, Does anyone call OCaml code from C++? C can call OCaml with the OCaml foreign interfaces. But when we call OCaml from C++, we need to consider =91extern C' stuff, like what we do when call C from C++, because the bridge functions between C and OCaml are written in C. However, those functions have not been prefixed with 'extern C', and some functions, such as caml_alloc_dummy in libasmrun, have not been exposed in a head file. So it is hard to define a wrapper to let it work in C++. When linking C++ and libasmrun, caml_alloc_dummy cannot be found by the linker. Does anyone happen to know how to solve this problem? Thanks a lot. Jianzhou