2021년 6월 11일 금요일

Creating personal library in Linux : 1. Fortran library to be used in Fortran (working)

 The purpose of this post is to summarize the procedure to make personal library of routines so that re-use previous works. 

(1) Fortran library to be used in Fortran 

(2) C/C++ library to be used in C/C++

(3) Fortran library to be used in C/C++

(4) C/C++ library to be used in Fortran

(5) Fortran library to be used in Python 

(6) C/C++ library to be used in Python 


Let us start from the first/second case. 

(1) to make a static library use "ar  crvs" 

ar rc liball.a dog.o cat.o bird.o #rc=replace/create

ranlib liball.a # make symbol indexing or use "s" for ar

to use

gcc main.c -L -l<filename>

(2) to make dynamic/shared library use linker like "gcc" ,"gfortran"

gcc -g -fPIC -Wall -Werror -Wextra -pedantic *.c -shared -o liball.so

to use dynamic library

gcc -g -wall -o app app.c liball.so

* if source file *.f use .mod file, one have to keep them to make shared library.
But once the shared library is created, .mod files are no more necessary. 

-------------------To be continued---------------------------------------------

댓글 없음:

댓글 쓰기