grx2.4 and mingw32
For simplicity I wrote a short program..
For compiling with fortran I have to compile it as follows:
gcc -c test.c g77 -o test test.o -lgrx20 -mwindows
I need g77 for linking with FORTRAN code requiring the FORTRAN libraries..
test does do nice things (no window for the graphics context..)
The MAIN__ (required as PROGRAM xxx for the fortran library) and GRXMain seem to be fighting against each other..
-- test.c -- #include <grx20.h> #include <malloc.h> static int xmax, ymax, status;
int MAIN__() { GRXMain(); }
int GRXMain() { gstest1(); }
gstest1() { long nplanes; int points[4][2] = {{30,30},{300,30},{300,300},{30,300}}; GrLineOption GSDefinition;
/* Initialisiere Graphik */ GrSetMode(GR_default_graphics); xmax=GrMaxX(); ymax=GrMaxY();
/* Initialisiere eine Farbe (Rot) */ GrSetColor( 2, 255, 0, 0);
/* Zeichne Viereck mit Groesse des Bildschirms -10 */ GrBox(10, 10, xmax-10, ymax-10, 2);
GrSetMode(GR_default_text);
}
---
Any idea? Gerhard Schneider
-- test.c -- #include <grx20.h> #include <malloc.h> static int xmax, ymax, status;
Why this?, it not makes sense, GRXMain will be called from WinMain (in the video driver)
int MAIN__() { GRXMain(); }
This is ok
int GRXMain() { gstest1(); }
gstest1() { long nplanes; int points[4][2] = {{30,30},{300,30},{300,300},{30,300}}; GrLineOption GSDefinition;
/* Initialisiere Graphik */ GrSetMode(GR_default_graphics); xmax=GrMaxX(); ymax=GrMaxY();
/* Initialisiere eine Farbe (Rot) */ GrSetColor( 2, 255, 0, 0);
/* Zeichne Viereck mit Groesse des Bildschirms -10 */ GrBox(10, 10, xmax-10, ymax-10, 2);
You need some code here if you want to see something
GrSetMode(GR_default_text);
}
The problem is not in GRX, when Mingw makes a windows program (via the -mwindows switch) it expect to begin with WinMain, not main.
Problem solved..
For my example I had to:
cp libg2c.a libmyg2c.a ar d mylibg2c.a main.o (you don't need it because mingw provides it :-)
g77 -o mytest mytest.c -L. -lmyg2c -lgrx20 -mwindows
Working well (with FORTRAN too..).
GS