Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29246 Discussions

unresolved external symbol _MAIN__ referenced in function _main

Brian_A_
Novice
2,787 Views

THis program compiled fine on CFC, but in IFC 2011 I am encountering an error.

[bash]Microsoft  Program Maintenance Utility Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.

	if not exist o mkdir o
	dir envrl\*.hh /b /l /o >envrl\filedoth
	dir envrl\*.ff /b /l /o >envrl\filedotf
	dir matpro\*.hh /b /l /o >matpro\filedoth
	dir matpro\*.ff /b /l /o >matpro\filedotf
	dir relap\*.hh /b /l /o >relap\filedoth
	dir relap\*.ff /b /l /o >relap\filedotf
	dir scdap\*.hh /b /l /o >scdap\filedoth
	dir scdap\*.ff /b /l /o >scdap\filedotf
	auxx\builderm makermap
	nmake -nologo -f makrelap def=rma NM=o FFLAGS=  FPSTOP= O=o cpl= exedll=dll
	lib -nologo  relap\aatl.o relap\brycej.o relap\ccfl.o relap\chfcal.o relap\chfkut.o relap\chforn.o relap\chfpg.o relap\chfpgf.o relap\chfpgg.o relap\chfpgp.o relap\chfsrl.o relap\chftab.o relap\chklev.o relap\cmpdat.o relap\conden.o relap\condn2.o relap\cthxpr.o relap\dittus.o relap\dtstep.o relap\eprij.o relap\fidis2.o relap\fidisj.o relap\fidisv.o relap\flostj.o relap\flostv.o relap\gasthc.o relap\gentblc.o relap\helm.o relap\hifbub.o relap\hseflw.o relap\htfilm.o relap\htheta.o relap\htlev.o relap\htrc1.o relap\htrc2.o relap\ilevel.o relap\invhtb.o relap\inputd.o relap\intrac.o relap\invhts.o relap\invtbl.o relap\jundat.o relap\katokj.o relap\khoo.o relap\kloss.o relap\level.o relap\levskt.o relap\lpdatc.o relap\majout.o relap\ncfilm.o relap\ncprop.o relap\ncwall.o relap\noncnd.o relap\packer.o relap\pcontrl.o relap\petukv.o relap\phantj.o relap\phantv.o relap\pintfc.o relap\pjundat.o relap\prebun.o relap\prednb.o relap\qfhtrc.o relap\rchng.o relap\relap5.o relap\rnewp.o relap\rrestf.o relap\rrstd.o relap\rstrec.o relap\scnreq.o relap\scrtch.o relap\statcc.o relap\state.o relap\suboil.o relap\tchf.o relap\tchfmc.o relap\tdpptr.o relap\tempi.o relap\tempifc.o relap\tfront.o relap\thcond.o relap\tmsfb.o relap\tran.o relap\trip.o relap\trnctl.o relap\trnfin.o relap\trnset.o relap\tsetsl.o relap\tstpctc.o relap\ufilef.o relap\usrvarc.o relap\valve.o relap\vexplt.o relap\vfinl.o relap\vimplt.o relap\voldat.o relap\vreqsd.o relap\zbrent.o relap\zfslgj.o relap\accum.o relap\blkdta.o relap\brntrn.o relap\celmdr.o relap\adechk.o relap\cmpcom.o relap\cntrlc.o relap\convar.o relap\conver.o relap\courn1.o relap\cournt.o relap\cramer.o relap\detmnt.o relap\display00.o relap\display01.o relap\display02.o relap\display03.o relap\display04.o relap\displaytp.o relap\displayw3.o relap\dmpcom.o relap\dryer.o relap\eccmxj.o relap\eccmxv.o relap\eqfinl.o relap\eqfinm.o relap\fhnumbers.o relap\fildmp.o relap\fmvlwr.o relap\ftbmem.o relap\fwdrag.o relap\gapcon.o relap\gcsub.o relap\gctpm.o relap\gedry.o relap\gesep.o relap\gesub.o relap\getsec.o relap\gninit.o relap\gntbl.o relap\grdnrj.o relap\griftj.o relap\guinstruct.o relap\handlemenu.o relap\handlemenu3.o relap\helphd.o relap\hloss.o relap\ht1inp.o relap\ht1sst.o relap\ht1tdp.o relap\ht2tdp.o relap\htadv.o relap\htcond.o relap\htcondd.o relap\htcsol.o relap\htfinl.o relap\hydro.o relap\hynode.o relap\hynoded.o relap\hzflow.o relap\icmpf.o relap\icmpn1.o relap\icompn.o relap\iconvr.o relap\iedit.o relap\ielvtn.o relap\igntbl.o relap\ihsefl.o relap\ihtcmp.o relap\ihzflw.o relap\ijprop.o relap\imiedt.o relap\imlp.o relap\incond.o relap\iplot.o relap\interi.o relap\invjt.o relap\ipipe.o relap\ipump.o relap\ir5pvmc.o relap\iradht.o relap\irflht.o relap\irkin.o relap\isngj.o relap\issi.o relap\istate.o relap\itrip.o relap\itrscn.o relap\itstck.o relap\iturbst.o relap\iusrvr.o relap\ivelst.o relap\ivlvel.o relap\jchoke.o relap\jprop.o relap\key.o relap\madata.o relap\mdata2.o relap\mirec.o relap\mover.o relap\mserrd.o relap\nansca.o relap\nanscj.o relap\nanscv.o relap\nlssrv.o relap\phantjd.o relap\phantvd.o relap\pimplt.o relap\plotmd.o relap\plotmd2.o relap\pltwrt.o relap\pminvx.o relap\polatr.o relap\preseq.o relap\prntfa.o relap\prntia.o relap\prseqm.o relap\psatpd.o relap\pscrtch.o relap\pset.o relap\pstdnb.o relap\pstpd2.o relap\ptrpblk.o relap\pump.o relap\pump2.o relap\pvmfxrec.o relap\pvmput.o relap\pvmrcv.o relap\pvmset.o relap\pvmsnd.o relap\pvoldat.o relap\qfmove.o relap\qfsrch.o relap\qmwr.o relap\r3dcmp.o relap\raccum.o relap\radht.o relap\rbrnch.o relap\rcards.o relap\rcdelt.o relap\rcompn.o relap\rconvr.o relap\rgntbl.o relap\rhelp.o relap\rhtcmp.o relap\rintrv.o relap\rkin.o relap\rmadat.o relap\rmap.o relap\rmblnk.o relap\rmflds.o relap\rmiedt.o relap\rmtplj.o relap\rnoncn.o relap\ronoff.o relap\rpipe.o relap\rplot.o relap\rpmpdc.o relap\rpmpmd.o relap\rpmvnj.o relap\rpump.o relap\rr5pvmc.o relap\rradht.o relap\rrewrite.o relap\rrkin.o relap\rrkinh.o relap\rrkinp.o relap\rsngj.o relap\rsngv.o relap\rssi.o relap\rstop.o relap\rstrip.o relap\rtmdj.o relap\rtmdv.o relap\rtrip.o relap\rtsc.o relap\rturb.o relap\rusrvr.o relap\rvalve.o relap\simplt.o relap\simul.o relap\snapit.o relap\srestf.o relap\sscntr.o relap\sstchk.o relap\stacc.o relap\statep.o relap\stateq.o relap\stcset.o relap\std2x0.o relap\std2x1.o relap\std2x3.o relap\std2x6.o relap\stdry.o relap\stdsp.o relap\stgodu.o relap\stolst.o relap\stread.o relap\strip.o relap\strpu.o relap\strpu1.o relap\strpu2.o relap\strpvm.o relap\strpx.o relap\strsat.o relap\strtp.o relap\strtx.o relap\strx.o relap\stvrpx.o relap\surftn.o relap\svh2x2.o relap\sysitr.o relap\syssol.o relap\tcnvsl.o relap\tstate.o relap\turbst.o relap\viscos.o relap\vlvela.o relap\volvel.o relap\wrplid.o -out:lib\relapo.lib
	envrl\stgh2oo.exe envrl\stgh2oo.pr
	envrl\stgd2oo.exe envrl\stgd2oo.pr
	ifort -nologo   -auto -Qansi_alias- -pad_source -traceback  -fltconsistency -fpconstant -nogen-interfaces  -thread -dbglibs -dll relap\relap5.o  lib\relapo.lib lib\scdapo.lib  lib\matproo.lib lib\envrlo.lib  libifcoremt.lib libifport.lib libmmt.lib kernel32.lib  ifqwin.lib gdi32.lib user32.lib libirc.lib  comdlg32.lib ifqw_mdi.lib libcmt.lib imagehlp.lib  opengl32.lib glu32.lib lib\f90gl.lib lib\f90glu.lib  lib\f90glut.lib lib\glut32.lib rma\sim.lib  -exe:relap5o.dll -link  -incremental:no -nodefaultlib
ifort: command line warning #10161: unrecognized source type 'relap\relap5.o'; object file assumed
ipo: warning #11073: relapo.lib(tsetsl.o): locally defined symbol __imp__LPDATC_mp_GERR imported
   Creating library relap5o.lib and object relap5o.exp
relapo.lib(tsetsl.o) : warning LNK4217: locally defined symbol _LPDATC_mp_GERR imported in function _TSETSL
relapo.lib(istate.o) : warning LNK4217: locally defined symbol _LPDATC_mp_GERR imported in function _ISTATE
relapo.lib(iedit.o) : warning LNK4049: locally defined symbol _LPDATC_mp_GERR imported
relapo.lib(syssol.o) : warning LNK4049: locally defined symbol _LPDATC_mp_GERR imported
libifcoremt.lib(for_main.obj) : error LNK2019: unresolved external symbol _MAIN__ referenced in function _main
relap5o.dll : fatal error LNK1120: 1 unresolved externals[/bash]

Here is the make file where the IFORT command is used.

[bash]$(f90) -nologo $(FFLAGS) $(FPSTOP) $(FL) \
	-thread -dbglibs -dll relap\relap5.$O \
	lib\relap$(NM).lib lib\scdap$(NM).lib \
	lib\matpro$(NM).lib lib\envrl$(NM).lib \
	libifcoremt.lib libifport.lib libmmt.lib kernel32.lib \
	ifqwin.lib gdi32.lib user32.lib libirc.lib \
	comdlg32.lib ifqw_mdi.lib libcmt.lib imagehlp.lib \
	opengl32.lib glu32.lib lib\f90gl.lib lib\f90glu.lib \
	lib\f90glut.lib lib\glut32.lib rma\sim.lib \
	-exe:relap5$(NM).dll -link \
	-incremental:no -nodefaultlib[/bash]

0 Kudos
8 Replies
Brian_A_
Novice
2,787 Views
It looks like it is a moduile called interfac.mod that was created from this file, called interfac.for.
[bash]      module interfaces
	interface

      subroutine SIMSTATE [c, alias:'_simstate'] ()
      end subroutine SIMSTATE

      end interface

	end
[/bash]
I type the command: ifort interfac.for to create a obj and mod file and then I get the same unresolved error.
0 Kudos
IanH
Honored Contributor III
2,787 Views
_MAIN__ is the linker name that the intel fortran compiler gives to the main program (the program unit that optionally starts with a PROGRAM statement and ends with an END statement).

A DLL doesn't have a main program so the linker shouldn't be searching for that symbol. The command line in your original post does have /dll in it to tell the ifort driver that a DLL is being built, but I suspect your manual specification of all the various intel libraries is then not consistent with the /dll option.

(In your reply post, your command line doesn't have the /dll option so the ifort driver will be trying to build a complete program. Your example source does not have a main program - hence the link error.)

Because you are using the ifort driver to organise the link stage there is typically no need to directly list things like the run time libraries. Is there a reason that you have things set up this way? Assuming CFC is the compaq compiler (CVF?) there's no way that its build line would have been referencing intel fortran libraries, so that configuration is not the same as the original working setup.

I am not familiar enough with the runtime library details and don't know what sort of application you are trying to build so I can't say this with any confidence, but I would be getting rid of -nodefaultlib and the various libif* libraries as a starting point and instead rely on the higher level command line options of the ifort driver. Tell us more about the nature of the application if you want more specific advice about those.

0 Kudos
Brian_A_
Novice
2,787 Views
OK normally our program creates a EXE file, but we have another company that ties our program to theres by us providing them with a DLL instead. They gave us file called sim.lib and interfac.for. I have to create an obj and mod file for our code to compile with the ties to there code. The sim.lib contains this:
[bash]Microsoft  COFF/PE Dumper Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file rmasim.lib

File Type: LIBRARY

COFF SYMBOL TABLE
000 00937809 ABS    notype       Static       | @comp.id
001 00000000 SECT2  notype       External     | __IMPORT_DESCRIPTOR_selsim
002 C0000040 SECT2  notype       Section      | .idata$2
003 00000000 SECT3  notype       Static       | .idata$6
004 C0000040 UNDEF  notype       Section      | .idata$4
005 C0000040 UNDEF  notype       Section      | .idata$5
006 00000000 UNDEF  notype       External     | __NULL_IMPORT_DESCRIPTOR
007 00000000 UNDEF  notype       External     | selsim_NULL_THUNK_DATA

String Table Size = 0x50 bytes

COFF SYMBOL TABLE
000 00937809 ABS    notype       Static       | @comp.id
001 00000000 SECT2  notype       External     | __NULL_IMPORT_DESCRIPTOR

String Table Size = 0x1D bytes

COFF SYMBOL TABLE
000 00937809 ABS    notype       Static       | @comp.id
001 00000000 SECT2  notype       External     | selsim_NULL_THUNK_DATA

String Table Size = 0x1C bytes

     Exports

       ordinal    name

                  _MXXTIM
                  _RELSIM
                  _RELSIMF
                  _RNAMES
                  _RSTLINE
                  _SIMLOG
                  _SIM_ABORT
                  _UOPEN
                  _pltpos
                  _rdflag
                  _simstate

  Summary

          C0 .debug$S
          14 .idata$2
          14 .idata$3
           4 .idata$4
           4 .idata$5
           C .idata$6
[/bash]
I hope this makes sense.
0 Kudos
mecej4
Honored Contributor III
2,787 Views
Your project and build log are too big for me to examine line by line, but here is one point that occurs to me.

When you switch from building an EXE to building a DLL, you have to specify which routines are to be exported by the DLL, and you have to decide how to go about doing so.

If your sources have DEC$ ATTRIBUTES DLLEXPORT :: , the compiler and linker will build the export list and use the list in building the DLL.

If this is not the case, you have to build a module definitions file (something.DEF) manually, process it using LIB.EXE, and include the resulting exports file (something.EXP) in the step that uses the linker to build the DLL.
0 Kudos
Brian_A_
Novice
2,787 Views
Out main program is a subroutine, due to the fact that we have checking in place to see if it is a EXE or DLL being created. I took out the -nodefaultlib and the libif* files and get the same problem. The other company that is using our DLL supplied us with a sim.lib file, that contains the EXPORTS, and we modified three of our source files to have the DLLEXPORT commands in them. THey also supplied us with a file called interfac.for, which in our source is called using "use interfaces." We had to run the command "ifort -c interfac.for" to get the obj and mod files.
From what we can tell our coding should not think that it creating an EXE and we should not be getting the unresolved.
0 Kudos
Brian_A_
Novice
2,787 Views
[bash]$(f90) -nologo $(FFLAGS) $(FPSTOP) $(FL) -threads -dbglibs -dll 
	relaprelap5.$O librelap$(NM).lib libscdap$(NM).lib 
	libmatpro$(NM).lib libenvrl$(NM).lib libmmt.lib kernel32.lib 
	ifqwin.lib gdi32.lib user32.lib libirc.lib 
	comdlg32.lib ifqw_mdi.lib libcmt.lib imagehlp.lib rmasim.lib 
	-exe:relap5$(NM).dll -link -incremental:no[/bash]
Could any of the libraries in the command line be causing my unresolved?
0 Kudos
Brian_A_
Novice
2,787 Views
I fixed it. I removed all of the lib files that were not from our program.
0 Kudos
Lorri_M_Intel
Employee
2,787 Views

What did you mean by "our main program is a subroutine" ?

In order to have an executable, there must be an actualmain program somewhere in the mix. The
message you are getting means that there is no Fortran MAIN program there.

As described by a previous poster, a Fortran MAIN program either has an explicit
PROGRAM [optional program name]
at the beginning, or it has an implied "program" statement due to the lack of MODULE, FUNCTION, SUBROUTINE, or BLOCK DATA (etc).

Given your line above, I might expect that relap\relap5 might be a Fortran MAIN program.

-- Lorri

0 Kudos
Reply