"multiply defined symbols": same sub name in different modules

"multiply defined symbols": same sub name in different modules

I am getting this error:

modD.obj : error LNK2005: vfe$0001INNER_SUB$BLK already defined in modC.objmodD.obj : error LNK2005: vfe$0000INNER_SUB$BLK already defined in modC.objDebug/module_namespace_conflict.exe : fatal error LNK1169: one or more multiply defined symbols found

This is because i have identically named inner code blocks in two modules:

module m_C
    contains
    
    subroutine the_sub()
        integer(4)::int_a,int_b
        
        call inner_sub()
                
        contains
                            
            subroutine inner_sub()
                write(*,'(i)') int_b                
            end subroutine
            
    end subroutine
            
end module


module m_D
    contains
    
    subroutine the_sub()
        integer(4)::int_a,int_b
        
        call inner_sub()
                
        contains
                            
            subroutine inner_sub()
                write(*,'(i)') int_b                
            end subroutine
            
    end subroutine
            
end module



program main
end program 

I haven't looked it up in the standard but shouldn't this be allowed?

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Please report the contents of the files used in the compilation faithfully. If the code that you showed is put into one file and compiled, no error occurs. The linker output that you listed indicates that two object files were given to the linker. What do you have in files modC.f90 and modD.f90?

I do note that with Ifort 11.1 the VFE produces global symbols in the .OBJ file, but with 12.1 the VFE produces local symbols. Thus, if the same VFE were to be seen in two or more source files, multiple definitions would occur with version 11.1 but not with 12.1.

Indeed, module m_C is in modC.f90 and module m_D is in modD.f90. The program block is in a separate source file.My compiler version is 12.0.1.127, and my license may not entitle me to any more updates. If so I'll just work around the problem.

1. VFEs are an extension, so you won't find anything in the standard on this.
2. Yes, it should work. It does work in 12.1 (Composer XE 2011 Update 6)

Steve - Intel Developer Support

Leave a Comment

Please sign in to add a comment. Not a member? Join today