- 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
First, -I accepts only a path argument so that's why the case specifying the path and module file name (mod1.mod) did not work. You only need to specify the path to the module file(s) not the actual name(s).
Similarly, -L only specifies the path to libraries. You should also use the l (lowercase) to specify the actual library names without the leading "lib" and trailing ".a".
Next, the undefined references relate to the order the linker sees the lib (.a) and object file for main.f90.
You can successfully compile/link your sample program using the commands below. I changed your lib names to libONE.a and libTWO.a to help show use of the l option.
cd /path1
ifort -V -c lib1.f90 -o lib1.o
ar rcv libONE.a lib1.o
ifort -V -c lib2.f90 -o lib2.o
ar rcv libTWO.a lib2.o
cd path2
ifort -V -I.. main.f90 -L.. -lTWO -lONE
It is important to note the compilation of main.f90 and subsequent link for the ifort command line above only succeed because of the order the files appear on the command line given their inner dependencies.
You can avoid this ordering requirement using the linker's --start-group/--end-group to repeatedly search archives until all external references are resolved. Normally an archive is searched only once and in the order specified on the command-line. Notice that libONE and libTWO have switched positions below.That's just an attempt to show the link succeeds related to the linker repeatedly searching those two archives to resolve externals.
The alternative to the ifort command for main.f90 above is to compile main.f90 to an object file and then link all components as shown:
ifort -V -I.. -c main.f90
ifort -V -L.. main.o -Wl,--start-group,-lONE,-lTWO -Wl,--end-group
Hope that helps.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
First, -I accepts only a path argument so that's why the case specifying the path and module file name (mod1.mod) did not work. You only need to specify the path to the module file(s) not the actual name(s).
Similarly, -L only specifies the path to libraries. You should also use the l (lowercase) to specify the actual library names without the leading "lib" and trailing ".a".
Next, the undefined references relate to the order the linker sees the lib (.a) and object file for main.f90.
You can successfully compile/link your sample program using the commands below. I changed your lib names to libONE.a and libTWO.a to help show use of the l option.
cd /path1
ifort -V -c lib1.f90 -o lib1.o
ar rcv libONE.a lib1.o
ifort -V -c lib2.f90 -o lib2.o
ar rcv libTWO.a lib2.o
cd path2
ifort -V -I.. main.f90 -L.. -lTWO -lONE
It is important to note the compilation of main.f90 and subsequent link for the ifort command line above only succeed because of the order the files appear on the command line given their inner dependencies.
You can avoid this ordering requirement using the linker's --start-group/--end-group to repeatedly search archives until all external references are resolved. Normally an archive is searched only once and in the order specified on the command-line. Notice that libONE and libTWO have switched positions below.That's just an attempt to show the link succeeds related to the linker repeatedly searching those two archives to resolve externals.
The alternative to the ifort command for main.f90 above is to compile main.f90 to an object file and then link all components as shown:
ifort -V -I.. -c main.f90
ifort -V -L.. main.o -Wl,--start-group,-lONE,-lTWO -Wl,--end-group
Hope that helps.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page