* [Caml-list] Exception Typetexp.Error(_, _) when using Toploop
@ 2012-08-10 21:30 Jean-Baptiste Jeannin
2012-08-11 0:14 ` [Caml-list] " Hongbo Zhang
2012-08-11 8:34 ` [Caml-list] " Jérémie Dimino
0 siblings, 2 replies; 5+ messages in thread
From: Jean-Baptiste Jeannin @ 2012-08-10 21:30 UTC (permalink / raw)
To: caml-list
Hi all,
I am getting a strange dynamic type error Typetexp.Error(_, _) when
trying to compile files using Toploop. It is strange to me because the
error appears or not depending on which directory I compile from (while
adapting all the paths, of course). I narrowed it down to two small
files but am now stuck. My understanding (from comments in
http://caml.inria.fr/svn/ocaml/branches/gadts/typing/typetexp.ml) is
that it is a type error that is happening when trying to dynamically
interpret (using Toploop) a dynamically generated piece of code, located
in a string.
Here is how to reproduce the error. In a directory, create a
subdirectory subdir, and in this subdirectory create a file tree.ml
containing the code:
type tree = Leaf | Node of tree * tree;;
in the main directory, create a file prog.ml containing the code:
let s = "let t = Tree.Leaf;;" in
let lexed = Lexing.from_string s in
let parsed = (!Toploop.parse_toplevel_phrase) lexed in
Toploop.execute_phrase true Format.err_formatter parsed;;
If trying to compile them inside subdir, it works fine:
$ cd subdir
$ ocamlc -o prog.exe -I .. toplevellib.cma tree.ml ../prog.ml
$ ./prog.exe
val t : Tree.tree = Tree.Leaf
However, if trying to compile them from the top directory (which is what
I would like to do), it does not work and raises a Typetexp.Error(_, _)
exception at runtime:
$ cd ..
$ ocamlc -o prog.exe -I subdir toplevellib.cma subdir/tree.ml prog.ml
$ ./prog.exe
Fatal error: exception Typetexp.Error(_, _)
If putting both files in the same directory and compiling them together
it works too (but I would prefer not to do that):
$ ocamlc -o prog.exe -I subdir toplevellib.cma tree.ml prog.ml
$ ./prog.exe
val t : Tree.tree = Tree.Leaf
I think what happens is that the Tree.Leaf is not recognized because the
module Tree is not in the directory from which we are compiling. Any
idea how to fix this, while keeping the directory structure and
compiling from the top directory, or any better understanding of what is
happening?
Thanks,
Jean-Baptiste Jeannin
Please note: the commands above were executed with OCaml 3.12.0. If you
are using 4.00.0 my understanding (although not tested) is that you
should replace "toplevellib.cma" by "+compiler-libs ocamlcommon.cma
ocamlbytecomp.cma ocamltoplevel.cma" everywhere
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Caml-list] Re: Exception Typetexp.Error(_, _) when using Toploop
2012-08-10 21:30 [Caml-list] Exception Typetexp.Error(_, _) when using Toploop Jean-Baptiste Jeannin
@ 2012-08-11 0:14 ` Hongbo Zhang
2012-08-11 20:03 ` [Caml-list] " Jean-Baptiste Jeannin
2012-08-11 8:34 ` [Caml-list] " Jérémie Dimino
1 sibling, 1 reply; 5+ messages in thread
From: Hongbo Zhang @ 2012-08-11 0:14 UTC (permalink / raw)
To: Jean-Baptiste Jeannin; +Cc: caml-list
On 8/10/12 5:30 PM, Jean-Baptiste Jeannin wrote:
> Hi all,
>
Greetings,
> I am getting a strange dynamic type error Typetexp.Error(_, _) when
> trying to compile files using Toploop. It is strange to me because the
> error appears or not depending on which directory I compile from (while
> adapting all the paths, of course). I narrowed it down to two small
> files but am now stuck. My understanding (from comments in
> http://caml.inria.fr/svn/ocaml/branches/gadts/typing/typetexp.ml) is
> that it is a type error that is happening when trying to dynamically
> interpret (using Toploop) a dynamically generated piece of code, located
> in a string.
>
> Here is how to reproduce the error. In a directory, create a
> subdirectory subdir, and in this subdirectory create a file tree.ml
> containing the code:
>
> type tree = Leaf | Node of tree * tree;;
>
> in the main directory, create a file prog.ml containing the code:
>
> let s = "let t = Tree.Leaf;;" in
> let lexed = Lexing.from_string s in
> let parsed = (!Toploop.parse_toplevel_phrase) lexed in
> Toploop.execute_phrase true Format.err_formatter parsed;;
>
>
> If trying to compile them inside subdir, it works fine:
>
> $ cd subdir
> $ ocamlc -o prog.exe -I .. toplevellib.cma tree.ml ../prog.ml
> $ ./prog.exe
> val t : Tree.tree = Tree.Leaf
>
> However, if trying to compile them from the top directory (which is what
> I would like to do), it does not work and raises a Typetexp.Error(_, _)
> exception at runtime:
>
> $ cd ..
> $ ocamlc -o prog.exe -I subdir toplevellib.cma subdir/tree.ml prog.ml
> $ ./prog.exe
> Fatal error: exception Typetexp.Error(_, _)
>
Are you sure tree.cmo is linked in?
what's the output of
ocamlobjinfo prog.exe?
> If putting both files in the same directory and compiling them together
> it works too (but I would prefer not to do that):
>
> $ ocamlc -o prog.exe -I subdir toplevellib.cma tree.ml prog.ml
> $ ./prog.exe
> val t : Tree.tree = Tree.Leaf
>
>
> I think what happens is that the Tree.Leaf is not recognized because the
> module Tree is not in the directory from which we are compiling. Any
> idea how to fix this, while keeping the directory structure and
> compiling from the top directory, or any better understanding of what is
> happening?
>
> Thanks,
> Jean-Baptiste Jeannin
>
>
>
>
>
>
>
>
>
>
> Please note: the commands above were executed with OCaml 3.12.0. If you
> are using 4.00.0 my understanding (although not tested) is that you
> should replace "toplevellib.cma" by "+compiler-libs ocamlcommon.cma
> ocamlbytecomp.cma ocamltoplevel.cma" everywhere
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Caml-list] RE: Exception Typetexp.Error(_, _) when using Toploop
2012-08-11 0:14 ` [Caml-list] " Hongbo Zhang
@ 2012-08-11 20:03 ` Jean-Baptiste Jeannin
0 siblings, 0 replies; 5+ messages in thread
From: Jean-Baptiste Jeannin @ 2012-08-11 20:03 UTC (permalink / raw)
To: Hongbo Zhang; +Cc: caml-list
Hi and thanks for your answer,
No, I am not sure it is linked in, but I am not sure how to do that so that it would be seen when executing code with the Toploop module. The result of ocamlobjinfo prog.exe is below:
$ ocamlobjinfo prog.exe
File prog.exe
Imported units:
d5245ab9689c384bc4805a797389aa01 Consistbl
7cfacd2fd02ac7225ffce89f520aec95 Parsetree
971a915c5d6e79ba8c5a551e0767f582 Map
6c911d1ef9de041df9a60020ae4d3d60 Bytelibrarian
aaa46201460de222b812caf2f6636244 Lazy
13d9e853d4692b1144b5f8043dfe6278 Sort
9c85fb419d52a8fd876c84784374e0cf List
877340141c0babb58b3aaef2f5b70fc9 Arg
e4c27b9790736236103b35b2de656168 Config
40bf652f22a33a7cfa05ee1dd5e0d7e4 Buffer
b97416ea092f498da88c982dd5a074cd Unused_var
bde00c24a8b6f3afd86d76d6b1caa9a0 Includeclass
4feba1f9f7b0c78a3ebd28097f9d4ec1 Typetexp
cb18a206a56d0beb1da4e575310ca437 Printinstr
93b87822c2c8392ee87cd7d7b8cca1e0 Bytesections
8d886e366bfa1e2c96b5e5598b5021f9 Typeopt
9c86f7320512d6740a75017fd66156a8 Hashtbl
55250c391e05a095d3696890d0d554a2 Printf
c378e83a5777aa7422f4e3995bb07db4 Asttypes
7b178c9cf52b5cb8145441e1a0d309f5 Set
ffbbcaa7baaaa10ac040740d1ddb0bae Typedtree
6dbef22dee80539d72b8039549ffd860 Datarepr
db723a1798b122e08919a2bfed062514 Pervasives
3dee29b414dd26a1cfca3bbdf20e7dfc Char
d0c0e82b272b1076cfb81abc20b4d75c Symtable
4fe60c54d4de0672924c1d4ee2053e46 Sys
42ba23382847e6bc05e770c167b161ed Switch
9cf8941f15489d84ebd11297f6b92182 CamlinternalOO
429be3a1c6c989977bb4886528a1da6b Opcodes
ec079f09d44b11983bde76893042f639 Ctype
1f5c6dcac044efdd670289685f208f84 Includemod
07a9578a9db5f1fc9a8647f3515e4e4a Oprint
36a276c72f4c0f1fd7b9282e48e3e3e0 Location
5c8d86fd2a568662cf57868766acfd48 Primitive
515c08ccd93d0ae2e81da1870310d9b6 Types
45011e08b9444a985d5b1470f18d2869 Translcore
e5a3d315d8af2256fb359a8156888143 Dll
fcf85b1e977bb3058109433068246cbb Syntaxerr
161a702f0eec41f7111d55f7d961ccdf Toploop
7221837ac3fed0272717e66472bd201a Matching
201db7374ab9a685695742afff9f0595 Bytegen
843e8cd447d0c6e18da85de5ca09d84f Tree
f7b3acd4ed1c043d87651fb95b4a05f8 Warnings
720848e0b508273805ef38d884a57618 Array
7d5623c54d065ad3f652261d2776959c Lexing
b3f9a487e1ef724150c51728a6a18272 Simplif
fd6aa58f68ced17384fc91c9ea8b7744 Instruct
1f61ca883a41a7ac4e3c78914cf03107 Errors
9aa08b49d0fa9478bc9791d31165d842 Printast
8f09e1331fe8af2d7b954585551cbe4f Int64
ea4ae2aef7de8f271963b77a67b13330 Ident
20349e3fee6fdaa84c3b3bbd701f332e Translmod
c91c0bbb9f7670b10cdc0f2dcc57c5f9 Int32
c91c0bbb9f7670b10cdc0f2dcc57c5f9 Int32
10fab058aa8506c620beeeece873605d Parse
fe6750406385f8a9b379eb6d7735f1bb Mtype
b990a85604f525d852d4c6779c0dc21c Genprintval
b6328b6ed8b2f42cc880b5b7acbefb5a Path
39c97a8d88ae5e762434836dc042ce6a Includecore
4455601f65e095e26712e8447c3c5191 Meta
d2b94e3fde9368ab776c69b9fd51c2ff Cmo_format
409308ec9d1a2ab99fa91fd0dfefca97 Nativeint
6ccad0e9482dcedd96d1d7364013fbac Gc
3aeb33d11433c95bb62053c65665eb76 Obj
e34f7b4a9b277777b6383211fee496d4 Stack
98f0bae75fbbc271fdbcb2229ccf4295 Misc
8d7e6f1b8de0ac75dacb0b99dd5b2f2f Marshal
6acec1252f82413ba88aa91f64a2357b Lambda
bc87b0a21cde095f477cca1f0abb32b8 Filename
7b49b9723731b34908862eb9416c6e28 Subst
88a1c562ed00f3e31a2fb6526ab68fdb Printlambda
78e8b9395429f8963eaa880842fa6eec Bytelink
1c68005fabae3ad5ec9a8439f3c2b2f1 Compile
8214b3f9f1486bc007588793a34b2019 Longident
59e1db94d28f5c920aaddc6ba25fb659 Parsing
2c4d4b8fea3a23125797fc37cc24e4e0 Stypes
a1f7d2e218d08594b71acc96738b957f Bytepackager
06ab5e6944c47322b9d305c0aa0b07ff String
c56fd54d179c83c96fd2e47135607aff Parmatch
84cddf85614815250d98d54ec13705b1 Digest
77a809fb7160e46b69174060eaa4a0b4 Printtyp
8ce6a09d81abf005da172ec4881a4b74 Typedecl
a48642ddc4334c6e92613ef17c92b4be Translobj
74242dde2540bfe8330f30da0a814384 Emitcode
6ae7f7dcc15bfbd64ef12a28c1d5b1ab Prog
082cb289f6f3b40d2eaad236d857e5a0 Btype
3137f16394f7a4a1edd271f84c621c10 Terminfo
d7dea4d1d7c6e4b3c295f210e687cd1f Clflags
96dbcdc761ede265d7f6b2b68cf2776c Annot
329e4d10e6c276322d0a3004ed7f7d6f Typecore
0f3a5c81d427f062ff7d23a4867ef526 Tbl
624d3497eade87b42a0670481b6867c5 Predef
61ed767711858a5f577fdab8913b9405 Lexer
18968f16d79967f14a591d833e09d03e Translclass
8cc335694ed8f32e778ba9c3091944f4 Ccomp
4b3c758f176b77f683031f57fe75bfca Std_exit
227fb38c6dfc5c0f1b050ee46651eebe CamlinternalLazy
166bfa9f1b5f062ae198da640077f5fe Typeclass
e0de312c23ff9caec6c5bfa1f44a43b4 Format
733c5ef1844e9303ca9be3735c187a93 Typemod
72df3429aa2b3fa76f9f92f38d704d70 Runtimedef
455c4cacd33b897fb736e0185e695baf Pparse
f9e53791afaf51c7d247f9487709f695 Weak
0d4fd7f331f808a9e91b4c15b4f18fdf Outcometree
eb46746227016f42f03af00544772d98 Random
8d4da27e7da8174913ee07200b3c51e0 Env
1f660fc858b120b34ebe4e84c8dbb7e3 Parser
7b5bd3a8fe1678a0b517ca35a7ccd832 Linenum
Primitives used:
caml_get_exception_backtrace
caml_backtrace_status
caml_record_backtrace
caml_dynlink_get_current_libs
caml_dynlink_add_primitive
caml_dynlink_lookup_symbol
caml_dynlink_close_lib
caml_dynlink_open_lib
caml_ensure_stack_capacity
caml_final_release
caml_final_register
caml_weak_blit
caml_weak_check
caml_weak_get_copy
caml_weak_get
caml_weak_set
caml_weak_create
caml_register_named_value
caml_terminfo_resume
caml_terminfo_standout
caml_terminfo_backup
caml_terminfo_setup
caml_sys_read_directory
caml_sys_get_config
caml_sys_random_seed
caml_sys_time
caml_sys_system_command
caml_sys_get_argv
caml_sys_getenv
caml_sys_getcwd
caml_sys_chdir
caml_sys_rename
caml_sys_remove
caml_sys_is_directory
caml_sys_file_exists
caml_sys_close
caml_sys_open
caml_sys_exit
caml_bitvect_test
caml_is_printable
caml_fill_string
caml_blit_string
caml_string_greaterequal
caml_string_greaterthan
caml_string_lessequal
caml_string_lessthan
caml_string_compare
caml_string_notequal
caml_string_equal
caml_string_set
caml_string_get
caml_create_string
caml_ml_string_length
caml_install_signal_handler
caml_set_parser_trace
caml_parse_engine
caml_get_public_method
caml_lazy_make_forward
caml_lazy_follow_forward
caml_obj_add_offset
caml_obj_truncate
caml_obj_dup
caml_obj_block
caml_obj_set_tag
caml_obj_tag
caml_obj_is_block
caml_static_resize
caml_static_release_bytecode
caml_static_free
caml_static_alloc
caml_invoke_traced_function
caml_get_current_environment
caml_realloc_global
caml_reify_bytecode
caml_get_section_table
caml_get_global_data
caml_md5_chan
caml_md5_string
caml_new_lex_engine
caml_lex_engine
caml_ml_input_scan_line
caml_ml_pos_in_64
caml_ml_pos_in
caml_ml_seek_in_64
caml_ml_seek_in
caml_ml_input
caml_ml_input_int
caml_ml_input_char
caml_ml_pos_out_64
caml_ml_pos_out
caml_ml_seek_out_64
caml_ml_seek_out
caml_ml_output
caml_ml_output_partial
caml_ml_output_int
caml_ml_output_char
caml_ml_flush
caml_ml_flush_partial
caml_ml_set_binary_mode
caml_ml_channel_size_64
caml_ml_channel_size
caml_ml_close_channel
caml_channel_descriptor
caml_ml_out_channels_list
caml_ml_open_descriptor_out
caml_ml_open_descriptor_in
caml_nativeint_of_string
caml_nativeint_format
caml_nativeint_compare
caml_nativeint_to_int32
caml_nativeint_of_int32
caml_nativeint_to_float
caml_nativeint_of_float
caml_nativeint_to_int
caml_nativeint_of_int
caml_nativeint_shift_right_unsigned
caml_nativeint_shift_right
caml_nativeint_shift_left
caml_nativeint_xor
caml_nativeint_or
caml_nativeint_and
caml_nativeint_mod
caml_nativeint_div
caml_nativeint_mul
caml_nativeint_sub
caml_nativeint_add
caml_nativeint_neg
caml_int64_float_of_bits
caml_int64_bits_of_float
caml_int64_of_string
caml_int64_format
caml_int64_compare
caml_int64_to_nativeint
caml_int64_of_nativeint
caml_int64_to_int32
caml_int64_of_int32
caml_int64_to_float
caml_int64_of_float
caml_int64_to_int
caml_int64_of_int
caml_int64_shift_right_unsigned
caml_int64_shift_right
caml_int64_shift_left
caml_int64_xor
caml_int64_or
caml_int64_and
caml_int64_mod
caml_int64_div
caml_int64_mul
caml_int64_sub
caml_int64_add
caml_int64_neg
caml_int32_float_of_bits
caml_int32_bits_of_float
caml_int32_of_string
caml_int32_format
caml_int32_compare
caml_int32_to_float
caml_int32_of_float
caml_int32_to_int
caml_int32_of_int
caml_int32_shift_right_unsigned
caml_int32_shift_right
caml_int32_shift_left
caml_int32_xor
caml_int32_or
caml_int32_and
caml_int32_mod
caml_int32_div
caml_int32_mul
caml_int32_sub
caml_int32_add
caml_int32_neg
caml_format_int
caml_int_of_string
caml_int_compare
caml_marshal_data_size
caml_input_value_from_string
caml_input_value
caml_hash_univ_param
caml_gc_compaction
caml_gc_major_slice
caml_gc_full_major
caml_gc_major
caml_gc_minor
caml_gc_set
caml_gc_get
caml_gc_counters
caml_gc_quick_stat
caml_gc_stat
caml_classify_float
caml_float_compare
caml_gt_float
caml_ge_float
caml_lt_float
caml_le_float
caml_neq_float
caml_eq_float
caml_log1p_float
caml_expm1_float
caml_ceil_float
caml_atan2_float
caml_atan_float
caml_acos_float
caml_asin_float
caml_tanh_float
caml_tan_float
caml_cosh_float
caml_cos_float
caml_sinh_float
caml_sin_float
caml_power_float
caml_sqrt_float
caml_modf_float
caml_log10_float
caml_log_float
caml_ldexp_float
caml_frexp_float
caml_fmod_float
caml_floor_float
caml_exp_float
caml_div_float
caml_mul_float
caml_sub_float
caml_add_float
caml_abs_float
caml_neg_float
caml_float_of_int
caml_int_of_float
caml_float_of_string
caml_format_float
caml_output_value_to_buffer
caml_output_value_to_string
caml_output_value
caml_greaterequal
caml_greaterthan
caml_lessequal
caml_lessthan
caml_notequal
caml_equal
caml_compare
caml_make_array
caml_make_vect
caml_array_unsafe_set
caml_array_unsafe_set_float
caml_array_unsafe_set_addr
caml_array_unsafe_get
caml_array_unsafe_get_float
caml_array_set
caml_array_set_float
caml_array_set_addr
caml_array_get
caml_array_get_float
caml_array_get_addr
caml_update_dummy
caml_alloc_dummy_float
caml_alloc_dummy
Thank you!
Jean-Baptiste Jeannin
________________________________________
From: Hongbo Zhang [bobzhang1988@gmail.com]
Sent: Friday, August 10, 2012 8:14 PM
To: Jean-Baptiste Jeannin
Cc: caml-list@inria.fr
Subject: Re: Exception Typetexp.Error(_, _) when using Toploop
On 8/10/12 5:30 PM, Jean-Baptiste Jeannin wrote:
> Hi all,
>
Greetings,
> I am getting a strange dynamic type error Typetexp.Error(_, _) when
> trying to compile files using Toploop. It is strange to me because the
> error appears or not depending on which directory I compile from (while
> adapting all the paths, of course). I narrowed it down to two small
> files but am now stuck. My understanding (from comments in
> http://caml.inria.fr/svn/ocaml/branches/gadts/typing/typetexp.ml) is
> that it is a type error that is happening when trying to dynamically
> interpret (using Toploop) a dynamically generated piece of code, located
> in a string.
>
> Here is how to reproduce the error. In a directory, create a
> subdirectory subdir, and in this subdirectory create a file tree.ml
> containing the code:
>
> type tree = Leaf | Node of tree * tree;;
>
> in the main directory, create a file prog.ml containing the code:
>
> let s = "let t = Tree.Leaf;;" in
> let lexed = Lexing.from_string s in
> let parsed = (!Toploop.parse_toplevel_phrase) lexed in
> Toploop.execute_phrase true Format.err_formatter parsed;;
>
>
> If trying to compile them inside subdir, it works fine:
>
> $ cd subdir
> $ ocamlc -o prog.exe -I .. toplevellib.cma tree.ml ../prog.ml
> $ ./prog.exe
> val t : Tree.tree = Tree.Leaf
>
> However, if trying to compile them from the top directory (which is what
> I would like to do), it does not work and raises a Typetexp.Error(_, _)
> exception at runtime:
>
> $ cd ..
> $ ocamlc -o prog.exe -I subdir toplevellib.cma subdir/tree.ml prog.ml
> $ ./prog.exe
> Fatal error: exception Typetexp.Error(_, _)
>
Are you sure tree.cmo is linked in?
what's the output of
ocamlobjinfo prog.exe?
> If putting both files in the same directory and compiling them together
> it works too (but I would prefer not to do that):
>
> $ ocamlc -o prog.exe -I subdir toplevellib.cma tree.ml prog.ml
> $ ./prog.exe
> val t : Tree.tree = Tree.Leaf
>
>
> I think what happens is that the Tree.Leaf is not recognized because the
> module Tree is not in the directory from which we are compiling. Any
> idea how to fix this, while keeping the directory structure and
> compiling from the top directory, or any better understanding of what is
> happening?
>
> Thanks,
> Jean-Baptiste Jeannin
>
>
>
>
>
>
>
>
>
>
> Please note: the commands above were executed with OCaml 3.12.0. If you
> are using 4.00.0 my understanding (although not tested) is that you
> should replace "toplevellib.cma" by "+compiler-libs ocamlcommon.cma
> ocamlbytecomp.cma ocamltoplevel.cma" everywhere
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] Exception Typetexp.Error(_, _) when using Toploop
2012-08-10 21:30 [Caml-list] Exception Typetexp.Error(_, _) when using Toploop Jean-Baptiste Jeannin
2012-08-11 0:14 ` [Caml-list] " Hongbo Zhang
@ 2012-08-11 8:34 ` Jérémie Dimino
2012-08-11 20:15 ` Jean-Baptiste Jeannin
1 sibling, 1 reply; 5+ messages in thread
From: Jérémie Dimino @ 2012-08-11 8:34 UTC (permalink / raw)
To: Jean-Baptiste Jeannin; +Cc: caml-list
Le Fri, 10 Aug 2012 17:30:26 -0400,
Jean-Baptiste Jeannin <jeannin@cs.cornell.edu> a écrit :
> $ cd ..
> $ ocamlc -o prog.exe -I subdir toplevellib.cma subdir/tree.ml prog.ml
> $ ./prog.exe
> Fatal error: exception Typetexp.Error(_, _)
It is because it cannot find the interface for the module Tree (which
is contained in the file tree.cmi). If you want to compile code at
runtime using compiler libraries you need all .cmi for all units you
are using in this code.
You can add new search paths using Topdirs.dir_directory, which
correspond to the #directory directive in the toplevel.
Cheers,
--
Jérémie
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [Caml-list] Exception Typetexp.Error(_, _) when using Toploop
2012-08-11 8:34 ` [Caml-list] " Jérémie Dimino
@ 2012-08-11 20:15 ` Jean-Baptiste Jeannin
0 siblings, 0 replies; 5+ messages in thread
From: Jean-Baptiste Jeannin @ 2012-08-11 20:15 UTC (permalink / raw)
To: Jérémie Dimino; +Cc: caml-list
Hi Jeremie and thanks for your answer,
If I understand correctly you suggest two possible fixes:
First possible fix, copy tree.cmi one level up. I don't like this solution too much but it works:
$ ocamlc -o prog.exe -I subdir toplevellib.cma subdir/tree.ml prog.ml
$ ./prog.exe
Fatal error: exception Typetexp.Error(_, _)
$ cp subdir/tree.cmi .
$ ./prog.exe
val t : Tree.tree = Tree.Leaf
Second possible fix, add the line 'Topdirs.dir_directory "subdir";' to prog.ml. This works great, I prefer it and it solves my problem. Thanks a lot!
________________________________________
From: caml-list-request@inria.fr [caml-list-request@inria.fr] On Behalf Of Jérémie Dimino [jeremie@dimino.org]
Sent: Saturday, August 11, 2012 4:34 AM
To: Jean-Baptiste Jeannin
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Exception Typetexp.Error(_, _) when using Toploop
Le Fri, 10 Aug 2012 17:30:26 -0400,
Jean-Baptiste Jeannin <jeannin@cs.cornell.edu> a écrit :
> $ cd ..
> $ ocamlc -o prog.exe -I subdir toplevellib.cma subdir/tree.ml prog.ml
> $ ./prog.exe
> Fatal error: exception Typetexp.Error(_, _)
It is because it cannot find the interface for the module Tree (which
is contained in the file tree.cmi). If you want to compile code at
runtime using compiler libraries you need all .cmi for all units you
are using in this code.
You can add new search paths using Topdirs.dir_directory, which
correspond to the #directory directive in the toplevel.
Cheers,
--
Jérémie
--
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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-08-11 20:15 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-10 21:30 [Caml-list] Exception Typetexp.Error(_, _) when using Toploop Jean-Baptiste Jeannin
2012-08-11 0:14 ` [Caml-list] " Hongbo Zhang
2012-08-11 20:03 ` [Caml-list] " Jean-Baptiste Jeannin
2012-08-11 8:34 ` [Caml-list] " Jérémie Dimino
2012-08-11 20:15 ` Jean-Baptiste Jeannin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox