- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
- Marcas:
- Intel® Fortran Compiler
Link copiado
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Do you have a C++ main program functioncalling a Fortran DLL function?
Or a C++ DLL functioncalling a Fortran DLL function? More details please.
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
I hope the following will help you with your enquiry.
I attach a C++ main program (hello.cpp + stdafx.cpp and stdafx.h) which calls a C++ function 'Displaymessage'with two string objectarguments and two length arguments and whichpassses character strings and length arguments toan equivalent Fortran function (FORTDISPLAYMESSAGE) which is the only entry in a Fortran DLL. I use Compaq Visual Fortran and include the workspace in the Zip file. The Fortran is in the file 'STRINGS.F90' so you can create your own IVF solution.
When the Fortran DLL is created (I started with the debug version, with 'Debug single threaded DLL' specified under
the Project Settings...Fortran..Libraries tab), it produces the 'STRING.DLL' and its export/import library 'STRING.LIB'.
The import library 'STRING.LIB' must then be added to your C++ project/solution along with the C++ files included in the zip file andthe C++must be compiled in 'debug' configuration with matching debug librariesif the Fortran wasbuilt as a debug configuration. That is, both C++ and Fortran projects must agree inconfiguration and matching libraries (I think!). When compiled, the C++ project will create the executable 'hello.exe'. The 'STRING.DLL' file must be copied to the folder where the C++ .EXE file is created so that it can be found when the C++ program is executed.
When the C++ program is run, it outputs to a console window whereas I haveallowed the Fortran function to issue Message boxes, both displayed in the attached screenshot.pdf, to show that the character strings were successfully passed to and from the Fortran DLL.
I hope this helps.
- Subscrever fonte RSS
- Marcar tópico como novo
- Marcar tópico como lido
- Flutuar este Tópico para o utilizador atual
- Marcador
- Subscrever
- Página amigável para impressora