C interface trouble
David Carter
d.carter at 2020speech.com
Thu Jan 10 17:12:29 CET 2002
Hi,
This is a bit long, but I'm hoping an experienced Mozart/Cygwin/C/C++
hacker can just skim through it, muttering "yes...yes...yes...oh no,
the idiot!!", and tell me where, why and how I am an idiot.
I am tearing my hair out trying to get oztool to compile and link a
non-trivial
DLL for calling from Mozart. I'm running Mozart 1.2.3 under Cygwin and
Windows 2000.
I followed the example given in the "C Interface" documentation and
everything worked fine, along these lines:
% oztool c++ -c test.cc -o test.o
% oztool ld test.o -o test.so-`oztool platform`
declare [Test] = {Module.link ['test.so{native}']}
I can call the functions in "test" and get good results. But problems
arise when I try to include the C object code I actually want to
interface to, which has nothing to do with Mozart/Oz and was compiled
with its own makefile, calling gcc not oztool (although I did modify
the makefile to compile with -mno-cygwin).
This other code is in a directory I will call "otherstuff". I can use
it successfully from a standalone C program mymain.c:
% gcc -mno-cygwin -I../otherstuff/include -c -o mymain.o mymain.c
% gcc -mno-cygwin -o mymain mymain.o ../otherstuff/obj/*.o
Next, I wrote myinterface.cc (note: C++ not C) which has an include of
"mozart.h" as well as one for code that calls the otherstuff. The include
for the otherstuff, and the calls that use it, are just the same as in
mymain.c.
And it compiles fine with
% oztool c++ -I../otherstuff/include -c myinterface.cc -o myinterface.o
Now I want to make the DLL. Here's what I tried:
% oztool ld -o myinterface.so-`oztool platform` ../otherstuff/obj/*.o
myinterface.o
The problem is, I get lots of undefined references, generated by calls
in myinterface.cc to functions in otherstuff. I know the otherstuff
code is being seen, because before I figured out I had to compile that
with -mno-cygwin, I was getting complaints from there too -- some
of them from the very same functions it is telling me are now undefined.
So - how do I tell "oztool ld" that the calls to in myinterface to
functions in otherstuff refer to those functions?? One trouble is that
"oztool ld" with a "-verbose" reveals calls are being made to DLLTOOL
and DLLWRAP, which I had never heard of before today...
Thanks in advance
David
-
Please send submissions to users at mozart-oz.org
and administriva mail to users-request at mozart-oz.org.
The Mozart Oz web site is at http://www.mozart-oz.org/.
More information about the mozart-users
mailing list