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

A simple .so example that export a subroutine?

Intel_C_Intel
Employee
469 Views
Hello.
We are porting a program from Fortran 8.0Windows to Fortran 8.0 Linux, and we are struggling to export certain functions and subroutines from the .so file. Any help would be very much appreciated.
1) As far as we understand do not dynamic link libraries (.dll) exist under Linux. Instead we have to use dynamic shared objects (.so). Is this correct?
2) From the library, we need to export a few symbols.InWindows, we used the !DECT$ATTRIBUTES DLLEXPORT command. This command seems not to work under Linux, as far as we can see. What is the corresponding command under Linux?
3) It would have been extremely convenient if you would demeonstrate how to export a function in a .so library by means of a simple example. The library could contain the following two functions for example:
double precision functionnrt(a,n)
double precision a
integer n
nrt = a**(1.0D00/dble(n))
end
double precision function invnrt(a,n)
double precision a
integer n
invnrt = 1.0D00/a**(1.0D00/dble(n))
end
Let us assume that we wanted to export the first of these two functionsonly, and that the second should be hidden as the code is confidential. Is it possible to do this by means of a define file (.DEF), an export file (.EXP) or by means of a command that is equivalent to DLLEXPORT?
From our point of view, I think that the .DEF file alternative would be the most useful, as this seems to be same under Linux and Windows. Is this correct?
When you submit the example program (if this is not too timeconsuming for you), please let us know the requested compiler options also (using ifort under linux), and how to use the exported nrt function in another program. The following main program would be sufficient:
program mainroot
double precision a,b
a = 3.5D00
b = nrt(a,4)
write(*,*)a,b
end program mainroot
I hope that I am not asking too many questions!
Best regards from Lars Petter Endresen

Message Edited by lpe@scandpower.no on 04-13-2004 06:34 AM

0 Kudos
2 Replies
TimP
Honored Contributor III
469 Views
As I understand it, all functions are exported from a linux .so. While there are efforts underway to change that, I don't believe anything is available now.
0 Kudos
Intel_C_Intel
Employee
469 Views
Thanks for the almost immediate reply. We have now found a command dlltool:
Is it possible to use this command instead? Or is the only alternative to use a tcp-ip coupling between the two programs to avoid the customer to sneak into our software?
Best wishes,
Lars Petter Endresen
0 Kudos
Reply