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

Linking error in Linux for polymorphic-class pointer allocation

Eric_U_
Beginner
937 Views

Hi all,

I am having issues with the linking step for my program using ifort in ComposerXE 2013 (SP1) under Red Hat Linux.  The issue occurs when I try to do something like this:

    class(my_abstract_class), pointer :: ptr

​    type(my_subclass) :: obj ! where my_subclass extends my_abstract_class

    allocate(ptr, source = obj)  !<-- linker complains that there is an undefined reference to "for allocate"

I made sure to source "<ComposerXE Directory>/compilervars.csh intel64"

Are there any additional directories that may have not been included in my library path? Is this a known compiler issue with the linux version of ifort? The release notes for 2013 seem to indicate that this feature of fortran 2003 has been enabled

Thanks,
-Eric Uthoff

0 Kudos
5 Replies
Eric_U_
Beginner
937 Views

Actually, I want to make clear, this isn't restricted to pointers but also to polymorphic with the "allocatable" keyword, for instance:
    type(my_abstract_class), allocatable :: abs_obj


​-Eric
 

0 Kudos
Eric_U_
Beginner
937 Views

Actually, I want to make clear, this isn't restricted to pointers but also to polymorphic variables with the "allocatable" keyword, for instance:
    type(my_abstract_class), allocatable :: abs_obj


​-Eric
 

0 Kudos
Steven_L_Intel1
Employee
937 Views

Please show a log of your build session including the command used for linking and the exact and complete error message. You have something fundamentally wrong in your build process.

0 Kudos
Eric_U_
Beginner
937 Views

Hey Steve,

Your comment got me to take another look at the link command and I found the issue. 

In case you're curious:

I had included a folder in my link command (via -L <my_folder>) which I though contained some third party libraries that my program uses.  I was not aware that it also contained copies of some ifort libraries from ifort v.10, (e.g. Libifcoremt, Libintlc and others). Since they were higher up in priority, these old versions of the libraries were being linked instead of the current version. Shockingly, until I started using some of the more advanced FORTRAN 2003 features, this was actually worked just fine and has remained undetected for months! Looks like this was just a bone-headed mistake (possibly by me). 

Thanks for your time Steve!

-Eric

0 Kudos
Steven_L_Intel1
Employee
937 Views

Glad to hear it.

0 Kudos
Reply