- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i have created a library file made up of subroutines(as usual) and they are created using module. is it possible to USE these module from other directories? actually i have to call to subroutines from that library (say A and B), and B's result depends on output of A. so in the argument list of A and B i should put them, waht i generally do using explicit interface. but as in this case, modules are in different directories, i cant simply use them. what is the way out?
i am compiling the main code with the libraries using simple command:
[cpp]irun: $(FOBJ) $(FC) -o $@ $(FFLAGS) $(FPAR) $(FOBJ) ~/Recursion/LMA/liblm.a [/cpp]
is this ok? i can see it is compiling and running, but not something i learned in manuals.
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
[cpp]main.o : main.f90 ~/Recursion/LMA/liblm.a -l/home/rudra/Recursion/LMA/mlms.mod [/cpp]while compiling using -l
make: stat: lib/home/rudra/Recursion/LMA/mlms.mod.so: Permission denied
make: stat: lib/home/rudra/Recursion/LMA/mlms.mod.a: Permission denied
make: *** No rule to make target `-l/home/rudra/Recursion/LMA/mlms.mod', needed by `main.o'. Stop.
where permission denied, i guess means, no such file exist. what to do?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[cpp]main.o : main.f90 ~/Recursion/LMA/liblm.a -l/home/rudra/Recursion/LMA/mlms.modwhile compiling using -l
[/cpp]
make: stat: lib/home/rudra/Recursion/LMA/mlms.mod.so: Permission denied
make: stat: lib/home/rudra/Recursion/LMA/mlms.mod.a: Permission denied
make: *** No rule to make target `-l/home/rudra/Recursion/LMA/mlms.mod', needed by `main.o'. Stop.
where permission denied, i guess means, no such file exist. what to do?
The font in the browser may be confusing you. Steve said to use -I, the first letter in the word Include. It looks like you have -l as in the first letter of library - this is wrong. It must be -I as in Include.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The font in the browser may be confusing you. Steve said to use -I, the first letter in the word Include. It looks like you have -l as in the first letter of library - this is wrong. It must be -I as in Include.
I can't read your next post, but I can state that -I~/ or -L~/ will not work in place of -L/home/yourlogin/ or -I/home/yourlogin/ This is general linux practice, not specific to Intel compilers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
first i have created a library in directory ~/Recursion/LMA using makefile:
[cpp].f.o: $(FC) -c $(PREFLAGS) $(FFLAGS) $< mv $(*F).o $(*D) # .c.o: $(CC) $(CCFLAGS) -c $< mv $(*F).o $(*D) 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 r liblm.a lm-lib.o lm-lib-end.o $(lmobj)[/cpp]
Now, i want to use this in my main code,in die ~/Recursion/ASR/, compiling as:
[cpp]irun: $(FOBJ) $(FC) -o $@ $(FFLAGS) $(FPAR) $(FOBJ) /home/rudra/Recursion/LMTO-A/liblm.a hop.o : hop.f90 param.o kind.o $(FC) -c $(FFLAGS) $(FPAR) hop.f90 $(LIBFLAGS) kind.o : kind.f90 $(FC) -c $(FFLAGS) $(FPAR) kind.f90 ldos.o : ldos.f90 param.o $(FC) -c $(FFLAGS) $(FPAR) ldos.f90 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 -I~/Recursion/LMTO-A -llm $(FC) -c $(FFLAGS) $(FPAR) main.f90 -I~/Recursion/LMTO-A -llm [/cpp]while i am making this, it is yeilding error:
[cpp]$ makebut if i compile things simply as
make: *** No rule to make target `-I~/Recursion/LMTO-A', needed by `main.o'. Stop.
[/cpp]
$(FC) -c $(FFLAGS) $(FPAR) main.f90 ../LMTO-A/liblm.a
then it is compiling(not using the .mod file though), and with a constraint that my liblm.a and main.f90 should be compiled with same compiler, which i dont think a library should do. plz help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
$(FC) -c $(FFLAGS) $(FPAR) main.f90 -I/home/ruda/Recursion/LMTO-A -L/home/ruda/Recursion/LMTO-A -llm
The make failure involves line 10 and the -I and -l compiler options you added. Those are needed on line 11 as you have placed them but those are not appropriate for line 10.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[cpp]irun: $(FOBJ) $(FC) -o $@ $(FFLAGS) $(FPAR) $(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]
which gives error:
ld: cannot find -lm
make: *** [irun] Error 1
i also tried without linking lm in linking; with no luck. how to link?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Maybe there's cut-n-paste problem here, but I cannot really tell why that's occurring from the snippets and now your main.o rule looks like one continuous line.
I also was misleading in my earlier post having overlooked the -c option for the main.o rule. The main.o rule is compiling only, therefore, -L and -l are not appropriate options. It could be that rule threw the last error you received.
As Tim mentioned earlier, if you trying to convince the compiler to use a static archive (.a) comprised of .mod files (not .o files) during the compilation phase of main.f (which seems to be what you were after by mixing -I and -l originally), then that won't work. The compiler only seeks to open files ending with .mod from a directory notstatic archive (.a), which is why Tim suggested your makefile needs to extract the .mod files from the static archive for the compiler to see/use those. The linker processes static archives at link time only.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
is it ok? i think i am missing something as it should not be the case.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I may be abit confused about your end goal.
If you're trying to create a static archive of gfrotran object files and have ifort (when compiling your main program) use any associated gfortran produced module files, then that will not work. ifort has no understanding of gfortran module files.
Also, you cannot expect to resolve any external dependencies from your gfortran objects in your static archive from the ifort run-time libraries at link time when compiling/linking your main program.
If the desire is to use a non-Intel compiler for your static archive and the Intel compiler for any program that uses that static archive, then you cannot leverage the USE and you must ensure your static archive does not accidentally use any ifort run-time libraries when linked.

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