caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* how to use c wrapper files in libraries
@ 2009-07-20 14:28 Aaron Bohannon
  2009-07-20 14:58 ` [Caml-list] " RABIH.ELCHAAR
  2009-07-20 23:40 ` Erik de Castro Lopo
  0 siblings, 2 replies; 6+ messages in thread
From: Aaron Bohannon @ 2009-07-20 14:28 UTC (permalink / raw)
  To: caml-list

Hello,

I am trying to use the wrapper for libsndfile contributed by Erik de
Castro Lopo (http://caml.inria.fr/cgi-bin/hump.en.cgi?contrib=556).
The wrapper code compiles just fine.  And the tests that use the OCaml
library it builds work just fine.  However, I am having a frustrating
compile-time error when I try to compile my program in a different
directory.

The wrapper code is being packaged into an OCaml library using the
following command:

ocamlc -a -o sndfile.cma -custom sndfile_stub.o sndfile.cmo \
  -ccopt -L/usr/local/lib -cclib -lsndfile

Within the same directory, the test program can be successfully compiled with:

ocamlc -o test_sndfile sndfile.cma test_sndfile.ml

Within a different directory, I used:

ocamlc -o mytest -I /path/to/libsndfile-ocaml/files/   sndfile.cma   mytest.ml

And I get:

powerpc-apple-darwin8-gcc-4.0.1: sndfile_stub.o: No such file or directory
Error while building custom runtime system

I have tried setting every path-related option I could find, and
nothing helped.  I tried reading everything I could find about
compiling and using c wrappers for OCaml, but there is a severe lack
of documentation on the topic.  In particular, I could find no example
of a c object file being given as an argument to an "ocamlc -a"
command, so I am not sure what that is supposed to do, which makes it
impossible for me to understand this error message.

I am using OCaml 3.10.1 on OS X 10.4.  Any help would be appreciated.

 - Aaron


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [Caml-list] how to use c wrapper files in libraries
  2009-07-20 14:28 how to use c wrapper files in libraries Aaron Bohannon
@ 2009-07-20 14:58 ` RABIH.ELCHAAR
  2009-07-20 16:21   ` Aaron Bohannon
  2009-07-20 23:40 ` Erik de Castro Lopo
  1 sibling, 1 reply; 6+ messages in thread
From: RABIH.ELCHAAR @ 2009-07-20 14:58 UTC (permalink / raw)
  To: bohannon, caml-list

I am not familiar with this specific library.
In the general approach, you compile your c code, and package it into a library, let's say libA.a

Then while building your sndfile.cma, you should pass the option
ocamlc -a -o sndfile.cma -cclib -lA ...

A caml executable linked with your library will have also libA.a passed in the linking phase.

Using ocamlc -verbose could give you a hint to which files are missing.

Hope this helps,

Rabih

-----Message d'origine-----
De : caml-list-bounces@yquem.inria.fr [mailto:caml-list-bounces@yquem.inria.fr] De la part de Aaron Bohannon
Envoyé : lundi 20 juillet 2009 16:28
À : caml-list@yquem.inria.fr
Objet : [Caml-list] how to use c wrapper files in libraries

Hello,

I am trying to use the wrapper for libsndfile contributed by Erik de
Castro Lopo (http://caml.inria.fr/cgi-bin/hump.en.cgi?contrib=556).
The wrapper code compiles just fine.  And the tests that use the OCaml
library it builds work just fine.  However, I am having a frustrating
compile-time error when I try to compile my program in a different
directory.

The wrapper code is being packaged into an OCaml library using the
following command:

ocamlc -a -o sndfile.cma -custom sndfile_stub.o sndfile.cmo \
  -ccopt -L/usr/local/lib -cclib -lsndfile

Within the same directory, the test program can be successfully compiled with:

ocamlc -o test_sndfile sndfile.cma test_sndfile.ml

Within a different directory, I used:

ocamlc -o mytest -I /path/to/libsndfile-ocaml/files/   sndfile.cma   mytest.ml

And I get:

powerpc-apple-darwin8-gcc-4.0.1: sndfile_stub.o: No such file or directory
Error while building custom runtime system

I have tried setting every path-related option I could find, and
nothing helped.  I tried reading everything I could find about
compiling and using c wrappers for OCaml, but there is a severe lack
of documentation on the topic.  In particular, I could find no example
of a c object file being given as an argument to an "ocamlc -a"
command, so I am not sure what that is supposed to do, which makes it
impossible for me to understand this error message.

I am using OCaml 3.10.1 on OS X 10.4.  Any help would be appreciated.

 - Aaron

_______________________________________________
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
This message and any attachments (the "message") are confidential, intended solely for the addressee(s), and may contain legally privileged information. 
Any unauthorised use or dissemination is prohibited. 
E-mails are susceptible to alteration. 
Neither Societe Generale Asset Management nor any of its subsidiaries or affiliates shall be liable for the message if altered, changed or falsified. 
  
Find out more about Societe Generale Asset Management's proposal on www.sgam.com
  
                                ******** 
  
Ce message et toutes les pieces jointes (ci-apres le "message") sont confidentiels et susceptibles de contenir des informations couvertes par le secret professionnel.
Ce message est etabli a l'intention exclusive de ses destinataires.
Toute utilisation ou diffusion non autorisee est interdite. 
Tout message electronique est susceptible d'alteration. Societe Generale Asset Management et ses filiales declinent toute responsabilite au titre de ce message s'il a ete altere, deforme ou falsifie. 

Decouvrez l'offre et les services de Societe Generale Asset Management sur le site www.sgam.fr


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] how to use c wrapper files in libraries
  2009-07-20 14:58 ` [Caml-list] " RABIH.ELCHAAR
@ 2009-07-20 16:21   ` Aaron Bohannon
  2009-07-21  8:48     ` RABIH.ELCHAAR
  0 siblings, 1 reply; 6+ messages in thread
From: Aaron Bohannon @ 2009-07-20 16:21 UTC (permalink / raw)
  To: RABIH.ELCHAAR; +Cc: caml-list

Thank you.  This does clarify some things.  Everything works like
clockwork after reworking things this way.

Based on the output of "ocamlc -verbose", it seems that if you pass
"file.o" file to "ocamlc -a", it does nothing except remember the name
"file.o" and pass it to gcc when the OCaml library is later used,
which is a pretty useless and confusing behavior---in general, you
will not be in the same directory that contains "file.o" when you use
the OCaml library and I don't know of any gcc options that will make
gcc look in other directories for object files.  It would seem better
for "ocamlc -a" to ignore ".o" files and display an appropriate
warning.

 - Aaron

On Mon, Jul 20, 2009 at 10:58 AM, <RABIH.ELCHAAR@sgam.com> wrote:
> I am not familiar with this specific library.
> In the general approach, you compile your c code, and package it into a library, let's say libA.a
>
> Then while building your sndfile.cma, you should pass the option
> ocamlc -a -o sndfile.cma -cclib -lA ...
>
> A caml executable linked with your library will have also libA.a passed in the linking phase.
>
> Using ocamlc -verbose could give you a hint to which files are missing.
>
> Hope this helps,
>
> Rabih
>
> -----Message d'origine-----
> De : caml-list-bounces@yquem.inria.fr [mailto:caml-list-bounces@yquem.inria.fr] De la part de Aaron Bohannon
> Envoyé : lundi 20 juillet 2009 16:28
> À : caml-list@yquem.inria.fr
> Objet : [Caml-list] how to use c wrapper files in libraries
>
> Hello,
>
> I am trying to use the wrapper for libsndfile contributed by Erik de
> Castro Lopo (http://caml.inria.fr/cgi-bin/hump.en.cgi?contrib=556).
> The wrapper code compiles just fine.  And the tests that use the OCaml
> library it builds work just fine.  However, I am having a frustrating
> compile-time error when I try to compile my program in a different
> directory.
>
> The wrapper code is being packaged into an OCaml library using the
> following command:
>
> ocamlc -a -o sndfile.cma -custom sndfile_stub.o sndfile.cmo \
>  -ccopt -L/usr/local/lib -cclib -lsndfile
>
> Within the same directory, the test program can be successfully compiled with:
>
> ocamlc -o test_sndfile sndfile.cma test_sndfile.ml
>
> Within a different directory, I used:
>
> ocamlc -o mytest -I /path/to/libsndfile-ocaml/files/   sndfile.cma   mytest.ml
>
> And I get:
>
> powerpc-apple-darwin8-gcc-4.0.1: sndfile_stub.o: No such file or directory
> Error while building custom runtime system
>
> I have tried setting every path-related option I could find, and
> nothing helped.  I tried reading everything I could find about
> compiling and using c wrappers for OCaml, but there is a severe lack
> of documentation on the topic.  In particular, I could find no example
> of a c object file being given as an argument to an "ocamlc -a"
> command, so I am not sure what that is supposed to do, which makes it
> impossible for me to understand this error message.
>
> I am using OCaml 3.10.1 on OS X 10.4.  Any help would be appreciated.
>
>  - Aaron
>
> _______________________________________________
> 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
> This message and any attachments (the "message") are confidential, intended solely for the addressee(s), and may contain legally privileged information.
> Any unauthorised use or dissemination is prohibited.
> E-mails are susceptible to alteration.
> Neither Societe Generale Asset Management nor any of its subsidiaries or affiliates shall be liable for the message if altered, changed or falsified.
>
> Find out more about Societe Generale Asset Management's proposal on www.sgam.com
>
>                                ********
>
> Ce message et toutes les pieces jointes (ci-apres le "message") sont confidentiels et susceptibles de contenir des informations couvertes par le secret professionnel.
> Ce message est etabli a l'intention exclusive de ses destinataires.
> Toute utilisation ou diffusion non autorisee est interdite.
> Tout message electronique est susceptible d'alteration. Societe Generale Asset Management et ses filiales declinent toute responsabilite au titre de ce message s'il a ete altere, deforme ou falsifie.
>
> Decouvrez l'offre et les services de Societe Generale Asset Management sur le site www.sgam.fr
>
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] how to use c wrapper files in libraries
  2009-07-20 14:28 how to use c wrapper files in libraries Aaron Bohannon
  2009-07-20 14:58 ` [Caml-list] " RABIH.ELCHAAR
@ 2009-07-20 23:40 ` Erik de Castro Lopo
  1 sibling, 0 replies; 6+ messages in thread
From: Erik de Castro Lopo @ 2009-07-20 23:40 UTC (permalink / raw)
  To: caml-list

Aaron Bohannon wrote:

> I am trying to use the wrapper for libsndfile contributed by Erik de
> Castro Lopo (http://caml.inria.fr/cgi-bin/hump.en.cgi?contrib=556).
> The wrapper code compiles just fine.

Oh wow, I never realised that made it into the Hump.

I did the wrapper as part of an experiement which I never followed
through on.

If you or anyone else is interested in maintaining it, please do
so.

Cheers,
Erik
-- 
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [Caml-list] how to use c wrapper files in libraries
  2009-07-20 16:21   ` Aaron Bohannon
@ 2009-07-21  8:48     ` RABIH.ELCHAAR
  2009-07-21 13:26       ` Aaron Bohannon
  0 siblings, 1 reply; 6+ messages in thread
From: RABIH.ELCHAAR @ 2009-07-21  8:48 UTC (permalink / raw)
  To: bohannon; +Cc: caml-list

I think that if you install your library along with the obj file, let's say to directory install, and if you pass to ocamlc -I install sndfile.cma ... maybe he will find the obj file and pass it to the linker.

I didn't do the experimentation though, maybe it won't work.

Rabih


-----Message d'origine-----
De : caml-list-bounces@yquem.inria.fr [mailto:caml-list-bounces@yquem.inria.fr] De la part de Aaron Bohannon
Envoyé : lundi 20 juillet 2009 18:22
À : EL CHAAR Rabih SGAM/AI/SAM
Cc : caml-list@yquem.inria.fr
Objet : Re: [Caml-list] how to use c wrapper files in libraries

Thank you.  This does clarify some things.  Everything works like
clockwork after reworking things this way.

Based on the output of "ocamlc -verbose", it seems that if you pass
"file.o" file to "ocamlc -a", it does nothing except remember the name
"file.o" and pass it to gcc when the OCaml library is later used,
which is a pretty useless and confusing behavior---in general, you
will not be in the same directory that contains "file.o" when you use
the OCaml library and I don't know of any gcc options that will make
gcc look in other directories for object files.  It would seem better
for "ocamlc -a" to ignore ".o" files and display an appropriate
warning.

 - Aaron

On Mon, Jul 20, 2009 at 10:58 AM, <RABIH.ELCHAAR@sgam.com> wrote:
> I am not familiar with this specific library.
> In the general approach, you compile your c code, and package it into a library, let's say libA.a
>
> Then while building your sndfile.cma, you should pass the option
> ocamlc -a -o sndfile.cma -cclib -lA ...
>
> A caml executable linked with your library will have also libA.a passed in the linking phase.
>
> Using ocamlc -verbose could give you a hint to which files are missing.
>
> Hope this helps,
>
> Rabih
>
> -----Message d'origine-----
> De : caml-list-bounces@yquem.inria.fr [mailto:caml-list-bounces@yquem.inria.fr] De la part de Aaron Bohannon
> Envoyé : lundi 20 juillet 2009 16:28
> À : caml-list@yquem.inria.fr
> Objet : [Caml-list] how to use c wrapper files in libraries
>
> Hello,
>
> I am trying to use the wrapper for libsndfile contributed by Erik de
> Castro Lopo (http://caml.inria.fr/cgi-bin/hump.en.cgi?contrib=556).
> The wrapper code compiles just fine.  And the tests that use the OCaml
> library it builds work just fine.  However, I am having a frustrating
> compile-time error when I try to compile my program in a different
> directory.
>
> The wrapper code is being packaged into an OCaml library using the
> following command:
>
> ocamlc -a -o sndfile.cma -custom sndfile_stub.o sndfile.cmo \
>  -ccopt -L/usr/local/lib -cclib -lsndfile
>
> Within the same directory, the test program can be successfully compiled with:
>
> ocamlc -o test_sndfile sndfile.cma test_sndfile.ml
>
> Within a different directory, I used:
>
> ocamlc -o mytest -I /path/to/libsndfile-ocaml/files/   sndfile.cma   mytest.ml
>
> And I get:
>
> powerpc-apple-darwin8-gcc-4.0.1: sndfile_stub.o: No such file or directory
> Error while building custom runtime system
>
> I have tried setting every path-related option I could find, and
> nothing helped.  I tried reading everything I could find about
> compiling and using c wrappers for OCaml, but there is a severe lack
> of documentation on the topic.  In particular, I could find no example
> of a c object file being given as an argument to an "ocamlc -a"
> command, so I am not sure what that is supposed to do, which makes it
> impossible for me to understand this error message.
>
> I am using OCaml 3.10.1 on OS X 10.4.  Any help would be appreciated.
>
>  - Aaron
>
> _______________________________________________
> 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
> This message and any attachments (the "message") are confidential, intended solely for the addressee(s), and may contain legally privileged information.
> Any unauthorised use or dissemination is prohibited.
> E-mails are susceptible to alteration.
> Neither Societe Generale Asset Management nor any of its subsidiaries or affiliates shall be liable for the message if altered, changed or falsified.
>
> Find out more about Societe Generale Asset Management's proposal on www.sgam.com
>
>                                ********
>
> Ce message et toutes les pieces jointes (ci-apres le "message") sont confidentiels et susceptibles de contenir des informations couvertes par le secret professionnel.
> Ce message est etabli a l'intention exclusive de ses destinataires.
> Toute utilisation ou diffusion non autorisee est interdite.
> Tout message electronique est susceptible d'alteration. Societe Generale Asset Management et ses filiales declinent toute responsabilite au titre de ce message s'il a ete altere, deforme ou falsifie.
>
> Decouvrez l'offre et les services de Societe Generale Asset Management sur le site www.sgam.fr
>
>

_______________________________________________
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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] how to use c wrapper files in libraries
  2009-07-21  8:48     ` RABIH.ELCHAAR
@ 2009-07-21 13:26       ` Aaron Bohannon
  0 siblings, 0 replies; 6+ messages in thread
From: Aaron Bohannon @ 2009-07-21 13:26 UTC (permalink / raw)
  To: RABIH.ELCHAAR; +Cc: caml-list

I thought so too, but it doesn't work.  ocamlc does pass the option
"-I install" to gcc, but gcc only uses "-I" directories to search for
header files, not object files.  gcc uses "-L" directories to search
for library (".a") files, but this also has no effect on where gcc
looks for ".o" files.

 - Aaron

On Tue, Jul 21, 2009 at 4:48 AM, <RABIH.ELCHAAR@sgam.com> wrote:
> I think that if you install your library along with the obj file, let's say to directory install, and if you pass to ocamlc -I install sndfile.cma ... maybe he will find the obj file and pass it to the linker.
>
> I didn't do the experimentation though, maybe it won't work.
>
> Rabih
>
>
> -----Message d'origine-----
> De : caml-list-bounces@yquem.inria.fr [mailto:caml-list-bounces@yquem.inria.fr] De la part de Aaron Bohannon
> Envoyé : lundi 20 juillet 2009 18:22
> À : EL CHAAR Rabih SGAM/AI/SAM
> Cc : caml-list@yquem.inria.fr
> Objet : Re: [Caml-list] how to use c wrapper files in libraries
>
> Thank you.  This does clarify some things.  Everything works like
> clockwork after reworking things this way.
>
> Based on the output of "ocamlc -verbose", it seems that if you pass
> "file.o" file to "ocamlc -a", it does nothing except remember the name
> "file.o" and pass it to gcc when the OCaml library is later used,
> which is a pretty useless and confusing behavior---in general, you
> will not be in the same directory that contains "file.o" when you use
> the OCaml library and I don't know of any gcc options that will make
> gcc look in other directories for object files.  It would seem better
> for "ocamlc -a" to ignore ".o" files and display an appropriate
> warning.
>
>  - Aaron
>
> On Mon, Jul 20, 2009 at 10:58 AM, <RABIH.ELCHAAR@sgam.com> wrote:
>> I am not familiar with this specific library.
>> In the general approach, you compile your c code, and package it into a library, let's say libA.a
>>
>> Then while building your sndfile.cma, you should pass the option
>> ocamlc -a -o sndfile.cma -cclib -lA ...
>>
>> A caml executable linked with your library will have also libA.a passed in the linking phase.
>>
>> Using ocamlc -verbose could give you a hint to which files are missing.
>>
>> Hope this helps,
>>
>> Rabih
>>
>> -----Message d'origine-----
>> De : caml-list-bounces@yquem.inria.fr [mailto:caml-list-bounces@yquem.inria.fr] De la part de Aaron Bohannon
>> Envoyé : lundi 20 juillet 2009 16:28
>> À : caml-list@yquem.inria.fr
>> Objet : [Caml-list] how to use c wrapper files in libraries
>>
>> Hello,
>>
>> I am trying to use the wrapper for libsndfile contributed by Erik de
>> Castro Lopo (http://caml.inria.fr/cgi-bin/hump.en.cgi?contrib=556).
>> The wrapper code compiles just fine.  And the tests that use the OCaml
>> library it builds work just fine.  However, I am having a frustrating
>> compile-time error when I try to compile my program in a different
>> directory.
>>
>> The wrapper code is being packaged into an OCaml library using the
>> following command:
>>
>> ocamlc -a -o sndfile.cma -custom sndfile_stub.o sndfile.cmo \
>>  -ccopt -L/usr/local/lib -cclib -lsndfile
>>
>> Within the same directory, the test program can be successfully compiled with:
>>
>> ocamlc -o test_sndfile sndfile.cma test_sndfile.ml
>>
>> Within a different directory, I used:
>>
>> ocamlc -o mytest -I /path/to/libsndfile-ocaml/files/   sndfile.cma   mytest.ml
>>
>> And I get:
>>
>> powerpc-apple-darwin8-gcc-4.0.1: sndfile_stub.o: No such file or directory
>> Error while building custom runtime system
>>
>> I have tried setting every path-related option I could find, and
>> nothing helped.  I tried reading everything I could find about
>> compiling and using c wrappers for OCaml, but there is a severe lack
>> of documentation on the topic.  In particular, I could find no example
>> of a c object file being given as an argument to an "ocamlc -a"
>> command, so I am not sure what that is supposed to do, which makes it
>> impossible for me to understand this error message.
>>
>> I am using OCaml 3.10.1 on OS X 10.4.  Any help would be appreciated.
>>
>>  - Aaron
>>
>> _______________________________________________
>> 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
>> This message and any attachments (the "message") are confidential, intended solely for the addressee(s), and may contain legally privileged information.
>> Any unauthorised use or dissemination is prohibited.
>> E-mails are susceptible to alteration.
>> Neither Societe Generale Asset Management nor any of its subsidiaries or affiliates shall be liable for the message if altered, changed or falsified.
>>
>> Find out more about Societe Generale Asset Management's proposal on www.sgam.com
>>
>>                                ********
>>
>> Ce message et toutes les pieces jointes (ci-apres le "message") sont confidentiels et susceptibles de contenir des informations couvertes par le secret professionnel.
>> Ce message est etabli a l'intention exclusive de ses destinataires.
>> Toute utilisation ou diffusion non autorisee est interdite.
>> Tout message electronique est susceptible d'alteration. Societe Generale Asset Management et ses filiales declinent toute responsabilite au titre de ce message s'il a ete altere, deforme ou falsifie.
>>
>> Decouvrez l'offre et les services de Societe Generale Asset Management sur le site www.sgam.fr
>>
>>
>
> _______________________________________________
> 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
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-07-21 13:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-20 14:28 how to use c wrapper files in libraries Aaron Bohannon
2009-07-20 14:58 ` [Caml-list] " RABIH.ELCHAAR
2009-07-20 16:21   ` Aaron Bohannon
2009-07-21  8:48     ` RABIH.ELCHAAR
2009-07-21 13:26       ` Aaron Bohannon
2009-07-20 23:40 ` Erik de Castro Lopo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).