|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
"ocaml_beginners"::[] How to load a "cma" file in a "ml" Script?Dear Sir/Madam,
I'm a student of Univeristy of Magdeburg in Germany, and doing a Study Thesis. We confronted a problem of Binding a C-Programm into our Ocaml-programmed-System. My C-Programm name: h2o.c , inside with #include <caml/mlvalues.h> #include <caml/memory.h> and the Function "ocaml_value_tid" My Ocaml File name: call_h2o.ml in this File is only: external value_tid:string->int->int->string ="ocaml_value_tid";; as testing I had made call_h2o.cma ,and tested under Ocaml's toplevel with: #load call_h2o.cma;; open Call_h2o;; value_tid Arg1 Arg2 Arg3 ...... It runned correctly. Now I want to bind the call_h2o.cma into a File in our System, which names table.ml. And in this file using the Function: value_tid I have added the following code at the top of the table.ml: #load "call_h2o.cma";; open Call_h2o;; And then by make I have got the following message: li@li-ubuntu:~/ottosvn$ make ocamldep subst_file.ml util.ml keywordsdeutsch.ml convert.ml table.ml maketbt.ml tab2tbt.ml operations.ml rec_zuw.ml crosstable.ml htmlprint.ml path.ml lexer.ml parser.ml runotto.ml subst_file.ml web_files.ml console.ml otto_cgi.ml otto_cgi_file.ml request.ml server.ml file.ml calc.ml calc_direct.ml forward.ml runotto.ml index.ml parser.mli > depend ocamlopt -w y -thread threads.cmxa -I xml-light str.cmxa -c table.ml File "table.ml", line 4, characters 0-1: Syntax error make: *** [table.cmx] Error 2 It says that #load "call_h2o.cma";; is of Syntax not right. But without #load "call_h2o.cma";; , how can call my value_tid Function in "call_h2o.cma"? Here I send also the Makefile from our System: ##******************Makefile our System*************************************** OCAMLC=ocamlc -g OCAMLOPT=ocamlopt OCAMLDEP=ocamldep INCLUDES=-I xml-light # 01.2007 following parameters added # -w y # disable warnings for all unused variables OCAMLFLAGS=-w y -thread threads.cma $(INCLUDES) str.cma OCAMLOPTFLAGS=-w y -thread threads.cmxa $(INCLUDES) str.cmxa DIST = subst.xml Makefile maketbt.ml htmlprint.ml console.ml otto_cgi.ml otto_cgi_file.ml request.ml server.ml util.ml file.ml calc.ml calc_direct.ml forward.ml file_string.ml runotto.ml index.ml timeout.sh terminated.txt testotto.cgi convert.ml DIST2 = otto.gif keywordsdeutsch.ml table.ml operations.ml tab2tbt.ml rec_zuw.ml crosstable.ml lexer.mll parser.mly term.ml path.ml keywords_de.tab functions.ml WEB = index.html web/index.html web/load.html web/otto.js web/output.html web/source.html web/plain.html web/ball.gif web/files.html web/up.gif web/down.gif web/tutorial_de.html web/tableedit.js web/manual_de.html web/otto_web.jpg web/help_de.html web/format_de.html web/extensions_de.html CGI_FILES = web/calc.cgi calc_direct.cgi web/file.cgi forward.cgi web/index.cgi testotto.cgi console.opt.exe timeout.sh terminated.txt OTTO_OBJS=subst_file.cmo util.cmo keywordsdeutsch.cmo convert.cmo table.cmo maketbt.cmo tab2tbt.cmo operations.cmo rec_zuw.cmo crosstable.cmo htmlprint.cmo path.cmo lexer.cmo parser.cmo runotto.cmo OTTOOPT_OBJS=subst_file.cmx util.cmx keywordsdeutsch.cmx convert..cmx table.cmx maketbt.cmx tab2tbt.cmx operations.cmx rec_zuw.cmx crosstable.cmx htmlprint.cmx path.cmx lexer.cmx parser.cmx runotto.cmx OTTO_ML=$(OTTO_OBJS:.cmo=.ml) subst_file.ml web_files.ml console.ml otto_cgi.ml otto_cgi_file.ml request.ml server.ml file.ml calc.ml calc_direct.ml forward.ml runotto.ml index.ml # Zielverzeichnis für die Binaries TODO: auslagern in andere Datei, die nicht im SVN ist DEST= # DEST=examples/ all: $(DEST)server.exe $(DEST)console.exe: $(OTTO_OBJS) console.cmo $(OCAMLC) -o $(DEST)console.exe str.cma -I xml-light xml-light.cma unix.cma nums.cma $(OTTO_OBJS) console.cmo $(DEST)console..opt.exe: console.cmx $(OCAMLOPT) -o $(DEST)console.opt.exe -I xml-light xml-light.cmxa unix.cmxa str.cmxa nums.cmxa $(OTTOOPT_OBJS) console.cmx # bytecode version des ottoql-servers zum debuggen $(DEST)server.b.exe: server.cmo parser.cmo $(OCAMLC) -thread unix.cma threads.cma -o $(DEST)server.b.exe -I xml-light xml-light.cma nums.cma str.cma web_files.cmo $(OTTO_OBJS) request.cmo otto_cgi.cmo otto_cgi_file.cmo server.cmo $(DEST)server.exe: server.cmx $(OCAMLOPT) -thread unix.cmxa threads.cmxa -o $(DEST)server.exe -I xml-light xml-light.cmxa nums.cmxa str.cmxa web_files.cmx $(OTTOOPT_OBJS) request.cmx otto_cgi.cmx otto_cgi_file..cmx server.cmx run: $(DEST)server.exe ./$(DEST)server.exe runb: export OTTO_DEBUG = 1 runb: export OCAMLRUNPARAM=b runb: $(DEST)server.b.exe ./$(DEST)server.b.exe web/calc.cgi: calc.cmx $(OCAMLOPT) -o web/calc.cgi -I xml-light xml-light.cmxa str.cmxa unix.cmxa nums.cmxa $(OTTOOPT_OBJS) request.cmx otto_cgi.cmx calc.cmx calc_direct.cgi: calc_direct.cmx $(OCAMLOPT) -o calc_direct.cgi -I xml-light xml-light.cmxa str.cmxa unix.cmxa nums.cmxa $(OTTOOPT_OBJS) request.cmx otto_cgi.cmx calc_direct.cmx web/file.cgi: file.cmx $(OCAMLOPT) -o web/file.cgi unix.cmxa util.cmx request.cmx otto_cgi_file.cmx file.cmx forward.cgi: forward.cmx $(OCAMLOPT) -o forward.cgi unix.cmxa util.cmx request.cmx otto_cgi_file.cmx forward.cmx web/index.cgi: index.cmx $(OCAMLOPT) -o web/index.cgi unix.cmxa util.cmx request.cmx otto_cgi_file.cmx index.cmx FILE_STRING = ocaml file_string.ml subst_file.ml: subst.xml $(FILE_STRING) subst.xml > subst_file.ml web_files.ml: $(WEB) $(FILE_STRING) $(WEB) > web_files.ml strip: -strip $(DEST)server.exe -strip $(DEST)console.opt.exe -strip web/calc.cgi -strip calc_direct.cgi -strip web/file.cgi -strip forward.cgi pack: -upx $(DEST)server.exe -upx $(DEST)console.opt.exe cgi: $(CGI_FILES) # TODO: umstellen auf SVN (mschnabe) ifdef OTTOWWW www: $(CGI_FILES) $(OTTOWWW) chmod +r $(CGI_FILES) $(WEB) chmod +x $(CGI_FILES) tar cf - $(CGI_FILES) $(WEB) | ( cd $(OTTOWWW); tar xfp - ) else www: echo "please set variable OTTOWWW as target" endif zip: zip -r zipfiles/otto_`date +%Y_%m.%d_%H%M`.zip ${DIST} ${DIST2} $(WEB) # Common rules .SUFFIXES: .ml .mli .cmo .cmi .cmx .mll .mly .ml.cmo: $(OCAMLC) $(OCAMLFLAGS) -c $< #$(OTTO_ML) .mli.cmi: $(OCAMLC) $(OCAMLFLAGS) -c $< .ml.cmx: $(OCAMLOPT) $(OCAMLOPTFLAGS) -c $< .mll.ml: ocamllex $< .mly.ml: ocamlyacc $< # Clean up clean: -rm -f *.cmi -rm -f *.mli -rm -f *.cmo -rm -f *.cmx -rm -f parser.ml -rm -f lexer.ml -rm -f depend -rm -f *.o -rm -f subst_file.ml -rm -f web_files.ml # Dependencies depend: $(OTTO_ML) parser.mli $(OCAMLDEP) $(OTTO_ML) parser.mli > depend -include depend ##*************************Ende*********************************** Could you give me some advice of Binding this call_h2o.cma into our System, so then I can use the Function in the call_h2o.cma for my script table.ml. Thank you very much for giving the advice! Regards,Xuefeng Li [Non-text portions of this message have been removed] ------------------------------------ Archives up to December 31, 2007 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/ The archives of the very official ocaml list (the seniors' one) can be found at http://caml.inria.fr Attachments are banned and you're asked to be polite, avoid flames etc.Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/ocaml_beginners/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/ocaml_beginners/join (Yahoo! ID required) <*> To change settings via email: mailto:ocaml_beginners-digest@... mailto:ocaml_beginners-fullfeatured@... <*> To unsubscribe from this group, send an email to: ocaml_beginners-unsubscribe@... <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/ |
|
|
Re: "ocaml_beginners"::[] How to load a "cma" file in a "ml" Script?-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 You do not load a "cma" file in a "ml" script. A .ml file is the source code. A .cma file is the compiled library. If you write a .ml file that needs a particular library you do not need to do anything special. Just make sure when you compile the .ml file, you compile it with the library. The OCaml toplevel is an interpreter that you can use to load "cma" files. In that case you are loading a library into the interpreter, not into the ml file. So your table.ml should just be: open Call_h2o value_tid "somestring" 0 0 And you can compile with: $ ocamlc call_h2o.cma table.ml The manual has more details on the meaning of the different extensions, Peng On Tuesday 02 September 2008 01:29:16 am Xuefeng Li wrote: > Dear Sir/Madam, > I'm a student of Univeristy of > Magdeburg in Germany, and doing a Study Thesis. > We confronted a problem of Binding a > C-Programm into our Ocaml-programmed-System. > > My C-Programm name: h2o.c , > > inside with #include <caml/mlvalues.h> > #include <caml/memory.h> and the Function > "ocaml_value_tid" > > > My Ocaml File name: call_h2o.ml > in this File is only: external > value_tid:string->int->int->string ="ocaml_value_tid";; > > as testing I had made call_h2o.cma > ,and tested under Ocaml's toplevel with: > #load call_h2o.cma;; > open Call_h2o;; > value_tid Arg1 Arg2 Arg3 > ...... > > It runned correctly. > > Now I want to bind the call_h2o.cma into a File in our System, which > names table.ml. And in this file using the Function: value_tid > > I have added the following code at the > top of the table.ml: > #load "call_h2o.cma";; > open Call_h2o;; > > And then by make I have got the > following message: > > li@li-ubuntu:~/ottosvn$ make > ocamldep subst_file.ml util.ml keywordsdeutsch.ml convert.ml table.ml > maketbt.ml tab2tbt.ml operations.ml rec_zuw.ml crosstable.ml htmlprint.ml > path.ml lexer.ml parser.ml runotto.ml subst_file.ml web_files.ml console.ml > otto_cgi.ml otto_cgi_file.ml request.ml server.ml file.ml calc.ml > calc_direct.ml forward.ml runotto.ml index.ml parser.mli > depend ocamlopt > -w y -thread threads.cmxa -I > xml-light str.cmxa -c table.ml > File "table.ml", line 4, > characters 0-1: > Syntax error > make: *** [table.cmx] Error 2 > > It says that #load "call_h2o.cma";; > is of Syntax not right. > > But without #load "call_h2o.cma";; > , how can call my value_tid Function in "call_h2o.cma"? > > Here I send also the Makefile from our > System: > ##******************Makefile our > System*************************************** > OCAMLC=ocamlc -g > OCAMLOPT=ocamlopt > OCAMLDEP=ocamldep > INCLUDES=-I xml-light > # 01.2007 following parameters added > # -w y # disable warnings for all > unused variables > OCAMLFLAGS=-w y -thread threads.cma > $(INCLUDES) str.cma > OCAMLOPTFLAGS=-w y -thread threads.cmxa > $(INCLUDES) str.cmxa > DIST = subst.xml Makefile maketbt.ml > htmlprint.ml console.ml otto_cgi.ml otto_cgi_file.ml request.ml > server.ml util.ml file.ml calc.ml calc_direct.ml forward.ml file_string.ml > runotto.ml index.ml timeout.sh terminated.txt testotto.cgi convert.ml > DIST2 = otto.gif keywordsdeutsch.ml > table.ml operations.ml tab2tbt.ml rec_zuw.ml crosstable.ml lexer.mll > parser.mly term.ml path.ml keywords_de.tab functions.ml > WEB = index.html web/index.html > web/load.html web/otto.js web/output.html web/source.html > web/plain.html web/ball.gif web/files.html web/up.gif web/down.gif > web/tutorial_de.html web/tableedit.js web/manual_de.html > web/otto_web.jpg web/help_de.html web/format_de.html > web/extensions_de.html > CGI_FILES = web/calc.cgi > calc_direct.cgi web/file.cgi forward.cgi web/index.cgi testotto.cgi > console.opt.exe timeout.sh terminated.txt > OTTO_OBJS=subst_file.cmo util.cmo > keywordsdeutsch.cmo convert.cmo table.cmo maketbt.cmo tab2tbt.cmo > operations.cmo rec_zuw.cmo crosstable.cmo htmlprint.cmo path.cmo > lexer.cmo parser.cmo runotto.cmo > OTTOOPT_OBJS=subst_file.cmx util.cmx > keywordsdeutsch.cmx convert..cmx table.cmx maketbt.cmx tab2tbt.cmx > operations.cmx rec_zuw.cmx crosstable.cmx htmlprint.cmx path.cmx > lexer.cmx parser.cmx runotto.cmx > OTTO_ML=$(OTTO_OBJS:.cmo=.ml) > subst_file.ml web_files.ml console.ml otto_cgi.ml otto_cgi_file.ml > request.ml server.ml file.ml calc.ml calc_direct.ml forward.ml > runotto.ml index.ml > # Zielverzeichnis für die Binaries > TODO: auslagern in andere Datei, die nicht im SVN ist > DEST= > # DEST=examples/ > all: $(DEST)server.exe > $(DEST)console.exe: $(OTTO_OBJS) > console.cmo > $(OCAMLC) -o $(DEST)console.exe > str.cma -I xml-light xml-light.cma unix.cma nums.cma $(OTTO_OBJS) > console.cmo > $(DEST)console..opt.exe: console.cmx > $(OCAMLOPT) -o $(DEST)console.opt.exe > -I xml-light xml-light.cmxa unix.cmxa str.cmxa nums.cmxa > $(OTTOOPT_OBJS) console.cmx > # bytecode version des ottoql-servers > zum debuggen > $(DEST)server.b.exe: server.cmo > parser.cmo > $(OCAMLC) -thread unix.cma > threads.cma -o $(DEST)server.b.exe -I xml-light xml-light.cma > nums.cma str.cma web_files.cmo $(OTTO_OBJS) request.cmo otto_cgi.cmo > otto_cgi_file.cmo server.cmo > $(DEST)server.exe: server.cmx > $(OCAMLOPT) -thread unix.cmxa > threads.cmxa -o $(DEST)server.exe -I xml-light xml-light.cmxa > nums.cmxa str.cmxa web_files.cmx $(OTTOOPT_OBJS) request.cmx > otto_cgi.cmx otto_cgi_file..cmx server.cmx > run: $(DEST)server.exe > ./$(DEST)server.exe > runb: export OTTO_DEBUG = 1 > runb: export OCAMLRUNPARAM=b > runb: $(DEST)server.b.exe > ./$(DEST)server.b.exe > web/calc.cgi: calc.cmx > $(OCAMLOPT) -o web/calc.cgi -I > xml-light xml-light.cmxa str.cmxa unix.cmxa nums.cmxa $(OTTOOPT_OBJS) > request.cmx otto_cgi.cmx calc.cmx > calc_direct.cgi: calc_direct.cmx > $(OCAMLOPT) -o calc_direct.cgi -I > xml-light xml-light.cmxa str.cmxa unix.cmxa nums.cmxa $(OTTOOPT_OBJS) > request.cmx otto_cgi.cmx calc_direct.cmx > web/file.cgi: file.cmx > $(OCAMLOPT) -o web/file.cgi unix.cmxa > util.cmx request.cmx otto_cgi_file.cmx file.cmx > forward.cgi: forward.cmx > $(OCAMLOPT) -o forward.cgi unix.cmxa > util.cmx request.cmx otto_cgi_file.cmx forward.cmx > web/index.cgi: index.cmx > $(OCAMLOPT) -o web/index.cgi unix.cmxa > util.cmx request.cmx otto_cgi_file.cmx index.cmx > FILE_STRING = ocaml file_string.ml > subst_file.ml: subst.xml > $(FILE_STRING) subst.xml > > subst_file.ml > web_files.ml: $(WEB) > $(FILE_STRING) $(WEB) > > web_files.ml > strip: > -strip $(DEST)server.exe > -strip $(DEST)console.opt.exe > -strip web/calc.cgi > -strip calc_direct.cgi > -strip web/file.cgi > -strip forward.cgi > pack: > -upx $(DEST)server.exe > -upx $(DEST)console.opt.exe > cgi: $(CGI_FILES) > # TODO: umstellen auf SVN (mschnabe) > ifdef OTTOWWW > www: $(CGI_FILES) $(OTTOWWW) > chmod +r $(CGI_FILES) $(WEB) > chmod +x $(CGI_FILES) > tar cf - $(CGI_FILES) $(WEB) | ( cd > $(OTTOWWW); tar xfp - ) > else > www: > echo "please set variable OTTOWWW > as target" > endif > zip: > zip -r zipfiles/otto_`date > +%Y_%m.%d_%H%M`.zip ${DIST} ${DIST2} $(WEB) > # Common rules > .SUFFIXES: .ml .mli .cmo .cmi .cmx .mll > .mly > .ml.cmo: > $(OCAMLC) $(OCAMLFLAGS) -c $< > #$(OTTO_ML) > .mli.cmi: > $(OCAMLC) $(OCAMLFLAGS) -c $< > .ml.cmx: > $(OCAMLOPT) $(OCAMLOPTFLAGS) -c $< > .mll.ml: > ocamllex $< > .mly.ml: > ocamlyacc $< > # Clean up > clean: > -rm -f *.cmi > -rm -f *.mli > -rm -f *.cmo > -rm -f *.cmx > -rm -f parser.ml > -rm -f lexer.ml > -rm -f depend > -rm -f *.o > -rm -f subst_file.ml > -rm -f web_files.ml > # Dependencies > depend: $(OTTO_ML) parser.mli > $(OCAMLDEP) $(OTTO_ML) parser.mli > > depend > -include depend > ##*************************Ende*********************************** > > Could you give me some advice of > Binding this call_h2o.cma into our System, so then I can use > the Function in the call_h2o.cma for my script table.ml. > > Thank you very much for giving the > advice! > > Regards,Xuefeng Li > > > > > [Non-text portions of this message have been removed] > > > ------------------------------------ > > Archives up to December 31, 2007 are also downloadable at > http://www.connettivo.net/cntprojects/ocaml_beginners/ The archives of the > very official ocaml list (the seniors' one) can be found at > http://caml.inria.fr Attachments are banned and you're asked to be polite, > avoid flames etc.Yahoo! Groups Links > > > iD8DBQFIvRuKfIRcEFL/JewRAlC9AJ0cfiDbTuLgWEbxSB6IUEcvMNvElwCgpOTQ GbcJ8AKUMyb5Ao0zBLXoKrE= =ccQW -----END PGP SIGNATURE----- |
| Free Forum Powered by Nabble | Forum Help |