I'm trying to get a stacktrace with Printexc.get_backtrace, but I'm getting an error:
(Program not linked with -g, cannot print stack backtrace)
I'm compiling like this:
ocamlfind ocamlc -g -o foo ... $(FOO_OBJS)
FOO_OBJS are compiled with just:
ocamlc -c $OBJ
What's wrong? Should every .cmo be compiled with -g?
If exception occurs in an object compiled without -g will I get a partial stacktrace, or no stacktrace at all?
What's wrong? Should every .cmo be compiled with -g?
Yes, you must add the -g option to compilation and linking. You can also use ocamldebug to step through the program with this option on. Also the enviroment variable, OCAMLRUNPARAM must be set to b.
If exception occurs in an object compiled without -g will I get a partial stacktrace, or no stacktrace at all?
You bet! I recall a few times that I'd forgotten the -g option and the back-trace was just of the standard library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With