- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Hello
This question was probably asked more than once, sorry. I could not find a solution of my problem.
MS VS 2008 + IFC 11.0
*******************FORTRAN*******************
Subroutine F
!DEC$ ATTRIBUTES DLLEXPORT::F,/abc/
!DEC$ ATTRIBUTES ALIAS: '_F@0' :: F
!DEC$ ATTRIBUTES ALIAS: '_abc' :: /abc/
real*8 a
common /abc/ a
write(*,*) "Test!"
write(*,*) a
end
****************c++**************************
#include
#pragma comment(lib,"fdll.lib")
using namespace std;
struct variables { double a; };
extern "C" {
extern struct variables abc;
void __stdcall F(); };
int main()
{
abc.a=1.0;
F();
return 0;
}
I tried '_abc' :: / abc /, '/ _abc /' :: / abc /, '_abc' :: abc - the result is the same.
I tried to use the BIND () - leads to the same error.
Please tell me what is my mistake?
Best regards.
This question was probably asked more than once, sorry. I could not find a solution of my problem.
MS VS 2008 + IFC 11.0
*******************FORTRAN*******************
Subroutine F
!DEC$ ATTRIBUTES DLLEXPORT::F,/abc/
!DEC$ ATTRIBUTES ALIAS: '_F@0' :: F
!DEC$ ATTRIBUTES ALIAS: '_abc' :: /abc/
real*8 a
common /abc/ a
write(*,*) "Test!"
write(*,*) a
end
****************c++**************************
#include
#pragma comment(lib,"fdll.lib")
using namespace std;
struct variables { double a; };
extern "C" {
extern struct variables abc;
void __stdcall F(); };
int main()
{
abc.a=1.0;
F();
return 0;
}
**********************************************
Error "Undefined symbol _abc".
I think that the error in! DEC $ ATTRIBUTES ALIAS: '_abc' :: / abc /I tried '_abc' :: / abc /, '/ _abc /' :: / abc /, '_abc' :: abc - the result is the same.
I tried to use the BIND () - leads to the same error.
Please tell me what is my mistake?
Best regards.
- Marcas:
- Intel® Fortran Compiler
Link copiado
4 Respostas
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
You missed __declspec(dllimport) on the struct, like so:
extern __declspec(dllimport) struct variables abc;
Also, you should remove the __stdcall from the C++ and remove !DEC$ ATTRIBUTES ALIAS: '_F@0' :: F. If you ever think you need an alias with @n on the end, you're doing it wrong.
I would recommend using module variables and the standard C interoperability features instead of COMMON.
extern __declspec(dllimport) struct variables abc;
Also, you should remove the __stdcall from the C++ and remove !DEC$ ATTRIBUTES ALIAS: '_F@0' :: F. If you ever think you need an alias with @n on the end, you're doing it wrong.
I would recommend using module variables and the standard C interoperability features instead of COMMON.
- 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
my question was stupid? :)
For some reason, nowhere in the articles "mix fortran and c++" I did't see mention of "extern __ declspec (dllimport) struct variables abc;" and BIND()
it worked, thanks!
For some reason, nowhere in the articles "mix fortran and c++" I did't see mention of "extern __ declspec (dllimport) struct variables abc;" and BIND()
it worked, thanks!
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Discussion of DLL export and import isn't really related to mixed-language - it applies to same-language programming too. While you can get away without a "dllimport" directive/pragma for routines, you can't for data.

Responder
Opções do tópico
- 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