Linking error in Linux for polymorphic-class pointer allocation

Linking error in Linux for polymorphic-class pointer allocation

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

6 帖子 / 0 全新
最新文章
如需更全面地了解编译器优化,请参阅优化注意事项

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
 

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
 

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.

Steve - Intel Developer Support

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

Glad to hear it.

Steve - Intel Developer Support

发表评论

登录添加评论。还不是成员?立即加入