Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
7 Views

windows Vs linux command line

Dear all,

I am working on a project where I have 4 fortran files: A.f90 is the main subroutine in which I have the line

!DEC$ ATTRIBUTES DLLEXPORT::A

and where I call the 3 others modules (let's call them B_mod.f90 C_mod.f90 and D_mod.f90 ).

To compile them on windows (I want a .dll output file), I do:

>ifort /c B_mod.f90 C_mod.f90 D_mod.f90

and :

ifort /dll A.f90 B_mod.obj C_mod.obj D_mod.obj /link libai_analogy.lib libai_saber.lib /NODEFAULTLIB:LIBCMT.lib

That works well and I get my A.dll output file (~231ko), and works properly later when it is called by another program on windows.

Now I would like to do the same on linux (debian 9), so I do:

>ifort -c A.f90 B_mod.f90 C_mod.f90 D_mod.f90

>ifort -shared -o A.dll A.o B_mod.o C_mod.o D_mod.o -Xlinker libai_analogy.lib libai_saber.lib

At first sight, it compiles without any error message, however the output dll file is this time ~452ko, and is not working when I call him later.

Could you please tell me where I am doing something wrong, and how can I proceed properly with linux?

Thanks a lot for your help.

0 Kudos
4 Replies
7 Views

Shared libraries on linux are

Shared libraries on linux are of file type .so

For help see: https://www.thegeekstuff.com/2012/06/linux-shared-libraries/

Jim Dempsey

 

0 Kudos
Highlighted
Black Belt
7 Views

You may also need to specify

You may also need to specify -fpic because many versions of Unix require that objects being linked into a shared library contain only position-independent code.

0 Kudos
Highlighted
Beginner
7 Views

Thanks Jim,

Thanks Jim,

ok so "libai_analogy.so" instead of "libai_analogy.lib" for instance.

But what if I don't have the ".so" files ? (I only have .lib files because they are coming from a windows software). Can I do something ?

Thanks for your help

 

0 Kudos
Highlighted
Black Belt Retired Employee
7 Views

You can't use Windows

You can't use Windows-compiled code on Linux. You'll have to rebuild the libraries from sources (or get them in a Linux-targeted form that works with Intel Fortran.)

--
Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos