- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to call fortran dll from c++. It works well for fortran subroutine without system command ("xxx.exe"). Currently the subroutine involves system command.
!ms$ if .not. defined(LINKDIRECT)
!ms$ attributes dllexport ::SUBFAN
!ms$ endif
...
call system("xxx.exe")
...
After building xx.dll and link with c++ project by adding xx.lib in linker input, it does not work. I have put xx.lib, xx.dll, xxx.exe in the working directory.
"unresolved external symbol _SUBFAN@60 referenced in function _main"
Will dll work in c++ if I have system (call system("xxx.exe")) inside the fortran subroutine?
Thank you
!ms$ if .not. defined(LINKDIRECT)
!ms$ attributes dllexport ::SUBFAN
!ms$ endif
...
call system("xxx.exe")
...
After building xx.dll and link with c++ project by adding xx.lib in linker input, it does not work. I have put xx.lib, xx.dll, xxx.exe in the working directory.
"unresolved external symbol _SUBFAN@60 referenced in function _main"
Will dll work in c++ if I have system (call system("xxx.exe")) inside the fortran subroutine?
Thank you
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm not certain of the answer, as there may be conflicts between Fortran system() and C system(). But, in order to give it a chance:
First, you should put USE IFPORT in your Fortran, and make your system call consistent with ifort implementation, as system isn't a Fortran standard until F2008, where it has a new name execute_command_line().
Then, assuming you use c++ to link your application, as you probably wish to do for a C++ main program, you will need also to link against specific Fortran libraries such as libifport and libifcore. Unless possibly you meet requirements to link the Fortran static libraries in the .dll.
First, you should put USE IFPORT in your Fortran, and make your system call consistent with ifort implementation, as system isn't a Fortran standard until F2008, where it has a new name execute_command_line().
Then, assuming you use c++ to link your application, as you probably wish to do for a C++ main program, you will need also to link against specific Fortran libraries such as libifport and libifcore. Unless possibly you meet requirements to link the Fortran static libraries in the .dll.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your comments. I made some print out on the screen when using c++ calling dll. It is said
xxx.exe is not recognized as an internal or external command, operable program or batch file during execution
xxx.exe is not recognized as an internal or external command, operable program or batch file during execution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much for your comments.
I made some printout when executing c++ with fortran dll. It is said
xxx.exe is not recognized as an internal or external command, operable program or batch file
I made some printout when executing c++ with fortran dll. It is said
xxx.exe is not recognized as an internal or external command, operable program or batch file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks. It works now. xxx.exe was confused about the path for the executable file.
![](/skins/images/C4F7392A5C68ACA60290C9576F107044/responsive_peak/images/icon_anonymous_message.png)
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