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:
real :: a, b, ab
ab = a+b
The main program is test.f90:
real :: a, b, absum
a = 1
b = 2
write(*,*) 'absum: ',absum
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:
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?
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 engineer, Frank 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 Burbank, California, to an air show in New York City, making the flight in 18 hours 21 minutes.
to the Spitfire.