[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Can I have a real main() ?

Marvin wrote:

I'm trying to add some graphics features to a C++ program for scientific calculation that I wrote some time ago. I chose V because it seemed easy to learn and portable. So far, I've been able to use the vTextCanvasPane to display the numerical results, and the vCanvasPane to plot the graphics. The problem is that I'm not able to put the 2 different canvases in the same application;

First of all, thanks to Bruce Wampler, Nikolai Tkachenko and Tom Hilinski for their precious help. Now my Test application has two vCmdWindows (a vTextEditor and a vCanvasPane); yesterday I used them to display the entries of a matrix and the plot of a cosine, and they worked all right. It seemed to me that my problems were over, so I started to add my C++ classes (the ones that make the actual calculation), to the Test app.

Here I've found out that I have a horrible problem: my classes need to link various local math libraries that we have here at Department of Mechanics; they are very old ones, automatically translated by F2c from Fortran to C, so they need to link the well-known libF2c.a library, that provides them with the proper environment (typedefs, function calls, defines, etc.)

The problem is that libF2c.a needs that somewhere a function main() is defined:

$ make
g++ -o ter.exe -O -LC:/cygwin/v/lib -L/local/lib ./terapp.o ./tercnv.o ./tercmdw .o ./tedcnv.o ./tedcmdw.o ./matrici.o -lsysln -leigen -lalloc -lF2c -lV -lcomctl32
 -lm -mwindows
/usr/lib/gcc-lib/i686-pc-cygwin/2.95.3-4/../../../../i686-pc-cygwin/bin/ld: warn
ing: cannot find entry symbol _WinMainCRTStartup; defaulting to 00401000
/local/lib/libF2c.a(main.o)(.text+0x1a4):main.c: undefined reference to `MAIN__'
collect2: ld returned 1 exit status
make: *** [ter.exe] Error 1

If I add a fake main
 int main(){}
anywhere in the code, the program links without errors, but then it does nothing. I understand that this is due to the fact that some sort of main for my V application is provided at linktime by the operating system, if none is found. So my question is: is it possible to force the linker to override the fake main, so that I can cheat libF2c.a, and have the V appMain started as well?

Ciao, Marvin

Reply to: