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?
Yes, you must add the
-goption to compilation and linking. You can also useocamldebugto step through the program with this option on. Also the enviroment variable,OCAMLRUNPARAMmust be set tob.You bet! I recall a few times that I’d forgotten the
-goption and the back-trace was just of the standard library.