ATTRIBUTES ALIAS -- Causes Link error

ATTRIBUTES ALIAS -- Causes Link error

I pulled up the C_call_f project from the samples directory. It compiles, links and executes fine. Taking baby steps, I wanted to change the name of the calling routine in C++, and use the ALIAS attribute to let Fortran know. I get a link error from this.

This works:
!DEC$ IF DEFINED (_DLL)
!DEC$ ATTRIBUTES DLLEXPORT :: FSUB
!DEC$ END IF

This doesn't:
!DEC$ IF DEFINED (_DLL)
!DEC$ ATTRIBUTES DLLEXPORT :: FSUB
!DEC$ ATTRIBUTES ALIAS : 'NewName' :: FSUB
!DEC$ END IF
error LNK2001: unresolved external symbol __imp__FSUB@20

Is there a project setting that needs changing?

Tom

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

The link error suggests that you didn't change name on C++ side (you have to change both in .h and .cpp file) or perhaps forgot to recompile it.

But even then, you'll get LNK2001: unresolved external symbol __imp__NewName@20. You're ALIASing your routine in the way C compiler doesn't expect (i.e. you're not adding any decoration at all). If you alias it with _NewName@20, then it will work (underscore plus @ plus # of args*4). You can export and alias names as you wish, but you have to use .def files or dynamic binding. (search for .DEF files in Programmer's Guide). VC++ recognizes .def files as well.

Jugoslav

Jugoslav
www.xeffort.com

Leave a Comment

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