From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: ** X-Spam-Status: No, score=2.8 required=5.0 tests=DNS_FROM_RFC_POST,SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id DE093BC37 for ; Tue, 9 Jun 2009 13:36:30 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AosBADvmLUpIDtyZkGdsb2JhbACXbj8BAQEBCQkMBxIDpVuBFo5GAQMCBIQGBYca X-IronPort-AV: E=Sophos;i="4.41,331,1241388000"; d="scan'208";a="29152550" Received: from fg-out-1718.google.com ([72.14.220.153]) by mail3-smtp-sop.national.inria.fr with ESMTP; 09 Jun 2009 13:36:30 +0200 Received: by fg-out-1718.google.com with SMTP id e12so1087507fga.20 for ; Tue, 09 Jun 2009 04:36:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:from:date :x-google-sender-auth:message-id:subject:to:content-type :content-transfer-encoding; bh=GvFSBLPqs1q35iXi8pY4C76KLyhVsYc1xhsNlgOJXz0=; b=bJZ8EhYViS2YapOEQKOUy7ULlYdXxMur7TQ++Y2WCDppy9jIPmsZB+ZFC0HQzM3pAy SIGxLDxA5p+PtFj/MUN3SfAAC3Pzm8iS1/pIU19BgagvseCFmFP/MiiTD0OyeHtIYW7I ohGm2f93FmzCVzScJNGEeNThJEl/U4RTnSVOY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:from:date:x-google-sender-auth:message-id :subject:to:content-type:content-transfer-encoding; b=T939yaqtHpJ2v8MJgRlUYIgFOSYgpvchqOas8VI0w3ndp6NEVRaShoWwA9Qwwlw4pd QSO22U4vRfIty5wC0yT50fBnzVvJMMj5f8tEf8BO/V2072JcsvaG5PKDtLH0rlNhq2w0 BR6qVNV5/NGNDH8R1xRDMVBExDhotxB+hmK8M= MIME-Version: 1.0 Sender: tautrimui@gmail.com Received: by 10.86.70.3 with SMTP id s3mr75804fga.12.1244547390037; Tue, 09 Jun 2009 04:36:30 -0700 (PDT) From: Tautrimas Pajarskas Date: Tue, 9 Jun 2009 14:36:10 +0300 X-Google-Sender-Auth: 621f8763810b9a97 Message-ID: <44e1544f0906090436l3eed359dq3740b5129c2cd6ef@mail.gmail.com> Subject: Compiling C++ in OCaml using Swig to native code To: caml-list@yquem.inria.fr Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; ocaml:01 swig:01 ocaml:01 swig:01 bytecode:01 ocamlopt:01 ocamlopt:01 -cclib:01 cmxa:01 allocator:01 cpp:01 cmxa:01 makefile:01 byte:01 variants:01 Hello, I'm trying to access C++ code from OCaml using Swig. I successfully compiled C++ code as a shared library through swig's C++ wrapper but only in bytecode. Now, if I try the procedures listed in http://www.linux-nantes.org/~fmonnier/OCaml/ocaml-wrapping-c.php#ref_cplusplus for ocamlopt, I get an error: ocamlopt -I . -cclib -lstdc++ md5wrapper.x.cmxa caller.ml -o caller.native ./libmd5wrapper.x.a(md5wrapper_wrap.o): In function `_wrap_new_md5wrappermd5wrapper': md5wrapper_wrap.cxx:(.text+0x147a): undefined reference to `md5wrapper::md5wrapper()' ./libmd5wrapper.x.a(md5wrapper_wrap.o): In function `_wrap_delete_md5wrappermd5wrapper': md5wrapper_wrap.cxx:(.text+0x2d20): undefined reference to `md5wrapper::~md5wrapper()' ./libmd5wrapper.x.a(md5wrapper_wrap.o): In function `_wrap_md5wrapper_getHashFromStringmd5wrapper': md5wrapper_wrap.cxx:(.text+0x7742): undefined reference to `md5wrapper::getHashFromString(std::basic_string, std::allocator >)' collect2: ld returned 1 exit status File "caml_startup", line 1, characters 0-1: Error: Error during linking make: *** [caller.native] Error 2 Library consists of two files: md5wrapper.h (main interface), md5.h, and their appropriate cpp files. md5wrapper_wrap.cxx is the swig's generated wrapper and md5wrapper.x.cmxa is the shared library. caller.ml is the script for using Md5wrapper module (library?). Here is the Makefile: http://pastebin.com/f5f55f789 (Keep in mind that caller.byte target compiles perfectly). I've tried all the variants I could think of. If anybody has any experience in Swig, please help (: -- Tautrimas Pajarskas