我有一个必须调用Clipper库的Fortran代码,我已经下载并编译了原始的C ++源代码。我用C ++编写了一个包装子程序,内容如下:
extern "C" void wrapUNIintersNM(
int Ndry[1],
double xclip[5],
double yclip[5],
double POLYStoBEjoinedX[13][100],
double POLYStoBEjoinedY[13][100],
int NPOLYtoBEjoined[1],
int VERTtoBEjoined[13],
double POLYSunionX[13][100],
double POLYSunionY[13][100],
int NPOLYSunion[1],
int VERTunion[13],
double POLYintersX[13][100],
double POLYintersY[13][100],
int NPOLYSinters[1],
int VERTinters[13],
double absMAXx[1],
double absMAXy[1])
{
............
............
}
我为绑定创建了一个模块:
module Cplusplus
use,intrinsic :: ISO_C_Binding
interface
subroutine wrapUNIintersNM(Ndry,xclip,yclip,&
POLYStoBEjoinedX,POLYStoBEjoinedY,NPOLYStoBEjoined,VERTtoBEjoined,&
POLYSunionX,POLYSunionY,NPOLYSunion,VERTunion, &
POLYintersX,POLYintersY,NPOLYSinters,VERTinters,&
absMAXx,absMAXy) bind(C,name="wrapUNIintersNM") ! bind(C,name="wrapperClipper") add name if you wanna retain uppercase letter, otherwise are all made lowercase and C++ is case sensitive
import :: c_double, c_int
real(kind=c_double), dimension(5) :: xclip,yclip
real(kind=c_double), dimension(100,13) :: POLYintersX,POLYintersY,POLYStoBEjoinedX,POLYStoBEjoinedY,&
POLYSunionX,POLYSunionY
real(kind=c_double) :: absMAXx(1),absMAXy(1)
integer(kind=c_int), dimension(13) :: VERTinters,VERTunion,VERTtoBEjoined
integer(kind=c_int) :: Ndry,NPOLYStoBEjoined,NPOLYSinters,NPOLYSunion
end subroutine
end interface
end module Cplusplus
我有一个子程序更新,以这种方式调用wrapUNIintersNM
subroutine update
use Cplusplus
.........
...........
CALL wrapUNIintersNM(Ndry,xclip,yclip, &
POLYStoBEjoinedX,POLYStoBEjoinedY,NPOLYStoBEjoined,VERTtoBEjoined,& !polygons to join (union)
POLYSunionX,POLYSunionY,NPOLYSunion,VERTunion, & !union of polygons
POLYintersX,POLYintersY,NPOLYSinters,VERTinters,& !intersection of union
absMAXx,absMAXy)
..........
...........
return
end
一切都很好,但在链接阶段我得到这个错误:
error LNK1120: 1 unresolved externals example.dll
error LNK2019: unresolved external symbol _wrapUNIintersNM referenced in function _UPDATE
有什么建议吗? 感谢