gcc -lf2c strangeness -- "MAIN__ undefined symbol"

gcc -lf2c strangeness -- "MAIN__ undefined symbol"

Post by Robert Dodi » Thu, 01 Oct 1998 04:00:00



Hello all,

I have installed the most recent f2c .rpm on my RH 5.0 system.
I can run f2c and compile the results using gcc just fine.
However, when I try to link the .o's together, I get this
error: "MAIN__ not defined".

Now nm libf2c.a shows that "main" is defined in main.o, and
"MAIN__" is an undefined symbol in main.o. I suppose that
the intent is that if I don't supply a main() function,
then MAIN__() will be called.

But indeed I do have a main() function. This tiny example
shows what happens:

t.c:
main() { return 0; }

% gcc -c t.c
% gcc t.o -o t -lf2c
--> produces "/usr/lib/libf2c.so: undefined reference to `MAIN__'"

What's going on here? Perhaps this is a problem with ld -- the
linker should not even try to search libf2c.so since there are no
undefined symbols in t.o.

Has anyone out there successfully linked programs created
using f2c??

Thanks in advance,
Robert Dodier

PS. Of course, my intention is to link t.c with functions translated
from Fortran by f2c. Perhaps that's not clear in the example.
--
``I was a less than serious student in college. If I had it to do over
again, I would be far more serious. I did play a lot of golf. But I
don't think that's any reflection on my ability to lead this nation.''
     -- Vice President Dan Quayle

 
 
 

gcc -lf2c strangeness -- "MAIN__ undefined symbol"

Post by B.W.H. van Bees » Sat, 03 Oct 1998 04:00:00



> Hello all,

> I have installed the most recent f2c .rpm on my RH 5.0 system.
> I can run f2c and compile the results using gcc just fine.
> However, when I try to link the .o's together, I get this
> error: "MAIN__ not defined".

> Now nm libf2c.a shows that "main" is defined in main.o, and
> "MAIN__" is an undefined symbol in main.o. I suppose that
> the intent is that if I don't supply a main() function,
> then MAIN__() will be called.

> But indeed I do have a main() function. This tiny example
> shows what happens:

> t.c:
> main() { return 0; }

> % gcc -c t.c
> % gcc t.o -o t -lf2c
> --> produces "/usr/lib/libf2c.so: undefined reference to `MAIN__'"

> What's going on here? Perhaps this is a problem with ld -- the
> linker should not even try to search libf2c.so since there are no
> undefined symbols in t.o.

> Has anyone out there successfully linked programs created
> using f2c??

> Thanks in advance,
> Robert Dodier

> PS. Of course, my intention is to link t.c with functions translated
> from Fortran by f2c. Perhaps that's not clear in the example.
> --
> ``I was a less than serious student in college. If I had it to do over
> again, I would be far more serious. I did play a lot of golf. But I
> don't think that's any reflection on my ability to lead this nation.''
>      -- Vice President Dan Quayle

I know of this problem. A work-around is to  compile the following
FORTRAN program:

C      for f2c
         END

(i.e. an almost empty FORTRAN main!)
and link it together with the rest of your code.
Don't ask me why.
 At least this helps. If anybody knows the true solution, I am interested
as well!

Regards,

Bertwim van Beest

 
 
 

1. What does "Undefined symbol "_glXMakeCurrent" mean?

Hi,
I have problems running the binary lyx-1.1.2 pkg on a 425t. First I had
to
trick pkg_add because the lyx pkg says it wants teTeX-1.0.6 and nothing
else but the available version is 1.0.7. When I start lyx I only get:

     /usr/libexec/ld.so:Undefined symbol "_glXMakeCurrent" in
     lyx:/usr/X11R6/lib/libforms.so.0.88

What is the villain? lyx,xforms-0.88 or ld.so?

I am using a freshly installed NetBSD-1.4.2 without xfont.tgz and
xserver.tgz. XServer is a Mac running MI/X.
I hope someone can help me.

                                Regards, Torsten

2. a half gig of swap and still running out of memory?

3. GETSERVBYNAME()????????????????????"""""""""""""

4. SLS 1.05

5. """"""""My SoundBlast 16 pnp isn't up yet""""""""""""

6. XDMCP Exceed + RH7

7. tdb_link error: "cg: cannot calculate difference between symbol ".L1 and symbol"

8. Storix System Backups

9. "undefined symbol" problem

10. /usr/sbin/pkg_create: Undefined symbol "basename"

11. ps command yields "ld.so: Undefined symbol: _kvm_read"

12. kde error: "undefined symbol: __pure_virtual"