Article View: fa.caml
Article #139Re: [Caml-list] static C library of wrappers: compilation issues
From: Xavier ALLAMIGEON
Date: Thu, 26 Apr 2012 10:08
Date: Thu, 26 Apr 2012 10:08
34 lines
3655 bytes
3655 bytes
Dear Edwin, Le 26/04/12 10:33, T�r�k Edwin a �crit : >> Here's the way I'm compiling everything. It builds a libhello_world.a static library from ml_code.obj.o and c_code.o. >> ocamlc -c ml_code.mli >> ocamlopt -c ml_code.ml >> ocamlopt -output-obj ml_code.cmx -o ml_code.obj.o >> gcc -c c_code.c -I"`ocamlc -where`" >> ar rcs libhello_world.a ml_code.obj.o c_code.o >> gcc -o test -L. -L"`ocamlc -where`" test.c -lhello_world -lasmrun -lm -ldl > > You need -Wl,--whole-archive -Wl,--no-whole-archive around the link of your .a, like this: > gcc -o test -L. -L"`ocamlc -where`" test.c -Wl,--whole-archive -lhello_world -Wl,--no-whole-archive -lasmrun -lm -ldl Thanks a lot, it works now! > Otherwise the functions from your .a are dropped because nothing else before it needs it (-lasmrun would, but its after your .a). What do you mean exactly? I imagine that test.o needs some functions of the libhello_world.a. But I don't see why libasmrun would need some other functions of libhello_world... What about the following alternative where libasmrun is directly appended to the .a file? cp "`ocamlc -where`"/libasmrun.a libhello_world.a ar rcs libhello_world.a ml_code.obj.o c_code.o gcc -o test -L. -L"`ocamlc -where`" test.c -lhello_world -lm -ldl Best regards. Xavier -- Caml-list mailing list. Subscription management and archives: https://sympa-roc.inria.fr/wws/info/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
Technical Details
Message-ID:
<fa.ioT/YTrmrBD22KvNJHup1lSU0qY@ifi.uio.no>Path:
arc1-ca.pugleaf.net!r9ni100222pbh.0!nntp.google.com!news2.google.com!news.glorb.com!uio.no!nntp.uio.no!.POSTED!not-for-mailReferences:
<fa.XlnNJXrM7cjr64FYE99G2A+nhk4@ifi.uio.no> <fa.x1meoX1izKZMvjRMs57ceIS84Ic@ifi.uio.no>Show Full Headers
Complete Article Headers
X-Google-Thread: ff861,9e13cd36b5c96a87
X-Google-NewGroupId: yes
X-Google-Attributes: gidc0fe4b917e,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII
Received: by 10.68.227.230 with SMTP id sd6mr5585508pbc.8.1335434915577;
Thu, 26 Apr 2012 03:08:35 -0700 (PDT)
Path: arc1-ca.pugleaf.net!r9ni100222pbh.0!nntp.google.com!news2.google.com!news.glorb.com!uio.no!nntp.uio.no!.POSTED!not-for-mail
From: Xavier ALLAMIGEON <xavier.allamigeon@inria.fr>
Newsgroups: fa.caml
Subject: Re: [Caml-list] static C library of wrappers: compilation issues
Date: Thu, 26 Apr 2012 10:08:35 UTC
Organization: Internet mailing list
Lines: 35
Message-ID: <fa.ioT/YTrmrBD22KvNJHup1lSU0qY@ifi.uio.no>
References: <fa.XlnNJXrM7cjr64FYE99G2A+nhk4@ifi.uio.no> <fa.x1meoX1izKZMvjRMs57ceIS84Ic@ifi.uio.no>
NNTP-Posting-Host: mail-jess.uio.no
Mime-Version: 1.0
X-Trace: readme.uio.no 1335434915 11217 129.240.7.9 (26 Apr 2012 10:08:35 GMT)
X-Complaints-To: abuse@uio.no
NNTP-Posting-Date: Thu, 26 Apr 2012 10:08:35 +0000 (UTC)
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:11.0) Gecko/20120327 Thunderbird/11.0.1
To: caml-list@inria.fr
X-IronPort-AV: E=Sophos;i="4.75,485,1330902000";
d="scan'208";a="155726063"
X-Authentication-Warning: walapai.inria.fr: sympa set sender to caml-list-owner@inria.fr using -f
X-IronPort-AV: E=Sophos;i="4.75,485,1330902000";
d="scan'208";a="141687933"
In-Reply-To: <4F990869.5050105@etorok.net>
X-Sequence: 3969
List-Id: <caml-list.inria.fr>
List-Archive: <https://sympa-roc.inria.fr/wws/arc/caml-list>
List-Help: <mailto:sympa@inria.fr?subject=help>
List-Owner: <mailto:caml-list-request@inria.fr>
List-Post: <mailto:caml-list@inria.fr>
List-Subscribe: <mailto:sympa@inria.fr?subject=subscribe%20caml-list>
List-Unsubscribe: <mailto:sympa@inria.fr?subject=unsubscribe%20caml-list>
Original-Date: Thu, 26 Apr 2012 12:08:08 +0200
Original-Message-Id: <4F991E88.5060402@inria.fr>
Original-References: <4F99003B.9070001@inria.fr> <4F990869.5050105@etorok.net>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit