- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I post this problem earlier, You tried to help me, but still i am searching. So i am reposting it in more details.
How can i compile and link a program that uses subroutines in
different directories?
as for simple example;
[cpp]$ cat trial.f90
call lm(oidxdn,opnu,opold,oqnu,oqold,avw)
call lm_end(oidxdn,opnu,opold,oqnu,oqold,avw)
end [/cpp]
is compiling as:
[cpp] $ gfortran -c trial.f90 -I/home/rudra/Recursion/LMTO-A [/cpp]
but when i am trying to create the executable, it says:
[cpp]gfortran trial.f90 -L/home/rudra/Recursion/LMTO-A -llm
/tmp/cc2gfNyf.o: In function `MAIN__':
trial.f90:(.text+0x44): undefined reference to `lm_'
collect2: ld returned 1 exit status [/cpp]
can anyone tell me the wayout?
As a work around, i tried to create a library(static) as
[cpp]liblm.a:MAIN/lm-lib.f MAIN/lm-lib-end.f $(lmobj)
$(FC) -c MAIN/lm-lib.f MAIN/lm-lib-end.f $(lmobj)
ar rcs liblm.a lm-lib.o lm-lib-end.o $(lmobj) [/cpp]
and link this to my main as:
[cpp]irun: $(FOBJ)
$(FC) $(FFLAGS) $(FPAR) -o $@ $(FOBJ) -L/home/rudra/Recursion/LMTO-
A/ -llm
........
........
main.o : main.f90 util.o ldos.o fermi.o band.o dos.o mmat.o hop.o
shared.o param.o kind.o cgreen.o bit_unm.o nis.o
$(FC) -c $(FFLAGS) $(FPAR) main.f90 -L/home/rudra/Recursion/LMTO-A -
llm [/cpp]
This one is working fine, only with a problem that even if my library
(liblm.a) is updated, main is not updating via make and i am forced to
make clean; make everytime i compile.
any suggestion?
(This is historical as i am trying to create and use my FIRST library.
So plz. be simple)
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page