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

Link error with module subroutines under 64-bit enviroment

phu_intel
Beginner
795 Views

Hi,

I am having trouble to complie/link a pretty simple test program under win64enviroment. by using intel 9.1 fortran complier. The program is simple with just two fotran file. One is the main file "mymain.for" and the other one is a module file "mydata.for". I wrote my make file "Makefile.win". It is ok under DOS build enviroment for 32-bit application; however, it fails under DOS build enviroment for 64-bit application.

The error I got is like this:

----------------------------------

mymain.obj : error LNK2019: unresolved external symbol MYDATA_mp_SETMYDATA refer
enced in function MAIN__
mymain.obj : error LNK2019: unresolved external symbol MYDATA_mp_GETMYDATA refer
enced in function MAIN__
.Release-Win64mytest.exe : fatal error LNK1120: 2 unresolved externals
NMAKE : fatal error U1077: 'link.exe' : return code '0x460'
Stop.

------------------------------------

Any anyone give a suggestion why this happens? Here is my fortran files and Makefile.win.

Thanks a lot!

-----------------------

mymain.for:

program mymain

use mydata

implicit none

integer(4) id

type(mytype) :: test1

id = 1

call setmydata(test1,id)

call getmydata(test1,id)

end program

------------------------

-----------------------

mydata.for

module mydata

implicit none

type mytype

integer(4) :: myId

end type mytype

contains

subroutine setmydata(this, myId_)

implicit none

type(mytype) :: this

integer(4),intent(in) :: myId_

this%myId = myId_

return

end subroutine setmydata

subroutine getmydata(this, myId_)

implicit none

type(mytype) :: this

integer(4),intent(out) :: myId_

myId_ = this%myId

return

end subroutine getmydata

end module mydata

--------------------------

---------------------------

Makefile.win

!IF "$(CFG)" == ""
!MESSAGE No configuration specified. You must specify a
!MESSAGE configuration on the command line. Example:
!MESSAGE
!MESSAGE nmake /f Makefile.win CFG="release"
!MESSAGE
!ERROR Invalid Configuration.
!ENDIF


!IF "$(CFG)" == "Win32"

OUTDIR=. elease
INTDIR=. elease
IntDir=$(INTDIR)

TargetPath=$(OUTDIR)mytest.exe

ALL : "$(OUTDIR)mytest.exe"

CLEAN :
-@erase "$(INTDIR)*.obj"
-@erase "$(INTDIR)*.mod"
-@erase "$(INTDIR)*.pdb"
-@erase "$(INTDIR)*.asm"
-@erase "$(INTDIR)*.map"
-@erase "$(INTDIR)*.dyn"
-@erase "$(INTDIR)*.dpi"
-@erase "$(INTDIR)*.tmp"
-@erase "$(INTDIR)*.log"
-@erase "$(INTDIR)*.ilk"
-@erase "$(INTDIR)*.exe"
-@erase "$(TargetPath)"

!IF "$(OUTDIR)" == "$(INTDIR)"

"$(INTDIR)" :
if not exist "$(INTDIR)/" mkdir "$(INTDIR)"

< P>
!ENDIF

!IF "$(OUTDIR)" != "$(INTDIR)"

"$(OUTDIR)" :
if not exist "$(OUTDIR)/" mkdir "$(OUTDIR)"


"$(INTDIR)" :
if not exist "$(INTDIR)/" mkdir "$(INTDIR)"


!ENDIF
F90=ifort.exe

F90_PROJ=-nologo -fpp -define:"COMPILER_IVF" -undefine:"COMPILER_DVF" -Op -fpconstant -iface:cvf -module:"$(INTDIR)/" -object:"$(INTDIR)/" -traceback -libs:static -threads -c


LINK=link.exe
LINK_FLAGS=-MACHINE:I386 -OUT:"$(OUTDIR)mytest.exe" -INCREMENTAL:NO -nologo -PDB:$(OUTDIR)mytest.pdb


!ENDIF


!IF "$(CFG)" == "Win64"

OUTDIR=.Release-Win64
INTDIR=.Release-Win64
IntDir=$(INTDIR)

TargetPath=$(OUTDIR)mytest.exe

ALL : "$(OUTDIR)mytest.exe"

CLEAN :
-@erase "$(INTDIR)*.obj"
-@erase "$(INTDIR)*.mod"
-@erase "$(INTDIR)*.pdb"
-@erase "$(INTDIR)*.asm"
-@erase "$(INTDIR)*.map"
-@erase "$(INTDIR)*.dyn"
-@erase "$(INTDIR)*.dpi"
-@erase "$(INTDIR)*.tmp"
-@erase "$(INTDIR)*.log"
-@erase "$(INTDIR)*.ilk"
-@erase "$(INTDIR)*.exe"
-@erase "$(TargetPath)"

!IF "$(OUTDIR)" == "$(INTDIR)"

"$(INTDIR)" :
if not exist "$(INTDIR)/" mkdir "$(INTDIR)"


!ENDIF

!IF "$(OUTDIR)" != "$(INTDIR)"

"$(OUTDIR)" :
if not exist "$(OUTDIR)/" mkdir "$(OUTDIR)"


"$(INTDIR)" :
if not exist "$(INTDIR)/" mkdir "$(INTDIR)"


!ENDIF
F90=ifort.exe

F90_PROJ=-nologo -fpp -define:"COMPILER_IVF" -define:"_WIN64" -undefine:"COMPILER_DVF" -Op -fpconstant -iface:cvf -module:"$(INTDIR)/" -object:"$(INTDIR)/" -traceback -libs:static -threads -c


LINK=link.exe
LINK_FLAGS= -OUT:"$(OUTDIR)mytest.exe" -INCREMENTAL:NO -nologo -PDB:$(OUTDIR)mytest.pdb


!ENDIF

OBJS =
"$(INTDIR)mydata.obj"
"$(INTDIR)mymain.obj"


#------------------------------

$(TargetPath) : "$(OUTDIR)" $(OBJS)
$(LINK) @<<
$(LINK_FLAGS) $(OBJS)
<<

"$(INTDIR)mydata.obj" : sourcemydata.for "$(INTDIR)"
$(F90) $(F90_PROJ) sourcemydata.for

"$(INTDIR)mymain.obj" : sourcemymain.for "$(INTDIR)"
$(F90) $(F90_PROJ) sourcemymain.for

---------------------------

Peng

0 Kudos
7 Replies
Steven_L_Intel1
Employee
795 Views

I can't reproduce this. At first I thought it was a known bug relating to module variables, but you aren't using those. What is the exact version of the compiler you are using? What is the output of:

link -dump -symbols mydata.obj
link -dump -symbols mymain.obj

?

Do you have a log showing the full compiler command used for both compiles? Since you are using /iface:cvf, I would expect the references to have @8 at the end.

0 Kudos
phu_intel
Beginner
795 Views

Steve,

Thanks for your reply. My inter fortran compiler is version 9.1.024(for both IA32 and EM64T). I actually can reproduce the error for version 9.0.030 for EM64T.

Did you try ' nmake /f Makefile.win CFG="Win64" ' under DOS build enviroment for EM64T? That's how I got the error.

With the "link -dump -symbols filename.obj", I got

for mymain.obj:

-----------------------

Microsoft COFF/PE Dumper Version 8.00.40310.39
Copyright (C) Microsoft Corporation. All rights reserved.


Dump of file Release-Win64mymain.obj

File Type: COFF OBJECT

COFF SYMBOL TABLE
000 00000000 DEBUG notype Filename | .file
sourcemymain.for
002 00000000 SECT1 notype Static | .drectve
Section length 15A, #relocs 0, #linenums 0, checksum 0
004 00000000 SECT2 notype Static | .text
Section length 50, #relocs 7, #linenums 0, checksum 0
006 00000000 SECT2 notype () External | MAIN__
007 00000000 UNDEF notype () External | __intel_new_proc_init
008 00000000 SECT3 notype Static | .rdata
Section length 8, #relocs 0, #linenums 0, checksum 0
00A 00000000 UNDEF notype () External | for_set_reentrancy
00B 00000000 SECT4 notype Static | .bss
Section length 4, #relocs 0, #linenums 0, checksum 0
00D 00000000 UNDEF notype () External | MYDATA_mp_SETMYDATA
00E 00000000 UNDEF notype () External | MYDATA_mp_GETMYDATA
00F 00000000 SECT5 notype Static | .xdata
Section length C, #relocs 0, #linenums 0, checksum 0
011 00000000 SECT5 notype Static | $unwind$MAIN__
012 00000000 SECT6 notype Static | .pdata
Section length C, #relocs 3, #linenums 0, checksum 0
014 00000000 SECT6 notype Static | $pdata$MAIN__
015 00000000 SECT4 notype Static | MYMAIN$TEST1.0.0
016 000000 00 SECT3 notype Static | LITPACK_0.0.0
017 00000000 SECT7 notype Static | .debug$S
Section length A0, #relocs 0, #linenums 0, checksum 0
019 00000000 SECT8 notype Static | .trace
Section length 80, #relocs 2, #linenums 0, checksum 0

String Table Size = 0x91 bytes

Summary

4 .bss
A0 .debug$S
15A .drectve
C .pdata
8 .rdata
50 .text
80 .trace
C .xdata

-----------------------------------

For mydata.obj:

---------------------------------

Microsoft COFF/PE Dumper Version 8.00.40310.39
Copyright (C) Microsoft Corporation. All rights reserved.


Dump of file Release-Win64mydata.obj

File Type: COFF OBJECT

COFF SYMBOL TABLE
000 00000000 DEBUG notype Filename | .file
sourcemydata.for
002 00000000 SECT1 notype Static | .drectve
Section length 15A, #relocs 0, #linenums 0, checksum 0
004 00000000 SECT2 notype Static | .text
Section length 28, #relocs 0, #linenums 0, checksum 0
006 00000000 SECT2 notype () External | MYDATA
007 00000000 SECT3 notype Static | .xdata
Section length 18, #relocs 0, #linenums 0, checksum 0
009 00000000 SECT3 notype Static | $unwind$MYDATA
00A 00000000 SECT4 notype Static | .pdata
Section length 24, #relocs 9, #linenums 0, checksum 0
00C 00000000 SECT4 notype Static | $pdata$MYDATA
00D 00000000 SECT5 notype Static | .debug$S
Section length A0, #relocs 0, #linenums 0, checksum 0
00F 0000000A SECT2 notype () External | MYDATA_mp_SETMYDATA
010 00000008 SECT3 notype Static | $unwind$MYDATA_mp_SETMYDATA
011 0000000C SECT4 notype Static | $pdata$MYDATA_mp_SETMYDATA
012 00000018 SECT2 notype () External | MYDATA_mp_GETMYDATA
013 00000010 SECT3 notype Static | $unwind$MYDATA_mp_GETMYDATA
014 00000018 SECT4 notype Static | $pdata$MYDATA_mp_GETMYDATA
015 00000000 SECT6 notype Static | .trace
Section length D8, #relocs 4, #linenums 0, checksum 0

String Table Size = 0xCF bytes

Summary

A0 .debug$S
15A .drectve
24 .pdata
28 .text
D8 .trace
18 .xdata

-----------------------------------------

I don't have log file for the compliation. However, here are what I got on screen on DOS enviroment.

For IA32:

---------------------

C:>nmake /f Makefile.win CFG="Win32"

Microsoft Program Maintenance Utility Version 7.10.3077
Copyright (C) Microsoft Corporation. All rights reserved.

ifort.exe -logo -fpp -define:"COMPILER_IVF" -undefine:"COMPILER_DVF" -Op
-fpconstant -iface:cvf -module:". elease/" -object:". elease/" -traceback -li
bs:static -threads -c sourcemydata.for
Intel Fortran Compiler for 32-bit applications, Version 9.1 Build 20060323
Z Package ID: W_FC_P_9.1.024
Copyright (C) 1985-2006 Intel Corporation. All rights reserved.

ifort.exe -logo -fpp -define:"COMPILER_IVF" -undefine:"COMPILER_DVF" -Op
-fpconstant -iface:cvf -module:". elease/" -object:". elease/" -traceback -li
bs:static -threads -c sourcemymain.for
Intel Fortran Compiler for 32-bit applications, Version 9.1 Build 20060323
Z Package ID: W_FC_P_9.1.024
Copyright (C) 1985-2006 Intel Corporation. All rights reserved.

link.exe @C:DOCUME~1meLOCALS~1Temp m6ED5.tmp

--------------------------------

For EM64T:

---------------------------------

C:>nmake /f Makefile.win CFG="Win64"

Microsoft Program Maintenance Utility Version 7.00.8882
Copyright (C) Microsoft Corp 1988-2000. All rights reserved.

&nb sp; ifort.exe -logo -fpp -define:"COMPILER_IVF" -define:"_WIN64" -undefine:"
COMPILER_DVF" -Op -fpconstant -iface:cvf -module:".Release-Win64/" -object:".R
elease-Win64/" -traceback -libs:static -threads -c sourcemydata.for
Intel Fortran Compiler for Intel EM64T-based applications, Version 9.1
Build 20060324
Copyright (C) 1985-2006 Intel Corporation. All rights reserved.

ifort.exe -logo -fpp -define:"COMPILER_IVF" -define:"_WIN64" -undefine:"
COMPILER_DVF" -Op -fpconstant -iface:cvf -module:".Release-Win64/" -object:".R
elease-Win64/" -traceback -libs:static -threads -c sourcemymain.for
Intel Fortran Compiler for Intel EM64T-based applications, Version 9.1
Build 20060324
Copyright (C) 1985-2006 Intel Corporation. All rights reserved.

link.exe @C:DOCUME~1meLOCALS~1Temp m6EDB.tmp
mymain.obj : error LNK2019: unresolved external symbol MYDATA_mp_SETMYDATA refer
enced in function MAIN__
mymain.obj : error LNK2019: unresolved external symbol MYDATA_mp_GETMYDATA refer
enced in function MAIN__
.Release-Win64mytest.exe : fatal error LNK1120: 2 unresolved externals
NMAKE : fatal error U1077: 'link.exe' : return code '0x460'
Stop.

----------------------------

Hope this is the log file you mentioned.

Can you see what's the problem?

Thanks!

Peng

0 Kudos
Steven_L_Intel1
Employee
795 Views

I don't spot anything obviously wrong in what you posted, but it works fine for me in 9.1.037:

F:MyProjectsmymain>nmake /f Makefile.win CFG="Win64"
Microsoft  Program Maintenance Utility Version 8.00.50727.762
Copyright (C) Microsoft Corporation. All rights reserved.
 ifort.exe -nologo -fpp -define:"COMPILER_IVF" -define:"_WIN64" -undefine
:"COMPILER_DVF" -Op -fpconstant -iface:cvf -module:".Release-Win64/" -object:".
Release-Win64/" -traceback -libs:static -threads -c sourcemydata.for
ifort.exe -nologo -fpp -define:"COMPILER_IVF" -define:"_WIN64" -undefine
:"COMPILER_DVF" -Op -fpconstant -iface:cvf -module:".Release-Win64/" -object:".
Release-Win64/" -traceback -libs:static -threads -c sourcemymain.for
link.exe @C:DOCUME~1sblionelLOCALS~1Temp m336.tmp
F:MyProjectsmymain>

Forget what I said about the @n - that doesn't apply to EM64T.

0 Kudos
phu_intel
Beginner
795 Views

It is strange. I will try to install the lastest one (9.1.037) and have a try then.

Thanks!

Peng

0 Kudos
phu_intel
Beginner
795 Views

Steve,

Just installed and tried with 9.1.037 on my pc. It works fine. Dose any bug fixed related to modulefor EM64T recently?

Thanks for the help!

Peng

0 Kudos
Steven_L_Intel1
Employee
795 Views
Not that I can think of, but there may have been. There is a problem relating to module variables (not routines) in that the compiler incorrectly adds a leading underscore in some contexts but not in others, which can lead to linking errors. This is fixed in 10.0 (not yet released) where the leading underscore is always omitted, but a switch is offered to get the old behavior. The release notes will describe this.
0 Kudos
phu_intel
Beginner
795 Views

OK. Then v10 is something we are expecting. Thanks!

Peng

0 Kudos
Reply