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

ifort can not find main function from my application fortran code

david_ifort
Beginner
1,175 Views

If Ifort links( using"-Qlocation,link,"C:\\Program Files\\Microsoft Visual Studio 8\\VC")FORTRAN codewith a static librarylibHYPRE.agenerated by gccfrom C code under cygwin,then the link can not find main functionof my application FUNCTION code, but use one of main function in libcygwin.a to result in a link error as follows.

Any suggestion? thanks in advance.

David.
=======================================

ifort main.f -c main.obj

Intel Visual Fortran Compiler Professional for applications running on IA-32, Version 11.1 Build 20090624 Package ID: w_cprof_p_11.1.038

Copyright (C) 1985-2009 Intel Corporation. All rights reserved.

ifort: warning #10146: no action performed for specified object file(s)

ifort module11.obj module12.obj module1.obj ads0.obj gmsini.obj vis0.obj rperm0.obj outdt3.obj alloc1.obj alloc2.obj alloc3.obj flux.obj mayer.obj hystmw.obj hyswwg.obj hyswws.obj resread.obj welread.obj cubic2.obj dpread.obj adoil.obj init.obj phabio.obj thirdd.obj main.obj densty.obj inst.obj odistm1.obj rstart.obj trapno.obj abnc.obj eacnms.obj ioncng.obj odiswo.obj single.obj try.obj adsorb.obj engbal.obj isamax.obj omofr.obj slv2eq.obj twoalc.obj alcptn.obj f.obj isrcheq.obj outdt1.obj solb.obj utfoam.obj asign1.obj file1.obj isrcheqi.obj outdt2.obj solmat.obj vgamma.obj asign2.obj file2.obj isrchfge.obj phasc.obj solve.obj viscos.obj bioread.obj file3.obj jacup.obj phcomp.obj sumtab.obj well.obj biosolve.obj g.obj jcg.obj printi.obj tcap.obj wellck.obj bundry.obj gauss.obj lauwer.obj printo.obj tdiffu.obj wellix.obj capnum.obj gel.obj manipl.obj prints.obj tielin.obj wheneq.obj coneq.obj georead.obj metric.obj qrate.obj time0.obj wmeacn.obj csecal.obj grdfac.obj moppst.obj radius.obj totals.obj cseod.obj noneq.obj reactr.obj tran1.obj matrixconv.obj cubic.obj ilsum.obj noneqk.obj renam1.obj trans.obj cvmgt.obj inname.obj nslug.obj renam2.obj trap.obj ddriv2.obj inout.obj odistm.obj revise.obj trapg.obj utchem_hypre.obj hypresolver.obj libcygwin.a libgpc.a libHYPRE.a -o utchem93

Intel Visual Fortran Compiler Professional for applications running on IA-32, Version 11.1 Build 20090624 Package ID: w_cprof_p_11.1.038

Copyright (C) 1985-2009 Intel Corporation. All rights reserved.

Microsoft Incremental Linker Version 8.00.50727.42

Copyright (C) Microsoft Corporation. All rights reserved.

-out:utchem93.exe

-subsystem:console

module11.obj

module12.obj

module1.obj

ads0.obj

gmsini.obj

vis0.obj

rperm0.obj

outdt3.obj

alloc1.obj

alloc2.obj

alloc3.obj

flux.obj

mayer.obj

hystmw.obj

hyswwg.obj

hyswws.obj

resread.obj

welread.obj

cubic2.obj

dpread.obj

adoil.obj

init.obj

phabio.obj

thirdd.obj

main.obj

densty.obj

inst.obj

odistm1.obj

rstart.obj

trapno.obj

abnc.obj

eacnms.obj

ioncng.obj

odiswo.obj

single.obj

try.obj

adsorb.obj

engbal.obj

isamax.obj

omofr.obj

slv2eq.obj

twoalc.obj

alcptn.obj

f.obj

isrcheq.obj

outdt1.obj

solb.obj

utfoam.obj

asign1.obj

file1.obj

isrcheqi.obj

outdt2.obj

solmat.obj

vgamma.obj

asign2.obj

file2.obj

isrchfge.obj

phasc.obj

solve.obj

viscos.obj

bioread.obj

file3.obj

jacup.obj

phcomp.obj

sumtab.obj

well.obj

biosolve.obj

g.obj

jcg.obj

printi.obj

tcap.obj

wellck.obj

bundry.obj

gauss.obj

lauwer.obj

printo.obj

tdiffu.obj

wellix.obj

capnum.obj

gel.obj

manipl.obj

prints.obj

tielin.obj

wheneq.obj

coneq.obj

georead.obj

metric.obj

qrate.obj

time0.obj

wmeacn.obj

csecal.obj

grdfac.obj

moppst.obj

radius.obj

totals.obj

cseod.obj

noneq.obj

reactr.obj

tran1.obj

matrixconv.obj

cubic.obj

ilsum.obj

noneqk.obj

renam1.obj

trans.obj

cvmgt.obj

inname.obj

nslug.obj

renam2.obj

trap.obj

ddriv2.obj

inout.obj

odistm.obj

revise.obj

trapg.obj

utchem_hypre.obj

hypresolver.obj

libcygwin.a

libgpc.a

libHYPRE.a

libcygwin.a(libcmain.o) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function _main

utchem93.exe : fatal error LNK1120: 1 unresolved externals

make: *** [utchem93] Error 96

0 Kudos
3 Replies
Steven_L_Intel1
Employee
1,175 Views
If your main.f contains a Fortran main program, it emits a reference to _MAIN__ which should be resolved in libifcore.lib. Something is referencing libcmain in the Cygwin library that appears to want a "Windows" application type, hence the _WinMain@6 entry point. I suspect the Fortran part of this is irrelevant - that the C main is being pulled in from something else.

I might suggest adding, at the end of the ifort command that links:

/link /verbose

and look at the output to see what is getting referenced from where. Of course, we don't support use of ifort with Cygwin/gcc... Perhaps others who have experience with Cygwin can help.
0 Kudos
david_ifort
Beginner
1,175 Views
I add the /link /verbose into the link in the makefile, theproblemseems still there. Please take a look at the new output of make in the following, thanks.

David

ifort module11.obj module12.obj module1.obj ads0.obj gmsini.obj vis0.obj rperm0.obj outdt3.obj alloc1.obj alloc2.obj alloc3.obj flux.obj mayer.obj hystmw.obj hyswwg.obj hyswws.obj resread.obj welread.obj cubic2.obj dpread.obj adoil.obj init.obj phabio.obj thirdd.obj main.obj densty.obj inst.obj odistm1.obj rstart.obj trapno.obj abnc.obj eacnms.obj ioncng.obj odiswo.obj single.obj try.obj adsorb.obj engbal.obj isamax.obj omofr.obj slv2eq.obj twoalc.obj alcptn.obj f.obj isrcheq.obj outdt1.obj solb.obj utfoam.obj asign1.obj file1.obj isrcheqi.obj outdt2.obj solmat.obj vgamma.obj asign2.obj file2.obj isrchfge.obj phasc.obj solve.obj viscos.obj bioread.obj file3.obj jacup.obj phcomp.obj sumtab.obj well.obj biosolve.obj g.obj jcg.obj printi.obj tcap.obj wellck.obj bundry.obj gauss.obj lauwer.obj printo.obj tdiffu.obj wellix.obj capnum.obj gel.obj manipl.obj prints.obj tielin.obj wheneq.obj coneq.obj georead.obj metric.obj qrate.obj time0.obj wmeacn.obj csecal.obj grdfac.obj moppst.obj radius.obj totals.obj cseod.obj noneq.obj reactr.obj tran1.obj matrixconv.obj cubic.obj ilsum.obj noneqk.obj renam1.obj trans.obj cvmgt.obj inname.obj nslug.obj renam2.obj trap.obj ddriv2.obj inout.obj odistm.obj revise.obj trapg.obj utchem_hypre.obj hypresolver.obj libcygwin.a libgpc.a libHYPRE.a -o utchem93 /link /verbose
Intel Visual Fortran Compiler Professional for applications running on IA-32, Version 11.1 Build 20090624 Package ID: w_cprof_p_11.1.038
Copyright (C) 1985-2009 Intel Corporation. All rights reserved.

Microsoft Incremental Linker Version 8.00.50727.42
Copyright (C) Microsoft Corporation. All rights reserved.

-out:utchem93.exe
-subsystem:console
/verbose
......
utchem_hypre.obj
hypresolver.obj
libcygwin.a
libgpc.a
libHYPRE.a

Starting pass 1
Processed /DEFAULTLIB:ifconsol
Processed /DEFAULTLIB:libifcoremt
Processed /DEFAULTLIB:libifport
Processed /DEFAULTLIB:libmmt
Processed /DEFAULTLIB:LIBCMT
Processed /DEFAULTLIB:libirc
Processed /DEFAULTLIB:svml_disp
Processed /DEFAULTLIB:OLDNAMES

Searching libraries
Searching libcygwin.a:
Searching libgpc.a:
Searching libHYPRE.a:
Found _HYPRE_IJMATRIXCREATE
Referenced in hypresolver.obj
Loaded libHYPRE.a(F90_HYPRE_IJMatrix.o)
........
Referenced in libirc.lib(tbk_display.obj)
Referenced in libirc.lib(tbk_backtrace.obj)
Loaded LIBCMT.lib(splitpat.obj)
Found __except_handler3
Referenced in libirc.lib(tbk_backtrace.obj)
Loaded LIBCMT.lib(exsup3.obj)
Found __mbsnbcpy_s
Referenced in LIBCMT.lib(splitpat.obj)
Loaded LIBCMT.lib(mbsnbcpy_s.obj)
Found _CallDestructExceptionObject
Referenced in LIBCMT.lib(exsup3.obj)
Loaded LIBCMT.lib(calldtor.obj)
Found __ValidateEH3RN
Referenced in LIBCMT.lib(exsup3.obj)
Loaded LIBCMT.lib(eh3valid.obj)
Found __mbsnbcpy_s_l
Referenced in LIBCMT.lib(mbsnbcpy_s.obj)
Loaded LIBCMT.lib(mbsnbcpy_s_l.obj)
Searching C:\Program Files\Intel\Compiler\11.1\038\Lib\ia32\libirc.lib:
Searching C:\Program Files\Intel\Compiler\11.1\038\Lib\ia32\svml_disp.lib:
Searching C:\Program Files\Microsoft Visual Studio 8\VC\LIB\OLDNAMES.lib:
Searching C:\Program Files\Microsoft Visual Studio 8\VC\LIB\uuid.lib:
Searching C:\Program Files\Microsoft Visual Studio 8\VC\LIB\kernel32.lib:
Searching C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\ImageHlp.lib:
Searching libcygwin.a:
Searching libgpc.a:
Searching libHYPRE.a:
Searching C:\Program Files\Intel\Compiler\11.1\038\Lib\ia32\ifconsol.lib:
Searching C:\Program Files\Intel\Compiler\11.1\038\Lib\ia32\libifcoremt.lib:
Searching C:\Program Files\Intel\Compiler\11.1\038\Lib\ia32\libifport.lib:
Searching C:\Program Files\Intel\Compiler\11.1\038\Lib\ia32\libmmt.lib:

Finished searching libraries

Finished pass 1

Generating non-SAFESEH image.
libcygwin.a(libcmain.o) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function _main
utchem93.exe : fatal error LNK1120: 1 unresolved externals
make: *** [utchem93] Error 96

0 Kudos
Steven_L_Intel1
Employee
1,175 Views
Adding /link /verbose would not fix the problem - but the output it displayed might help diagnose the problem. Unfortunately, you removed the interesting part. Please attach a ZIPped output file as I expect it will be large.

In any event, the issue is that something is referening libcmain.o from the Cygwin library but nothing is providing the _WinMain@16 entry point. I don't know if it would help to add /link /subsystem:console (don't have two /link switches) at the end of the ifort command, but you really need a Cygwin expert here. The issue is not Fortran.
0 Kudos
Reply