caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Warning 31: files b.cma(Str) and a.cma(Str) both define a module named Str
@ 2015-03-06 10:16 Vu Ngoc San
  2015-03-06 10:44 ` Pierrick Couderc
  0 siblings, 1 reply; 4+ messages in thread
From: Vu Ngoc San @ 2015-03-06 10:16 UTC (permalink / raw)
  To: caml-list

Hello list

I have a basic compilation question:
I want to write two independent libraries, say A an B, and both use a 
third library, eg. Str

When I write a program which uses A and B, I get
File "b.cma(Str)", line 1:
Warning 31: files b.cma(Str) and a.cma(Str) both define a module named Str

How to get rid of this warning ? Am I doing something wrong ?

Thanks
San

----

Here is a minimal example:

(* This is a.ml *)

let version = "A";;
let _ = print_endline (Str.string_before "Loading the A library -- foo" 
22);;

(* This is b.ml *)

let version = "B";;
let _ =  print_endline (Str.string_before ("Loading the " ^ version ^" 
library -- bar") 23);;

# this is Makefile.a

SOURCES = a.ml
LIBS = str
RESULT = a
all: byte-code-library
-include OCamlMakefile

# this is Makefile.b

SOURCES = b.ml
LIBS = str
RESULT = b
all: byte-code-library
-include OCamlMakefile

(* this is test.ml *)

let _ = print_endline (Str.string_before ("Hello " ^ A.version ^ " and " 
^ B.version ^"---")  13);;

# this is Makefile.test

SOURCES = test.ml
LIBS = a b
RESULT = test
all: byte-code
-include OCamlMakefile



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

* Re: [Caml-list] Warning 31: files b.cma(Str) and a.cma(Str) both define a module named Str
  2015-03-06 10:16 [Caml-list] Warning 31: files b.cma(Str) and a.cma(Str) both define a module named Str Vu Ngoc San
@ 2015-03-06 10:44 ` Pierrick Couderc
  2015-03-06 10:53   ` ygrek
  2015-03-06 11:08   ` Vu Ngoc San
  0 siblings, 2 replies; 4+ messages in thread
From: Pierrick Couderc @ 2015-03-06 10:44 UTC (permalink / raw)
  To: Vu Ngoc San; +Cc: Ocaml Mailing List

[-- Attachment #1: Type: text/plain, Size: 2352 bytes --]

Hi,

I'm not an expert at all with OCamlMakefile, but I guess that comes from
the fact the compiler embeds Str in both libraries "a.cma" and "b.cma".
Doing it by hand:

$ ocamlc -a -o a.cma a.ml
$ ocamlc -a -o b.cma b.ml
$ ocamlc -o a.out str.cma a.cma b.cma test.ml

You don't need to give "str" as Lib when generating your libraries, only
when producing your executable :-) If you give str.cma when generating your
libraries:

$ ocamlc -a -o a.cma str.cma a.ml
$ ocamlc -a -o b.cma str.cma b.ml
$ ocamlc -o a.out a.cma b.cma test.ml
  File "b.cma(Str)", line 1:
  Warning 31: files b.cma(Str) and a.cma(Str) both define a module named Str


Pierrick

2015-03-06 11:16 GMT+01:00 Vu Ngoc San <san.vu-ngoc@laposte.net>:

> Hello list
>
> I have a basic compilation question:
> I want to write two independent libraries, say A an B, and both use a
> third library, eg. Str
>
> When I write a program which uses A and B, I get
> File "b.cma(Str)", line 1:
> Warning 31: files b.cma(Str) and a.cma(Str) both define a module named Str
>
> How to get rid of this warning ? Am I doing something wrong ?
>
> Thanks
> San
>
> ----
>
> Here is a minimal example:
>
> (* This is a.ml *)
>
> let version = "A";;
> let _ = print_endline (Str.string_before "Loading the A library -- foo"
> 22);;
>
> (* This is b.ml *)
>
> let version = "B";;
> let _ =  print_endline (Str.string_before ("Loading the " ^ version ^"
> library -- bar") 23);;
>
> # this is Makefile.a
>
> SOURCES = a.ml
> LIBS = str
> RESULT = a
> all: byte-code-library
> -include OCamlMakefile
>
> # this is Makefile.b
>
> SOURCES = b.ml
> LIBS = str
> RESULT = b
> all: byte-code-library
> -include OCamlMakefile
>
> (* this is test.ml *)
>
> let _ = print_endline (Str.string_before ("Hello " ^ A.version ^ " and " ^
> B.version ^"---")  13);;
>
> # this is Makefile.test
>
> SOURCES = test.ml
> LIBS = a b
> RESULT = test
> all: byte-code
> -include OCamlMakefile
>
>
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>



-- 
Pierrick COUDERC

*PhD Student at OCamlPro / ENSTA Paristech Université Paris Saclay*

[-- Attachment #2: Type: text/html, Size: 4085 bytes --]

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

* Re: [Caml-list] Warning 31: files b.cma(Str) and a.cma(Str) both define a module named Str
  2015-03-06 10:44 ` Pierrick Couderc
@ 2015-03-06 10:53   ` ygrek
  2015-03-06 11:08   ` Vu Ngoc San
  1 sibling, 0 replies; 4+ messages in thread
From: ygrek @ 2015-03-06 10:53 UTC (permalink / raw)
  To: caml-list


 See also http://caml.inria.fr/mantis/view.php?id=5461

-- 

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

* Re: [Caml-list] Warning 31: files b.cma(Str) and a.cma(Str) both define a module named Str
  2015-03-06 10:44 ` Pierrick Couderc
  2015-03-06 10:53   ` ygrek
@ 2015-03-06 11:08   ` Vu Ngoc San
  1 sibling, 0 replies; 4+ messages in thread
From: Vu Ngoc San @ 2015-03-06 11:08 UTC (permalink / raw)
  To: Pierrick Couderc; +Cc: Ocaml Mailing List

[-- Attachment #1: Type: text/plain, Size: 2968 bytes --]

Thanks a lot Pierrick, now I have a set of working makefiles:

# this is Makefile.a

SOURCES = a.ml
RESULT = a
all: byte-code-library
-include OCamlMakefile

# this is Makefile.b

SOURCES = b.ml
RESULT = b
all: byte-code-library
-include OCamlMakefile

# this is Makefile.test

SOURCES = test.ml
LIBS = str a b
RESULT = test
all: byte-code
-include OCamlMakefile


Le 06/03/2015 11:44, Pierrick Couderc a écrit :
> Hi,
 >
 > I'm not an expert at all with OCamlMakefile, but I guess that comes 
from the fact the compiler embeds Str in both libraries "a.cma" and 
"b.cma". Doing it by hand:
 >
 > $ ocamlc -a -o a.cma a.ml
 > $ ocamlc -a -o b.cma b.ml
 > $ ocamlc -o a.out str.cma a.cma b.cma test.ml
 >
 > You don't need to give "str" as Lib when generating your libraries, 
only when producing your executable :-) If you give str.cma when 
generating your libraries:
 >
 > $ ocamlc -a -o a.cma str.cma a.ml
 > $ ocamlc -a -o b.cma str.cma b.ml
 > $ ocamlc -o a.out a.cma b.cma test.ml
 >   File "b.cma(Str)", line 1:
 >   Warning 31: files b.cma(Str) and a.cma(Str) both define a module 
named Str
 >
 >
 > Pierrick
 >
 > 2015-03-06 11:16 GMT+01:00 Vu Ngoc San <san.vu-ngoc@laposte.net>:
 >
 >     Hello list
 >
 >     I have a basic compilation question:
 >     I want to write two independent libraries, say A an B, and both 
use a third library, eg. Str
 >
 >     When I write a program which uses A and B, I get
 >     File "b.cma(Str)", line 1:
 >     Warning 31: files b.cma(Str) and a.cma(Str) both define a module 
named Str
 >
 >     How to get rid of this warning ? Am I doing something wrong ?
 >
 >     Thanks
 >     San
 >
 >     ----
 >
 >     Here is a minimal example:
 >
 >     (* This is a.ml *)
 >
 >     let version = "A";;
 >     let _ = print_endline (Str.string_before "Loading the A library 
-- foo" 22);;
 >
 >     (* This is b.ml *)
 >
 >     let version = "B";;
 >     let _ =  print_endline (Str.string_before ("Loading the " ^ 
version ^" library -- bar") 23);;
 >
 >     # this is Makefile.a
 >
 >     SOURCES = a.ml
 >     LIBS = str
 >     RESULT = a
 >     all: byte-code-library
 >     -include OCamlMakefile
 >
 >     # this is Makefile.b
 >
 >     SOURCES = b.ml
 >     LIBS = str
 >     RESULT = b
 >     all: byte-code-library
 >     -include OCamlMakefile
 >
 >     (* this is test.ml *)
 >
 >     let _ = print_endline (Str.string_before ("Hello " ^ A.version ^ 
" and " ^ B.version ^"---")  13);;
 >
 >     # this is Makefile.test
 >
 >     SOURCES = test.ml
 >     LIBS = a b
 >     RESULT = test
 >     all: byte-code
 >     -include OCamlMakefile
 >
 >
 >
 >     --
 >     Caml-list mailing list.  Subscription management and archives:
 >     https://sympa.inria.fr/sympa/arc/caml-list
 >     Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
 >     Bug reports: http://caml.inria.fr/bin/caml-bugs
 >
 >
 >
 >
 > --
 > Pierrick COUDERC
 >
 > PhD Student at OCamlPro / ENSTA Paristech Université Paris Saclay



[-- Attachment #2: Type: text/html, Size: 4926 bytes --]

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

end of thread, other threads:[~2015-03-06 11:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-06 10:16 [Caml-list] Warning 31: files b.cma(Str) and a.cma(Str) both define a module named Str Vu Ngoc San
2015-03-06 10:44 ` Pierrick Couderc
2015-03-06 10:53   ` ygrek
2015-03-06 11:08   ` Vu Ngoc San

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).