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

Re: Can I have a real main() ?

I don't know the solution to this at the moment, but I understand just
what the problem is.

I don't know why the library needs a main. That info is probably buried
in the documentation for that library. You might have to rebuild the library.

But, here is what the problem is:

When Windows starts an app that uses the Windows API, it must
have a routine called WinMain to start things going. This is the entry point.
But any C or C++ code will be built with a runtime library. There are
different versions of the runtime library. Those that don't use the Windows
API will be built to start in main() rather than WinMain(). It depends on
which runtime library you use. This is a function of the cygwin envrionment
it looks like you are using. So, somehow or another, the f2c library wants
main(), but not WinMain, but V and Windows wants WinMain().

I'm sure you aren't the first to encounter the problem, but you are the
first I know about to use V with F2c and encounter the problem.

The key is how to fix the startup code. Ideally, there is an F2c support
group that has the answer. There is also likely to be someone on
the cygwin newsgroup that knows how to deal with the main/WinMain
issue. You might have to build a special startup library for Cygwin.
It is not hard, and someone has likely done it  already. Then it wiould
simply be a linking issue. But I can't fix it in V because V needs
the WinMain entry point.

At 03:51 AM 07/01/2001, 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 ./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

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

Bruce E. Wampler, Ph.D.

Author of the V C++ GUI Framework

e-mail: mailto:bruce@objectcentral.com
web:    http://www.objectcentral.com

Reply to: