Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

libf2c.so problem!

Status
Not open for further replies.

milenko76

Technical User
Mar 26, 2010
100
PT
When I want to make file,get this:
/usr/lib/gcc/x86_64-linux-gnu/4.3.3/../../../../lib/libf2c.so: undefined reference to `MAIN__'
collect2: ld returned 1 exit status
What is going on?
How to overcome this issue?
My makefile:
FFLAGS = -O2 -g
#CFLAGS = -O -I/usr/openwin/include
CFLAGS = -O
LINK_FLAGS_AFTER='$$(PROFILE) $$(ALL_LIB) -u MAIN__
#
#rules for compiling .f files:
#
.f.o:
$(COMPILE.f) $(FFLAGS) $< $(INCS)
.c.o:
$(COMPILE.c) $(CFLAGS) $< $(INCS)
 
This line is important:
f77 -o main driver.o solve_mt2d_direct.o boem.o rotz.o gebolr.o d2emod.o pobo.o mte.o d2hmod.o gsres.o mth.o z1idu.o h1iud.o phase.o
Why is he adding main ???
 
milenko76 said:
Why is he adding main ???
It's not adding main. The option -o main means that the output should be placed into main, i.e. it creates the executable named main.
 
Not really.I found this:
The problem is that f2c wants to link to the MAIN__ function which is the "fortran main". Apparently it is just a dummy function call. And the fix is quite simple:

Add "int MAIN__( ) { return 0; }" somewhere is the sources.

Or pass the option -u MAIN__ to the linker.

How to do this?

 

Do you have a main program in your code ?

You need it else the linker will refuse to build up the executable program.

It does not depend on the programming language you use. FORTRAN , C, C++ of JAVA programs need a main program.



François Jacq
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top