You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After the library has been built, it can be included in a regular Makefile.
245
+
The recommended way to do this is using the [pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/) tool, for which an example is shown below.
246
+
```make
247
+
# Necessary if the installation directory is not in PKG_CONFIG_PATH
# Example definition of Fortran compiler and flags
255
+
FC := gfortran
256
+
FFLAGS := -O2 -Wall -g
257
+
258
+
# Definition of targets etc.
259
+
...
260
+
261
+
# Example rule to compile object files from .f90 files
262
+
%.o: %.f90
263
+
$(FC) -c -o $@ $< $(FFLAGS) $(STDLIB_CFLAGS)
264
+
265
+
# Example rule to link an executable from object files
266
+
%: %.o
267
+
$(FC) -o $@ $^ $(FFLAGS) $(STDLIB_LIBS)
268
+
269
+
```
270
+
271
+
The same can also be achieved without pkg-config.
245
272
If the library has been installed in a directory inside the compiler's search path,
246
-
only a flag `-lfortran_stdlib` is required to link against `libfortran_stdlib.a` or `libfortran_stdlib.so`.
273
+
only a flag `-lfortran_stdlib` is required.
247
274
If the installation directory is not in the compiler's search path, one can add for example
248
275
```make
249
-
libdir=${install_dir}/lib
250
-
moduledir=${install_dir}/include/fortran_stdlib/<compiler name and version>
276
+
install_dir := path/to/install_dir
277
+
libdir := $(install_dir)/lib
278
+
moduledir := $(install_dir)/include/fortran_stdlib/<compiler name and version>
251
279
```
252
-
Here it is assumed that the compiler will look for libraries in `libdir` and for module files in `moduledir`.
253
-
The library can also be included from a build directory without installation:
280
+
The linker should then look for libraries in `libdir`(using e.g.`-L$(libdir)`) and the compiler should look for module files in `moduledir` (using e.g. `-I$(moduledir)`).
281
+
Alternatively, the library can also be included from a build directory without installation with
0 commit comments