我在我的解決方案中有兩個項目:CPart
和FortranPart
。 FortranPart
取決於CPart
,後者包含main
函數。這裏的main.c
試圖從Visual C中調用英特爾Visual Fortran函數
#include <stdio.h>
extern int __stdcall FORTRAN_ADD(int *A, int *B);
int main()
{
int a = 3;
int b = 4;
int c = FORTRAN_ADD(&a, &b);
printf("%i\n", c);
return 0;
}
代碼這裏是我的FORTRAN模塊
module FORTRAN_UTILS
implicit none
contains
integer*4 function fortran_add(a, b) result(c)
implicit none
integer*4, intent(in) :: a, b
c = a + b
end function fortran_add
end module FORTRAN_UTILS
的代碼後,FORTRAN編譯我得到的文件FortranPart.lib
。在CPart
項目依賴項中,我將它添加爲外部庫。當我嘗試編譯並運行CPart
時,我得到以下內容
Error LNK2019 unresolved external symbol [email protected] referenced in function _main CPart c:\Users\sasha\documents\visual studio 2015\Projects\MSCourse\MSCourse\main.obj 1
P.S. 我需要主程序在C中,而不是C++。
真的有很多很多很多的問題,在這裏對這個問題的答案。你有沒有嘗試閱讀一些?你爲什麼使用'__stdcall FORTRAN_ADD'?爲什麼stdcall呢?爲什麼大寫字母?你編譯32位或64位?哪個編譯器版本? –