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

problem with modules and ifort (10.1.008) under Mac OS

michielotten
Beginner
711 Views
Hi,
I have problems compiling our software using ifort under Mac OS. The error I get happens during the building of the binary. I have included a sample program that gives the identical error as I get with our software and ifort. The sample program compiles without error using g95 (0.91). The error I get is:

ifort -c testmod2.f90 -o testmod2.o
ifort -c testmod.f90 -o testmod.o
ifort -c test.f90 -o test.o
ar -r testlib.a test.o testmod.o testmod2.o
ar: creating archive testlib.a
ifort -o test.bin test.o testlib.a
ld: Undefined symbols:
_testmod2_mp_var1_module2_
make: *** [test.bin] Error 1


As can be seen from the program included below ifort has no problems with the module variables from testmod but has problems with the testmod2 variables.

The main program and modules:

PROGRAM test

USE testmod
USE testmod2

IMPLICIT NONE

integer :: a,b,c,d

write (*,*) 'Hello World'

a = 1
b = 4
c = 7

write (*,*) a,c,d
testmod_var = 10
var1_module2 = testmod_var
d = test_func(a,c)
write (*,*) testmod_var,d
write (*,*) var1_module2

END PROGRAM test

MODULE testmod

IMPLICIT NONE

PRIVATE
PUBLIC testmod_var,test_func

INTEGER,SAVE :: testmod_var

CONTAINS

FUNCTION test_func(a,b)
INTEGER :: test_func
INTEGER, INTENT(IN) :: a,b
test_func = a + b + 3
END FUNCTION test_func


END MODULE testmod

MODULE testmod2

IMPLICIT NONE

PRIVATE var2_module2
PUBLIC var1_module2

INTEGER :: var1_module2,var2_module2


END MODULE testmod2

0 Kudos
2 Replies
Ron_Green
Moderator
711 Views
After your 'ar' command, you need to run ranlib -c against it:

ranlib -c testlib.a

ron
0 Kudos
michielotten
Beginner
711 Views
Thanks Ron! that did it :-) Cheers, Michiel.
0 Kudos
Reply