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

error LNK2019: Why I can not use "function" in my module?

lyricx
Beginner
260 Views

I am using Intel(R) Visual Fortran Composer XE 2011 Integration for Microsoft Visual Studio* 2010,   In my fortran code, the encountered problem is that I can not use "function" in my module, currently I just change the "function" to "subroutine" to simply abviate this problem.

When I use function in my code, I always meet with the error " error LNK2019 ".

Can anyone tell me how to resolve this problem? Thank you very much!

For the attached file, I can't compile successfully.

lyricx

0 Kudos
1 Reply
mecej4
Honored Contributor III
260 Views
Your description of the problem is rather vague, but here is what I guess to be the problem. You declare a function in one module, and invoke that function in a different subprogram which does not have a USE ... statement for the first module. Functions declared in a module receive name decorations, which explains the linker error that is issued when the invocation uses the undecorated name of the function. Rather than taking the trouble to learn and use the decoration scheme, you will do better if you employ an appropriate USE statement.
0 Kudos
Reply