- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
I just started using Intel Visual Fortran Compiler for Windows, and I am trying to set up a solution in Visual Studio 2010 that contains a Fortran Static Library project and a C++ project. I can access my Fortran subroutines and functions through the C++ project without any issues, but when I include any Fortran intrinsic functions in my Fortran code, I get a LNK2019 error.
For example, I created a Fortran function, FR,that calls the SQRT function. The Fortran project builds fine, but when I callFRin my C++ code, I get an error LNK2019: unresolved external symbol _SQRT referenced in function _FR. What do I need to include in my project so that I can use these functions?
Thanks for the help.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
FortranTest\FortranTest\test.f(11): warning #7319: This argument's data type is incompatible with this intrinsic procedure; procedure assumed EXTERNAL. [SQRT]
In subroutine FSROOT, you have a call to SQRT(N). N is not declared, so, by the rules of Fortran, it is implicitly INTEGER. (Variables starting with I through N are integer, all others are real. Hence the Fortran joke: "God is real, unless declared integer.")
SQRT is not defined for the integer type, so you get the warning. The compiler then assumes you mean some external routine SQRT which you didn't provide.
Assuming that you want to take the square root of the value of N, you will have to write it as:
FSROOT = SQRT(REAL(N))
The REAL() intrinsic converts the argument to the REAL datatype.
By the way, at least in this example, you don't need the ATTRIBUTES DLLEXPORT as you are building a static library. It does no harm.
링크가 복사됨
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
You may specify the appropriate Fortran library that contains the intrinsic functions to be used when linking.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
I have followed these instructions, but I still get this error. Any ideas?
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
error LNK2019: unresolved external symbol _SQRT referenced in function
error LNK1120: 1 unresolved externals
However, if I make a Fortran dynamic-link library, I receive these errors during the Fortran compilation instead of the C++ compilation.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
I am completely new to Fortran, so it could easily be a programming issue.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
FortranTest\FortranTest\test.f(11): warning #7319: This argument's data type is incompatible with this intrinsic procedure; procedure assumed EXTERNAL. [SQRT]
In subroutine FSROOT, you have a call to SQRT(N). N is not declared, so, by the rules of Fortran, it is implicitly INTEGER. (Variables starting with I through N are integer, all others are real. Hence the Fortran joke: "God is real, unless declared integer.")
SQRT is not defined for the integer type, so you get the warning. The compiler then assumes you mean some external routine SQRT which you didn't provide.
Assuming that you want to take the square root of the value of N, you will have to write it as:
FSROOT = SQRT(REAL(N))
The REAL() intrinsic converts the argument to the REAL datatype.
By the way, at least in this example, you don't need the ATTRIBUTES DLLEXPORT as you are building a static library. It does no harm.