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 concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 6B33BBB83 for ; Mon, 5 Jun 2006 10:34:18 +0200 (CEST) Received: from parmail03.sgcib.com (parmail03.sgcib.com [207.45.250.36]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id k558YHVZ024279 for ; Mon, 5 Jun 2006 10:34:18 +0200 X-IronPort-AV: i="4.05,208,1146434400"; d="scan'208"; a="15569880:sNHT28159412" X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Subject: RE: [Caml-list] ocamlopt problem Date: Mon, 5 Jun 2006 10:34:09 +0200 Message-ID: <7F070E410B10EE419826BF5206322CC2023B514E@frdef-exmb01.europe.am.socgen> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [Caml-list] ocamlopt problem Thread-Index: AcaGh0M/wTVDBWn0RjW4cIBCvegoxQB8LxuQ From: "EL CHAAR Rabih SGAM/AI/SAM" To: "David Allsopp" , "OCaml List" X-OriginalArrivalTime: 05 Jun 2006 08:34:14.0898 (UTC) FILETIME=[D3E44D20:01C6887A] X-NAI-Spam-Rules: 1 Rules triggered BAYES_00=-2.5 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" X-Miltered: at concorde with ID 4483EC8A.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; ocamlopt:01 toplevel:01 toplevel:01 bytecode:01 ocaml:01 ocaml:01 omitting:01 ocamlodbc:01 ocamlodbc:01 cmxa:01 ocamlopt:01 cmxa:01 mli:01 -cclib:01 -cclib:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 Hello David, The problem that you are facing is the following: Your c code is available through dllocamlodbc.dll which is dynamically load= ed by the toplevel. My understanding is that the capacity to load dynamically functions is only= available througth the toplevel. When generating executable (native or bytecode), you should pass the c code= embedded in a static library. You should have a libocamlodbc_.a built from ocaml_odbc_c.o, say via=20 $ ar -r libocamlodbc_.a ocaml_odbc_c.o Here maybe you should pay attention to some aspects of exporting C function= s to caml via -DCAML_DLL. If this is the case, you should compile another o= caml_odbc_c.o omitting the definition of this symbol (I don't know if the=20 -DODBC2 does this automatically) in order to generate the static library. This static library should be passed to both ocamlodbc.cma and ocamlodbc.cm= xa via $ ocamlopt -a -o ocamlodbc.cmxa ocaml_odbc.ml ocamlodbc.mli ocamlodbc.ml -cclib -lodbc32 -cclib -locamlodbc_ $ ocamlc -a -o ocamlodbc.cma ocaml_odbc.ml ocamlodbc.mli ocamlodbc.ml -dllib -locamlodbc -cclib -locamlodbc_ Afterwards, while building executables, the -cclib directive will be extrac= ted from the library and passed to the c linker. Hope this helps. Sincerely Rabih PS: What I've described above is the general approach. In your specific cas= e, questioning the presence of ocaml_odbc.o, the answer is that it is not i= ncluded in the .cmxa, it contains only specific caml code, and flags to pas= s to the external linkers. When passing a -ccopt ocaml_odbc_c.o to the libr= ary, it will be extracted at linking, supposing the corresponding .o is ava= ilable. -----Message d'origine----- De=A0: caml-list-bounces@yquem.inria.fr [mailto:caml-list-bounces@yquem.inr= ia.fr] De la part de David Allsopp Envoy=E9=A0: vendredi 2 juin 2006 22:58 =C0=A0: OCaml List Objet=A0: [Caml-list] ocamlopt problem I'm trying to build the ocamlodbc package under Windows using Cygwin/MinGW. It's all built and working except that I'm having one problem with the native library. My question, I think, relates to a misunderstanding with ocamlopt so I'm hoping someone can point out my error!=20 I've adapted the INSTALL_mingw.sh script to issue the following commands: $ gcc -mno-cygwin -c -DODBC2 -DWIN32 -I $OCAMLLIB/caml -I /usr/include/w32api ocaml_odbc_c.c $ gcc -mno-cygwin -shared -L $OCAMLLIB -L $OCAMLLIB/../bin -o dllocamlodbc.dll ocaml_odbc_c.o -lodbc32 -locamlrun=20 $ ocamlopt -a -o ocamlodbc.cmxa ocaml_odbc_c.o ocaml_odbc.ml ocamlodbc.mli ocamlodbc.ml -cclib -lodbc32 $ cp ocamlodbc.cmxa ocamlodbc.a ocamlodbc.cmi $OCAMLLIB $ ocamlc -a -o ocamlodbc.cma ocaml_odbc.ml ocamlodbc.mli ocamlodbc.ml -dllib -locamlodbc $ cp ocamlodbc.cmi ocamlodbc.cma $OCAMLLIB $ cp dllocamlodbc.dll $OCAMLLIB/stublibs The top-level library ocamlodbc.cma is working exactly as I'd expect. I then attempt to compile a program that uses the native library (in this case Exemples/monitor.ml) with the command ocamlopt -o monitor.exe ocamlodbc.cmxa monitor.ml but get the response gcc: ocaml_odbc_c.o: No such file or directory Error during linking Despite trying various -ccopt flags, the only way I can make it compile is to copy ocaml_odbc_c.o to the current directory. My understanding is that the ocamlopt statement that built ocamlodbc.cmxa should have included ocaml_odbc_c.o so why is gcc getting a linker problem when referencing the library? Sorry if it's a blindingly obvious mistake... David _______________________________________________ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs Ce message et toutes les pieces jointes (ci-apres le "message") sont confid= entiels et etablis a l'intention exclusive de ses destinataires.=20 Toute utilisation ou diffusion non autorisee est interdite.=20 Tout message electronique est susceptible d'alteration.=20 Societe Generale Asset Management et ses filiales declinent toute responsab= ilite au titre de ce message s'il a ete altere, deforme ou falsifie.=20 =20 Decouvrez l'offre et les services de Societe Generale Asset Management sur = le site www.sgam.fr=20 =20 ********=20 =20 This message and any attachments (the "message") are confidential and inten= ded solely for the addressees.=20 Any unauthorised use or dissemination is prohibited.=20 E-mails are susceptible to alteration.=20 Neither Societe Generale Asset Management nor any of its subsidiaries or af= filiates shall be liable for the message if altered, changed or falsified.=20 =20 Find out more about Societe Generale Asset Management's proposal on www.sga= m=2Ecom