- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page