Autotools: How to add a shared library .so?

Hi everyone,

I tried to add my Fortran modules and a shared library (.so) into an extensive library which is also written in Fortran. The code does not complain about the modules. It knows where to find .mod files. However, I do not know what option should be put in configure.ac to make it consider the shared library “.so”.

By far, I tried the following commands separately in configure.ac but no success:

Option 1)

medys_LDADD = -L/PathToDirectory -lnamelib

Option 2)

LDADD=PathToDirectory/namelib.so

Option 3)

AM_LDADD = PathToDirectory/namelib.so

I also saw that in one of the directories, in its Makefile, there is an option to precise the shared and static libraries paths. I indicated the path there but that did not change anything.

P.S.1: Whenever I make a change, I first do “autoreconf -vi” and second “make”.
P.S.2: The library that I use is not open source. So, unfortunately, I don’t have permission to share its related files. Its structure is as follows: in the main directory, there is a Makefile.am and inside the SUBDIRS option. Inside each directory, there is a “Makefile.mk” file. I put my modules and the shared library that I use inside a new directory and I made a “Makefile.mk” inside it. I followed what was done inside other "Makefile.mk"s (the source and module file’s names are listed there). But as there were no external shared libraries “.so” being used by this big library, I don’t know if an option should be added to “Makefile.mk” or configure.ac should be changed.

Is it possible to create a small example that shows the necessary components of the build process? We do not need to know the entire application, but it would help if you can post something akin to the example I posted in the other thread. That will give us a better picture of what you are struggling with.

@Arjen, sorry for asking, I am a newbie in using autotools. Did you generate automatically the example that you posted in my other thread? Or was it a copy/paste of different Makefiles/configure.ac ?

Hi @mary ,

Welcome to Fortran Discourse!

Disclaimer: I’ve never used AutoTools, so I have no direct pointers that can be of any help

However a suggestion since you mention you’re new to AutoTools: is it possible for you then to first try out fpm for your work?
https://fpm.fortran-lang.org/en/index.html

You will find a lot of guidance here on fpm and feedback from folks that show you its relative ease-of-use.

Once you get your work going with fpm, you will also gain a good map of your large application that may prove useful to you with AutoTools configuration and like.

Just 2 cents’ worth,

No, I constructed it manually, using examples from a larger project. It is part of the examples of my book (Modern Fortran in Practice, already 10 years old).
The reason I ask for a small example of what you are trying to achieve is that that way we can experiment ourselves, instead of trying to construct it from your description and thereby making stupid mistakes.