Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compiling a dynamic library on linux

Status
Not open for further replies.

Andrewgaven

Technical User
Feb 16, 2009
6
VE
Hello all, Does anyone know how to create a fortran dynamic library in linux?
On a windows platform my .dll is created by the following procedure
on shell:
$gfortran -c rls2.f90 backward.f90 forward.f90 fzmf.f90 dxfz.f90 hybrid.f90
$dlltool -z hybrid.def --export-all-symbols hybrid.o
$gfortran -shared -mrtd -o hybrid.dll hybrid.o rls2.o backward.o forward.o fzmf.o dxfz.o hybrid.def

On linux "dlltool" doesn't work so i can't create the .def file, does anyone know a equivalent for linux?
Thanks in advance.
 
Have a look at ld. A dll on Linux is called a shared object. It has a .so extension.

Actually, come to think of it, you do not need the dlltool step on Linux. Linux DLLs do not need .def files.
 
Thank for your answer.
i was able to create a .dll by omitting dlltool step and the the hybrid.def

$gfortran -c rls2.f90 backward.f90 forward.f90 fzmf.f90 dxfz.f90 hybrid.f90
$gfortran -shared -mrtd -o hybrid.dll hybrid.o rls2.o backward.o forward.o fzmf.o dxfz.o

however, went i call this .dll the result are random, like if some variable was missing, every time this function is called it gives different result although having the same input, this doesn't happens on windows platform and neither went compiled as a .out file. I also try by using the .so extension

$gfortran -shared -mrtd -o hybrid.so hybrid.o rls2.o backward.o forward.o fzmf.o dxfz.o

With the same results is there another way to create a .so?
 
Try

$gfortran -c -fpic rls2.f90 backward.f90 forward.f90 fzmf.f90 dxfz.f90 hybrid.f90

I don't know if -fpic is the default.
 
i did
$gfortran -c -fpic rls2.f90 backward.f90 forward.f90 fzmf.f90 dxfz.f90 hybrid.f90

but this only gives the .o of each file so i create the .so with

$gfortran -shared -mrtd -o hybrid.so hybrid.o rls2.o backward.o forward.o fzmf.o dxfz.o

same results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top