[ooc-compiler] C interface problems
Brought to you by:
mva
|
From: August <fus...@te...> - 2004-11-03 20:17:19
|
Hi everyone,
I'm trying to use OOC to compile a minimal OpenGL test program with
GLUT. I emailed the list about the subject a couple of months ago but
I never got it to work. S. Greenhill mentioned his OpenGL interface,
but unfortunately it lacks the GLUT definitions (moreover I prefer to
rename the identifiers by removing the prefix).
In C the code (not the generated code) is:
#include <GL/glut.h>
int w;
void Display(void) {}
int main(void)
{
w = glutCreateWindow("OpenGL Test");
glutDisplayFunc(Display);
glutMainLoop();
return 0;
}
It can be compiled and linked with the command ` gcc -o test
test.c -lopengl32 -lglut32'. When I run the program it successfully
displays an empty window.
Now to the Oberon-2 counterpart. I have a module named Glut.Mod which
contains:
MODULE Glut [INTERFACE "C"; LINK LIB "glut32"; LIB "opengl32"; END];
IMPORT C;
PROCEDURE ["glutCreateWindow"] CreateWindow*(title: ARRAY OF
C.char): C.int;
PROCEDURE ["glutDisplayFunc"] DisplayFunc*(p: PROCEDURE);
PROCEDURE ["glutMainLoop"] MainLoop*;
END Glut.
The test program is:
MODULE Test;
IMPORT C, Glut;
VAR w: C.int;
PROCEDURE Display;
END Display;
BEGIN
w := Glut.CreateWindow("OpenGL Test");
Glut.DisplayFunc(Display);
Glut.MainLoop
END Test.
When I execute `oo2c -M -v -r .. Test.Mod' I get the following output:
cd e:/home/ob2/c-interface/src/
oo2c -M -v -r .. Test.Mod
- /usr/local/lib/oo2c/pkginfo.xml
- /home/ob2/c-interface/sym/Test.Sym
- /usr/local/lib/oo2c/sym/RT0.Sym
- /usr/local/lib/oo2c/sym/Object.Sym
- /usr/local/lib/oo2c/sym/HashCode.Sym
- /usr/local/lib/oo2c/sym/Exception.Sym
- /usr/local/lib/oo2c/sym/C.Sym
- /home/ob2/c-interface/src/Glut.Mod
- /home/ob2/c-interface/src/Glut.Mod
+ /home/ob2/c-interface/obj/Glut.d
+ /home/ob2/c-interface/obj/Glut.oh
+ /home/ob2/c-interface/sym/Glut.Doc
+ /home/ob2/c-interface/sym/Glut.Sym
- /home/ob2/c-interface/sym/Glut.Sym
+ /home/ob2/c-interface/obj/Test_.c
gcc -O2 -I/usr/local/include -DGC_WIN32_THREADS -I/usr/local/lib/oo2c/src
-I/home/ob2/c-interface/obj -Iobj -I/usr/local/lib/oo2c/obj -c
/home/ob2/c-interface/obj/Test_.c -o /home/ob2/c-interface/obj/Test_.o
gcc -o /home/ob2/c-interface/bin/Test -L/usr/local/lib
/usr/local/lib/oo2c/obj/RT0.o /usr/local/lib/oo2c/obj/HashCode.o
/usr/local/lib/oo2c/obj/Object.o /usr/local/lib/oo2c/obj/Exception.o
/home/ob2/c-interface/obj/Test.o
/home/ob2/c-interface/obj/Test_.o -lopengl32 -lglut32 -L/usr/local/lib
/home/ob2/c-interface/obj/Test.o(.text+0x5c):Test.c: undefined
reference to `glutCreateWindow'
/home/ob2/c-interface/obj/Test.o(.text+0x6d):Test.c: undefined
reference to `glutDisplayFunc'
/home/ob2/c-interface/obj/Test.o(.text+0x78):Test.c: undefined
reference to `glutMainLoop'
Compilation exited abnormally with code 1 at Tue Nov 02 03:14:32
What am I doing wrong? Note that both `-lopengl32' and `-lglut32'
appears in the output (in the correct relative order).
Regards,
August
|