CLAPACK : Undefined reference to main__

CLAPACK : Undefined reference to main__

Post by Mik » Tue, 20 Aug 2002 21:33:01

I am trying to use the CLAPACK libraries from but simply
cannot get anything to compile.  No matter what I seem to do I
eventually get the error

Undefined refernce to main__

with varying gunk before it depending on exactly what I have done to
get the error.  I am pretty sure that there is nothing wrong with the
code I am trying to compile since it is the example code from in the FAQ

can anyone help me?  I am going nuts



1. F2C undefined reference to MAIN__ ?

Hi All:

This issue is a recurring theme and probably been answered before. But
can anyone tell me how to get rid of this linker error?
I don't think the answer is "get a newer version of f2c"?

This error usually occurs after the fortran has been converted to C, and
a "fortran converted" routine is called from a C main program. The static
library of f2c(libf2c.a) does not give this error. But the shared library
version gives " undefined reference to MAIN__". Awhile back, I
took the f2c source code and broke out the libI77, and libbF77 libs from , removed all references to main and linked the new c source with
these libs instead of This seemed to work, but I don't want to
hack f2c again.
My current f2c version came with the stock redhat 4.2 as does my libgcc
(gcc so I don't think I have any library, loader, linker
incompatility problems. Besides compiling with -static option works. Any
ideas why I get these errors with the shared lib.
Libraries and applications generated from the fortran code excluxively
work(no c interface).

So to summarize:
Fortran exclusively with shared or static libs - works
Fortran library callable from C main with static libraries - works
Fortran library callable from C main with shared libraries - generates
undefined reference to MAIN__

Can anyone shed some light on this issue.

Bill D.

2. Ping error?

3. f2c: Shared lib problem(Was: Undefined reference to MAIN__)


5. f2c: undefined reference to `MAIN__'

6. ALI M1533 Aladin IV

7. undefined reference to `pw_crypt',undefined reference to `spw_unpack'

8. I want to know how make the module of AIX. (I need "IBM AIX Version 3.1 RISC System/6000 as a Real-Time System")

9. gcc -lf2c strangeness -- "MAIN__ undefined symbol"

10. f2c: udefined reference to 'MAIN__'

11. Unresloved reference MAIN__ in

12. Can't seem to fix `undefined reference to `stat'' and `undefined reference to `atexit''

13. undefined reference to 'assert'