Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
ocamlopt problem
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-06-02 (21:07)
From: David Allsopp <dra-news@m...>
Subject: ocamlopt problem
I'm trying to build the ocamlodbc package under Windows using Cygwin/MinGW.
It's all built and working except that I'm having one problem with the
native library. My question, I think, relates to a misunderstanding with
ocamlopt so I'm hoping someone can point out my error! 

I've adapted the script to issue the following commands:

$ gcc -mno-cygwin -c -DODBC2 -DWIN32 -I $OCAMLLIB/caml -I
/usr/include/w32api ocaml_odbc_c.c
$ gcc -mno-cygwin -shared -L $OCAMLLIB -L $OCAMLLIB/../bin -o
dllocamlodbc.dll ocaml_odbc_c.o -lodbc32 -locamlrun 

$ ocamlopt -a -o ocamlodbc.cmxa ocaml_odbc_c.o ocamlodbc.mli -cclib -lodbc32
$ cp ocamlodbc.cmxa ocamlodbc.a ocamlodbc.cmi $OCAMLLIB

$ ocamlc -a -o ocamlodbc.cma ocamlodbc.mli -dllib
$ cp ocamlodbc.cmi ocamlodbc.cma $OCAMLLIB
$ cp dllocamlodbc.dll $OCAMLLIB/stublibs

The top-level library ocamlodbc.cma is working exactly as I'd expect. I then
attempt to compile a program that uses the native library (in this case
Exemples/ with the command

ocamlopt -o monitor.exe ocamlodbc.cmxa

but get the response

gcc: ocaml_odbc_c.o: No such file or directory
Error during linking

Despite trying various -ccopt flags, the only way I can make it compile is
to copy ocaml_odbc_c.o to the current directory. My understanding is that
the ocamlopt statement that built ocamlodbc.cmxa should have included
ocaml_odbc_c.o so why is gcc getting a linker problem when referencing the

Sorry if it's a blindingly obvious mistake...