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

Module location

New Contributor II

I thought I knew all about modules, but now a very simple example fails, and I guess I must have forgotten something.

I started with a Visual Studio program.  I wanted to use a module that another program had created, but the compile fails with unresolved symbol error:

Error 1 error LNK2019: unresolved external symbol _MCMAHON_mp_READPARAMETERS referenced in function _MAIN__ cycler.obj

The module name is 'mcmahon', and I specified its location in Additional Include Directories.

I next tried a simple test program compiled at the command line, with the same result.

The module code is testmod.f90:

module test_mod
implicit none


subroutine adder(a,b,ab)
real :: a, b, ab

ab = a+b
end subroutine

end module

The main program is test.f90:

program main
use test_mod
implicit none

real :: a, b, absum
a = 1
b = 2
call adder(a,b,absum)
write(*,*) 'absum: ',absum
end program

If I compile with this, the build is successful:

ifort test.f90 testmod.f90

But if I first compile testmod.f90:

ifort -c testmod.f90

creating test_mod.mod, then try to compile test.f90 I get the same error as with Visual Studio:

D:\testing\fortran\module>ifort test.f90
Intel(R) Visual Fortran Compiler Professional for applications running on IA-32,
Version 11.0 Build 20090609 Package ID: w_cprof_p_11.0.075
Copyright (C) 1985-2009 Intel Corporation. All rights reserved.

Microsoft (R) Incremental Linker Version 8.00.50727.762
Copyright (C) Microsoft Corporation. All rights reserved.

test.obj : error LNK2019: unresolved external symbol _TEST_MOD_mp_ADDER referenc
ed in function _MAIN__
test.exe : fatal error LNK1120: 1 unresolved externals

(Yes, I know it's a very old compiler, but it works well and suits my purposes.)

What am I doing wrong, or not doing?



0 Kudos
2 Replies
New Contributor II

Sorry!  I realised that what I need to do is include the associated .obj file in the build.  Working now.

Valued Contributor II

It is ok to update.  Really there are few differences between the builds, but you will get better error codes. 

Luckily Fortran does not change as fast as say C#. 

As an interesting analogy, from 1929 to 1941 we moved from the 

With Oscar Grubb aboard as flight engineerFrank Hawks sets a transcontinental airspeed record for a flight across the continental United States while ferrying the Lockheed Air Express (registration NR7955) from the Lockheed factory in BurbankCalifornia, to an air show in New York City, making the flight in 18 hours 21 minutes.

 to the Spitfire.