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

Re: Can I have a real main() ?

At 10.24 01/07/01 -0600, Bruce Wampler wrote:
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.

According to the documentation of the F2c library, a main() is needed because "Fortran main programs result in a C function named MAIN__ that is meant to be invoked by the main() in libf77."

However, f2c is not used anymore to convert whole Fortran77 programs, but to maintain compatibility with old automatically translated routines, so this feature is now quite useless. I watched the source of F2c, and I found out that "MAIN__" appears only in a file called "main.c"; and who needs a main.c? So I tried this:
 cp libF2c.a libVF2c.a
 ar -d libVF2c.a main.o
and I linked it instead of F2c. It works!

I am quite confident that this is a good solution, because the libraries that still require F2c are usually mathematical ones (like eigenlib, syslin, and many others), and they are not likely to need the stuff in main.c (mostly i/o routines, if I understand correctly.)

Even if, as you pointed out, this is not strictly a V issue, I think that the documentation should mention it. The use of translated Fortran routines is still very common in scientific calculation programs (they are reliable, fast and free, you can't ask any better), and it would be a pity for V users to be forced to abandon their well known libraries, because of a silly linking problem.

Thank you again for your help, and for your wonderful work with V.

Ciao, Marvin

Reply to: