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

Linker error with internal procedure definitions

MDK
Beginner
762 Views
[plain]!===== file: testa_mod.f90 =====!

module testa

contains

function testa_func
integer :: testa_func
contains
subroutine internal_sub
testa_func = 2
end subroutine
end function

end module


!===== file: testb_mod.f90 =====!

module testb

contains

function testb_func
integer :: testb_func
contains
subroutine internal_sub
testb_func = 2
end subroutine
end function

end module


!===== file: testc_mod.f90 =====!

module testc

contains

function testc_func
integer :: testc_func
contains
subroutine internal_sub
testc_func = 2
end subroutine
end function

end module


!===== file: main.f90 =====!

program main

use testa
use testb
use testc

end program

[/plain]

I'm getting a linker error for multiple definitions (LNK1169), and I'm not sure if it's my fault or the compiler/linker. I haven't been able to pare my code down to a reproducible example, but the sample above shows the gist of what I'm doing. I have multiple modules in separate files. Each module has a function that happens to have an internal procedure of the same name. It's my understanding that internal procedures only have local scope, so I don't think this should be a problem. The linker disagrees:

error LNK2005: INTERNAL_SUB$BLK..T403_ already defined in testa_mod.obj file:testb_mod.obj
fatal error LNK1169: one or more multiply defined symbols found file: main.exe

If I remove 'testa' from the compilation there is no error, even though 'testb' and 'testc' also have internal procedures with the same name. The fix for this problem is trivial, so I'm just wondering if I'm in the wrong.
0 Kudos
2 Replies
Steven_L_Intel1
Employee
762 Views
Which exact compiler version are you using? This sounds like a problem we fixed some time ago. I can't reproduce it in 11.1.054.
0 Kudos
MDK
Beginner
762 Views
Which exact compiler version are you using? This sounds like a problem we fixed some time ago. I can't reproduce it in 11.1.054.

This is with 11.1.054. The code I posted does not reproduce the problem. I haven't been able to pare down my actual code to a simple test case, and I wasn't entirely sure what I was doing was allowed in the first place. Now that I kow it might be a bug I'll try to reproduce it.
0 Kudos
Reply