Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28994 Discussions

Problem Linking Intel Fortran and Intel C++

frank_m1
Beginner
564 Views

I'm having linking errors trying to call a fortran subroutine from a c++ procedure. The MKL is called from procedures in the C++ part of the program and in the Fortran subroutine. The errors are all of this type.

LIBCMTD.lib(dbgheap.obj) : error LNK2005: __CrtSetCheckCount already defined in MSVCRTD.lib(MSVCR90D.dll)

Theres one for each conflict between MSVCRTD.lib and MSVCR90D.dll
My suspicionis is I'vegot something configured wrong. (but I'll inlcude the code just in case. sorry if it clutters the board.)

I've tried setting Ignore All Default Libaries to Yes/(NODEFAULTLIB). The linker died on every call to new or Delete [] andall overmlk_core.lib.

The fortran subroutine is:

INCLUDE 'mkl_dfti.f90'

SUBROUTINE FLOWPASS(BUFFER, BUFLEN)

USE MKL_DFTI
IMPLICIT NONE

INTEGER, INTENT(IN) ::BUFLEN
REAL(8), DIMENSION(BUFLEN), INTENT(INOUT) :: BUFFER
INTEGER STATUS
INTEGER ERR
REAL(8) SCALE
TYPE(DFTI_DESCRIPTOR), POINTER :: HAND
COMPLEX(8), ALLOCATABLE :: X_IN(:)
COMPLEX(8), ALLOCATABLE :: X_OUT(:)

ALLOCATE(X_IN(BUFLEN), STAT = ERR)
ALLOCATE(X_OUT(BUFLEN),STAT = ERR)

X_IN = DCMPLX(BUFFER,0.0)

STATUS = DftiCreateDescriptor(HAND, DFTI_DOUBLE, &
DFTI_COMPLEX, 1, BUFLEN)

STATUS = DftiSetValue(HAND, DFTI_PLACEMENT, &
DFTI_NOT_INPLACE)

STATUS = DftiCommitDescriptor(HAND)

STATUS = DftiComputeForward(HAND, X_IN, X_OUT)

! HEREGOES FILTER

SCALE = 1.0/REAL(BUFLEN, KIND=8)
Status = DftiSetValue(HAND, DFTI_BACKWARD_SCALE, SCALE)

STATUS = DftiCommitDescriptor(HAND)

STATUS = DftiComputeBackward(HAND, X_OUT, X_IN)

BUFFER = DREAL(X_IN)

Status = DftiFreeDescriptor(HAND)

DEALLOCATE(X_IN)
DEALLOCATE(X_OUT)

RETURN
END

Defined Here:

#ifdef __cplusplus
extern "C"
#endif

void FLOWPASS(double* ppad_data, int& padlen);



Called from here:

#include "mathimf.h"
#include "uni_transformations.h"
#include "utility_procs.h"


void iuni_low_pass(double* pdata, int datalen, int lag, double* plp_ave)
{
double* pdt_data;
pdt_data = new double[datalen];

int padlen = 2 * lag + datalen;
double* ppad_data;
ppad_data = new double[padlen];

iuni_linear_detrend(pdata, datalen, pdt_data);

iuni_assign(ppad_data, 0.0, lag);
iuni_copy(pdt_data, ppad_data+lag, datalen);
iuni_assign(ppad_data+lag+datalen, 0.0, lag);


FLOWPASS(ppad_data, padlen);


iuni_copy(ppad_data, plp_ave, padlen);

delete [] pdt_data;
delete [] ppad_data;
pdt_data = 0;
ppad_data = 0;

}

Any helpwill be appreciated, even its just sending me to another board.

0 Kudos
1 Solution
Steven_L_Intel1
Employee
564 Views
Remove all of the libraries you added tp NODEFAULTLIB. C++ defaults to Multithreaded [Debug] DLL and Fortran defaults to Multithreaded [Debug] (static library). You need to make these consistent. Probably easiest to change Fortran > Libraries > Runtime Library to Multithreaded [Debug] DLL. I put Debug in brackets because for the Release configuration you would not specify the debug libraries.

Try that and see where it gets you. Be sure you have read Configuring for Mixed-Language Applications.

View solution in original post

0 Kudos
2 Replies
Steven_L_Intel1
Employee
565 Views
Remove all of the libraries you added tp NODEFAULTLIB. C++ defaults to Multithreaded [Debug] DLL and Fortran defaults to Multithreaded [Debug] (static library). You need to make these consistent. Probably easiest to change Fortran > Libraries > Runtime Library to Multithreaded [Debug] DLL. I put Debug in brackets because for the Release configuration you would not specify the debug libraries.

Try that and see where it gets you. Be sure you have read Configuring for Mixed-Language Applications.
0 Kudos
frank_m1
Beginner
564 Views

That fixed it. Thank you.

0 Kudos
Reply