strange linking problem
- From: nicolasbock@xxxxxxxxx
- Date: 27 Apr 2005 16:46:05 -0700
Hello,
the problem I have is a little complicated to describe, well, I wil
give it a try. I wrote a module in f90 (MAC OS X 10.3, IBM XLF
compiler) which defines a character array and assigns a literal string
to it. In another file I use this array. I build my program such that I
make an object file out of the module and link that into the program. I
tried this two ways, first by linking the module by listing the object
file directly on the compiler command line, and second by using a
static library and linking it that way. In the first case, everything
works as I expect it, in the second case the array is empty. Here are
the files:
in file Parameters.F90:
MODULE Parameters
IMPLICIT NONE
Character (len=100) :: test = "This is a test"
END MODULE
in file Main.F90:
PROGRAM Main
USE Parameters
IMPLICIT NONE
write (*, *) "printing test: ", test
END PROGRAM Main
The Makefile which produces both versions of the program is
..PHONY : all
all : Main1 Main2
Main1 : Main.o libtest.a
xlf95 -o $@ $< -L. -ltest
Main2 : Main.o Parameters.o
xlf95 -o $@ $^
libtest.a : Parameters.o
ar -rcv libtest.a $^
ranlib libtest.a
Main.o : Parameters.o
%.o : %.F90
xlf95 -qsuffix=f=F90 -o $@ -c $^
Could someone shed some light on this strange problem? Is that
something that is to be expected?
Thanks already, nick
.
- Follow-Ups:
- Re: strange linking problem
- From: Richard E Maine
- Re: strange linking problem
- From: nicolasbock
- Re: strange linking problem
- Prev by Date: Re: why doesn't this compile ?
- Next by Date: Re: why doesn't this compile ?
- Previous by thread: why doesn't this compile ?
- Next by thread: Re: strange linking problem
- Index(es):
Relevant Pages
|