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

Re: Can I have a real main() ?

tafkam@libero.it wrote:
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
>.o ./tedcnv.o ./tedcmdw.o ./matrici.o -lsysln -leigen -lalloc -lF2c -lV
>  -lm -mwindows
>ing: cannot find entry symbol _WinMainCRTStartup; defaulting to 00401000
>/local/lib/libF2c.a(main.o)(.text+0x1a4):main.c: undefined reference to
>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

To UNSUBSCRIBE, email to other-vgui-discuss-request@other.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@other.debian.org

Some time ago, I had the same problem with libf2c and the missing main() function. A possible solution is the following: make a copy of libf2c.a, named e.g. lib my_f2c.a and delete the object file  main.o from that library using the unix command
"ar -d ....." (look at the man pages). Then link to my_libf2c instead of original libf2c. For me this worked well.
Volker Roth          University of Bonn     Department of Computer Science III
D-53117 Bonn         Roemerstr. 164         Germany
roth@cs.uni-bonn.de  Tel: +49 228 734219    Fax:  +49 228 73 4382
Reply to: