- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Hello,
i need to distribute a fortran dll which is going to be called from a native c program. It is compiled by The Command line compiler of Visual Studio Version 15.
Linking a Fortran dll in a "normal" Visual Studio c-Projekt works fine.
But when I try to link the *.lib in the Command line compiler, I always get error LNK1120: 1 unresolved symbols.
I use the Fortran Compiler Intel Visual Fortran Composer XE 2013.
Here is what I have:
Fortran function:
DOUBLE PRECISION FUNCTION ADDITION(A,B)
!DEC$ ATTRIBUTES DLLEXPORT:: ADDITION
USE ISO_C_BINDING
REAL (KIND = C_DOUBLE) :: A,B
ADDITION = A+B
END
The c program test.c:
#include <windows.h>
#include <stdio.h>
#include <string.h>
extern double ADDITION(double a,double b);
int main ()
{
char enter = 0;
double result = ADDITION(1, 2);
printf("The result is: %f\n", result);
printf("Press enter to continue\n");
while (enter != '\r' && enter != '\n') { enter = getchar(); }
printf("Thank you for pressing enter\n");
return 0;
}
The command lines for the Compiler:
cl test.c fortran_code.lib
The fortran_code.dll and the fortran_code.lib are in the same folder than test.c. So that should be ok.
Any ideas what I made wrong? Thank you.
- Marcas:
- Intel® Fortran Compiler
Link copiado
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Hello,
I replaced the c-Function ADDITION with _ADDITTION
Now i get the following error:
/out:test.exe
test.obj
fortran_code.lib
fortran_code.lib(fortran_code.dll): fatal error LNK1112: Modul Computertype "x86" conflicts with the target type "x64"
Switching the MIDL-Switches for Target Environment from x86 to x64 in my fortran project don't work either. Any ideas?
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
********* ALREADY SOLVED THE PROBLEM :) Thanks anyway
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Perhaps this was your solution, but you needed the BIND(C, NAME='ADDITION') suffix in the FUNCTION statement in the fortran. The binding label given by the NAME specifier needs to match (case sensitive) the name you use for the fortran procedure in the C code (no need for additional leading or trailing underscores, etc)..

- 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