Home > Archive > Fortran > December 2006 > include file problem
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
include file problem
|
|
| allelopath 2006-12-22, 7:05 pm |
| I am trying to make a project with an include file in a directory not
in the same directory as the source code.
As it is I get this compile error:
fortcom: Error: source/myFile.f, line 22: Cannot open include file
'myIncludeFile.inc'
include 'myIncludeFile.inc'
--------------^
compilation aborted for source/myFile.f (code 1)
The directory structure is as follows:
<myProject>
makefile
<source>
myFile.f
<inc>
myIncludeFile.inc
So the <inc> directory is contained in the <source> directory
If I move the include file into the <source> directory, the make works.
myFile.f includes the file like so:
include 'myIncludeFile.inc'
if I change it to:
include 'inc/myIncludeFile.inc'
then it compiles, but I was thinking that I wouldn't need to specify
the directoy in the code by way of the makefile.
Is this possible?
Pertinent excepts from makefile are below:
COMPILER = /usr/local/intel/9.1.044/bin/ifort
O = obj
..SUFFIXES:
..SUFFIXES: .inc $(SUFFIXES)
OBJ = ${O}/charyr.o\
FOPT = -c -O -i-dynamic
FFLAGS = $(FOPT)
CURRENT_PATH = $(CURDIR)
SRC = source
INCLUDE = inc
INCLUDE_DIR = ${SRC}/inc
INCLUDEFILE = ${CURRENT_PATH}/${INCLUDE_DIR}/myIncludeFile.inc
all : myProgram
clean :
rm myProgram obj/*.o
myProgram : $(OBJ) $(INCLUDE_FILE)
${COMPILER} $(OBJ) -o myProgram -C -lm
${O}/myFile.o : ${SRC}/myFile.f $(INCLUDE_FILE)
${COMPILER} -I./inc $(FFLAGS) ${SRC}/myFile.f
mv myFile.o ${O}/myFile.o
| |
| AeroSpace Ed 2006-12-22, 7:05 pm |
| Hello,
allelopath wrote:
> I am trying to make a project with an include file in a directory not
> in the same directory as the source code.
> As it is I get this compile error:
[snip]
>
> Pertinent excepts from makefile are below:
[snip]
> CURRENT_PATH = $(CURDIR)
> SRC = source
>
> INCLUDE = inc
> INCLUDE_DIR = ${SRC}/inc
[snip]
> ${O}/myFile.o : ${SRC}/myFile.f $(INCLUDE_FILE)
> ${COMPILER} -I./inc $(FFLAGS) ${SRC}/myFile.f
> mv myFile.o ${O}/myFile.o
Note that you are correctly specifying the source files, relative to your
make's 'cwd', however the include directory is in error I believe. Please
try this '-I./${SRC}/inc'.
Just a comment. Your Makefile is way too round-a-bout for such a simple
task. For what you are trying to do, it shouldn't be more than 5-10 lines.
Ed
| |
| allelopath 2006-12-22, 7:05 pm |
| Good eye. That was the problem. Thank you.
Afa the roundabout-ness goes, you are correct given what you see, but
there are many more files that I snipped out to isolate the problem.
On Dec 22, 9:06 am, AeroSpace Ed <mimihoo...@sbcglobal.net> wrote:
> Hello,
>
> allelopath wrote:
>
>
>
>
>
>
> make's 'cwd', however the include directory is in error I believe. Please
> try this '-I./${SRC}/inc'.
>
> Just a comment. Your Makefile is way too round-a-bout for such a simple
> task. For what you are trying to do, it shouldn't be more than 5-10 lines.
>
> Ed
|
|
|
|
|