-
Notifications
You must be signed in to change notification settings - Fork 5
Compile and link to static library
To avoid copying the source file f90getopt.F90
to your working directory (even if this is recommended) every time you want to use their features, it make sense to create a static library. After, you just need to link the library to your project. To do this follow the steps below
Change to the directory where the f90getopt.F90
is located and type:
gfortran -c f90getopt.F90
ar cr libf90getopt.a f90getopt.o
ranlib libf90getopt.a
You will get a static libray called libf90getopt.a
and a module file f90getopt.mod
.
Move the a-file on UNIX(-like) systems to /usr/local/lib
and the mod-file to /usr/local/include
:
sudo cp ./libf90getopt.a /usr/local/lib/
sudo cp ./f90getopt.mod /usr/local/include/
On Windows go to the appropriate directory of your compiler-system. MinGW and Cygwin are similar to UNIX. Integrated Development Environments (IDE) have their own rules. Refer the manual of your IDE.
To compile and link the sample program with the library can be done on Unixes with:
gfortran -o f90getopt_sample f90getopt_sample.f90 -I/usr/local/include -lf90getopt
Change paths to match the right ones on Windows.