------------------------------file:a.cpp-------------
#include <iostream.h>
#include <math.h>
extern "C"
{
void _stdcall TESTA(int *);
}
void main()
{
double a = sin(1.00);
cout<<"a="<<a;
int ii=1;
TESTA(&ii);
}
------------------------------file:b.f-------------
SUBROUTINE TESTA(IA)
WRITE(*,*) "IA=", IA
RETURN
END
编译提示错误:
Linking...
dfor.lib(matherr.obj) : error LNK2005: __matherr already defined in LIBCD.lib(matherr.obj)
LINK : warning LNK4098: defaultlib "libc.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
Debug/StaggeredGrid.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
经过分析发现是因为在main函数里面调用了sin数学函数,解决的方法是添加文件头:
#pragma comment (lib, "dfor")