Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* OCaml: problems compiling
@ 1997-07-18  0:21 Paul A. Steckler
  1997-07-21 16:02 ` Xavier Leroy
  0 siblings, 1 reply; 4+ messages in thread
From: Paul A. Steckler @ 1997-07-18  0:21 UTC (permalink / raw)
  To: caml-list

Frequently when compiling a file foo.ml files with ocamlopt
on a Sun Sparc, I get a message like:

	I/O error: foo.cmi: No such file or directory

Note that it's complaining about the .cmi file for the
file currently being compiled, not some other module.

I can usually workaround this problem by removing any
.cmi and .mli files, running ocamlc -c on foo.ml,
and then rerunning ocamlopt.  This strategy is 
haphazard, though, because I don't know what the
true cause of the problem is.

How can I avoid the error to begin with?

-- Paul





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

* Re: OCaml: problems compiling
  1997-07-18  0:21 OCaml: problems compiling Paul A. Steckler
@ 1997-07-21 16:02 ` Xavier Leroy
  1997-07-22 15:50   ` Joshua D. Guttman
  0 siblings, 1 reply; 4+ messages in thread
From: Xavier Leroy @ 1997-07-21 16:02 UTC (permalink / raw)
  To: steck; +Cc: caml-list

> Frequently when compiling a file foo.ml files with ocamlopt
> on a Sun Sparc, I get a message like:
> 
> 	I/O error: foo.cmi: No such file or directory
> 
> Note that it's complaining about the .cmi file for the
> file currently being compiled, not some other module.
> 
> How can I avoid the error to begin with?

You should compile the foo.mli file before compiling the foo.ml file.
That will produce the missing foo.cmi file.

Alternatively, if you don't have an interface file foo.mli in the same
directory as foo.ml, the compiler will create foo.cmi directly from
foo.ml.

I agree that a better error message is in order.

Regards,

- Xavier Leroy





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

* Re: OCaml: problems compiling
  1997-07-21 16:02 ` Xavier Leroy
@ 1997-07-22 15:50   ` Joshua D. Guttman
  1997-07-22 16:25     ` Pierre Weis
  0 siblings, 1 reply; 4+ messages in thread
From: Joshua D. Guttman @ 1997-07-22 15:50 UTC (permalink / raw)
  To: Xavier Leroy; +Cc: guttman, caml-list

>  > 	I/O error: foo.cmi: No such file or directory
>  > 
>  > Note that it's complaining about the .cmi file for the
>  > file currently being compiled, not some other module.
>  > 
>  > How can I avoid the error to begin with?
>  
>  You should compile the foo.mli file before compiling the foo.ml file.
>  That will produce the missing foo.cmi file.
>  
>  Alternatively, if you don't have an interface file foo.mli in the same
>  directory as foo.ml, the compiler will create foo.cmi directly from
>  foo.ml.
>  

Is there some convenient way to set up a makefile so that it will
ensure that foo.cmi is generated (or re-generated) before foo.cmo or
foo.cmx?  

Not being a magician of `make', I didn't see an easy way to express
the conditional on there existing a foo.mli file.  Of course, in the
ideal case one would actually see whether it was possible to make
foo.mli, e.g. from foo.mly.

Thanks.

	Josh






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

* Re: OCaml: problems compiling
  1997-07-22 15:50   ` Joshua D. Guttman
@ 1997-07-22 16:25     ` Pierre Weis
  0 siblings, 0 replies; 4+ messages in thread
From: Pierre Weis @ 1997-07-22 16:25 UTC (permalink / raw)
  To: guttman; +Cc: Xavier.Leroy, guttman, caml-list, Pierre Weis

> Is there some convenient way to set up a makefile so that it will
> ensure that foo.cmi is generated (or re-generated) before foo.cmo or
> foo.cmx?  
> 
> Not being a magician of `make', I didn't see an easy way to express
> the conditional on there existing a foo.mli file.  Of course, in the
> ideal case one would actually see whether it was possible to make
> foo.mli, e.g. from foo.mly.
> 
> Thanks.
> 
> 	Josh

Well, I'm not a magician of ``make'', but I use the following
(oversimplified) Makefile template for O'Caml. I hope it could be
useful, as a first attempt to automatize your recompilations.

As an example, the template is ready to use, if we suppose that you
want to produce executable file ``exc'', from (Caml lex) lexer source
definition ``lexer.mll'', parser source definition ``parser.mly'', and
O'Caml source files ``types.ml'' and ``main.ml''. It should not be too
difficult to modify it to fit your needs.

If Makefiles are new to you, note that the lines of rule
bodies must start with a tab character (not 8 blank spaces!).

Note also that this Makefile will handle dependancies between O'Caml
files, provided that you create a dummy file ``.depend'' the first
time you use it.

Usage:
-- just type make to recompile what have to be recompiled
-- type make clean, then make to rebuild the application from scratch.

============================================================
# The Caml compilers. You may have to add various -I options.

CAMLC = ocamlc
CAMLDEP = ocamldep
CAMLLEX = ocamllex
CAMLYACC = ocamlyacc

# Lex stuff
LEXSOURCES = lexer.mll
LEXGENERATED = lexer.mli lexer.ml

# Yacc stuff
YACCSOURCES = parser.mly
YACCGENERATED = parser.mli parser.ml

GENERATED = $(LEXGENERATED) $(YACCGENERATED)

# Caml sources
SOURCES = types.ml main.ml $(GENERATED)
# Caml object files to link
OBJS = types.cmo lexer.cmo parser.cmo main.cmo

# Name of executable file to generate
EXEC = exc

# This part should be generic
# Don't forget to create (touch) the file ./.depend at first use.

# Building the world
all: depend $(EXEC)

$(EXEC): $(GENERATED) $(OBJS)
	$(CAMLC) $(OBJS) -o $(EXEC) 

.SUFFIXES:
.SUFFIXES: .ml .mli .cmo .cmi .cmx
.SUFFIXES: .mll .mly

.ml.cmo:
	$(CAMLC) -c $<

.mli.cmi:
	$(CAMLC) -c $<

.mll.ml:
	$(CAMLLEX) $<

.mly.ml:
	$(CAMLYACC) $<

# Clean up
clean:
	rm -f *.cm[io] *.cmx *~ .*~ #*#
	rm -f $(GENERATED)
	rm -f $(EXEC)

# Dependencies
depend: $(SOURCES) $(GENERATED) $(LEXSOURCES) $(YACCSOURCES)
	$(CAMLDEP) *.mli *.ml > .depend

include .depend

=============================================================

Hope this help,

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/







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

end of thread, other threads:[~1997-07-22 16:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-07-18  0:21 OCaml: problems compiling Paul A. Steckler
1997-07-21 16:02 ` Xavier Leroy
1997-07-22 15:50   ` Joshua D. Guttman
1997-07-22 16:25     ` Pierre Weis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox