CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Main CFD Forum (http://www.cfd-online.com/Forums/main/)
-   -   FORTRAN static library (http://www.cfd-online.com/Forums/main/5888-fortran-static-library.html)

littlelz March 24, 2003 14:02

FORTRAN static library
 
hi, dear all, could you please tell me how could I use(add) an existed fortran static lib in a main fortran project, thanks very much!

Nashat March 25, 2003 15:40

Re: FORTRAN static library
 
Here's a makefile sample:

FC = g77 -g -Wall

FLIBS = -lblas -llapack -lslatec

PROGRAM = poisson

SOURCES = poisson.f linsolve.f iostuff.f utils.f

OBJECTS = poisson.o linsolve.o iostuff.o utils.o

INCLUDE = poisson.h

all: ${PROGRAM}

${PROGRAM}: ${OBJECTS}

${FC} -o ${PROGRAM} ${OBJECTS} ${FLIBS}

clean:

rm -f ${OBJECTS} ${PROGRAM} core

Nashat March 25, 2003 15:47

Re: FORTRAN static library
 
p.s. there should be a tab in the start of the following lines:

${FC} -o ${PROGRAM} ${OBJECTS} ${FLIBS}

and

rm -f ${OBJECTS} ${PROGRAM} core


Manosh March 26, 2003 04:11

Re: FORTRAN static library
 
If this one is a shell script, you need to add a line as well like

SHELL = /bin/sh

Manosh

Yiling March 27, 2003 04:44

Re: FORTRAN static library
 
Hi,

If I want to use them under the visual fortran project, how to call them? Thanks in advance!

Yiling

Manosh March 27, 2003 06:45

Re: FORTRAN static library
 
hi

Create a file called Makefile in your folder, which will include all things have written by Nashat.

In the same folder create directory 'SOURCES' which will contain all your source codes *f .. A header file (*.h) will be in the SOURCE directory.

create directory PROGRAM, which will contain the exe file.

Hope this helps.

Manosh

littlelz April 1, 2003 06:35

Re: FORTRAN static library
 
hi, dear all, i have known the answer, thanks a lot for all of your help!

If you want to use them under the visual fortran project, two steps as following:

first step: add your library file(.lib) directory into the 'projest->setting->link->object/library modules', please note the full directory and the library file name are needed

second step: add your library file(.lib) directory into the 'projest->setting->Fortran->category->preprocessor->include and use path' please note only the full directory is needed

good luck!


All times are GMT -4. The time now is 00:26.