- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You may specify the appropriate Fortran library that contains the intrinsic functions to be used when linking.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have followed these instructions, but I still get this error. Any ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am completely new to Fortran, so it could easily be a programming issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page