Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Problem with libraries...

teclis77
Beginner
298 Views

Hi,

I have a problem when linking my libraries, even if their a re shared or static ones...

the main program (a.f) is
 


program test
c
doubleprecision a, b
integer i
c
external somma, prodotto, divisione
c
write(6,*) ''
write(6,*) 'Routine Maths'
write(6,*) ''
write(6,*) 'Sum, type 1'
write(6,*) 'Product, type 2'
write(6,*) ''
read(5,*) i
c
a=10.0d0
b=20.0d0
c
if(i.eq.1) then
call somma(a, b, c)
else if (i.eq.2) then
call prodotto(a, b, c)
end if
c
write(6,*) c
c
end

 


while the subroutine (b.f90) is

 

 

 


subroutine somma(a,b,c)
!
doubleprecision a, b, c
!
c = a + b

end subroutine somma
!
!
!
subroutine prodotto(a,b,c)
!
doubleprecision a, b, c
!
c = a * b
!
end subroutine prodotto

 


If I run

 

 

 


ifort -o a.out a.f b.f90


all is okkey...

But, if I run

 

 


ifort -fpic -c b.f90
ifort -shared b.so b.o
ifort -o a.out a.f b.so


I find this exit (when i run ./a.out)

 

 


./a.out: error while loading shared libraries: lib.so: cannot open shared object file: No such file or directory

 


If I use the static library, when I link the main with the library I found

 

 


ifort -fpic -c b.f90
ar rc b.a b.o
ifort -o a.out a.f b.so

 

 


/tmp/ifortcOUaGn.o: In function `MAIN__':
a.f:(.text+0x235): undefined reference to `prodotto_'
a.f:(.text+0x24e): undefined reference to `somma_'

 


How I can resolve my problem???

 

0 Kudos
3 Replies
Steven_L_Intel1
Employee
298 Views

In the static case, don't you want b.a rather than b.so?

Is your .so in a directory named in LD_LIBRARY_PATH?

0 Kudos
teclis77
Beginner
298 Views
I'm sorry... obviously it is b.a...

but, why I have to put the b.so in teh LD_LIBRARY_PATH, if it is in the same directory?
0 Kudos
Steven_L_Intel1
Employee
298 Views
I'm not familiar enough with Linux to answer that. The references I could find did not indicate that the current directory was included in the search by default.
0 Kudos
Reply