The answer is equally easy: in the same way you would a standalone program.
If you use Visual Studio, define a project with the required output type. If you use the command-line, then:
ifort /dll name1.obj name2.obj name3.obj ... /exe:dllname.dll
(assuming you have already compiled the individual source files)
But reading the documentation say that I should have to files. One is the dll file and the second is a lib file in order to use to link when I have to do a program.
The previous procedure create the dll file, but where is the lib file?
The .lib is created in the same place as the DLL. If you don't see it, then you're missing !DEC$ ATTRIBUTES DLLEXPORT directives for any routines you want exported from the DLL.
When I do a static library, I need only the mod and smod files and the lib file to create a new program. I don't need worry about which routines I'm using in the program.
Now, I'm trying to do the same but using dll. I don't understand when you say that I need !DEC$ ATTRIBUTES DLLEXPORT if I want to export any routines from DLL. From your comment, I have to add !..... (macro) in every procedure (subroutine or function)? inclusive if I use modules or submodules?
You need to add an ATTRIBUTES DLLEXPORT directive in each and every subroutine and function you want visible outside the DLL. It goes in the actual routine, not interfaces. For example:
subroutine foobar (arg1, arg2) !DEC$ ATTRIBUTES DLLEXPORT :: foobar ...
You're right that this is different from creating a static library. When using it, it's the same - link to the .lib. (Of course, you then have to make sure the DLL is in a location Windows will find it.)
Only the subroutines and functions (optionally data) that are required to be called from the users of your DLL require the !DEC$ ATTRIBUTES DLLEXPORT ... The DLL private procedures need not have the DLLEXPORT.
My last question. All my procedures (functions or subroutines) are into a modules (or submodules). For each modules I have private and public procedures and variables.
If I understand well, I need to put in each public variables and public procedures the directive !DEC$ ATTRIBUTES....., right?
Is not possible to write all directives in one zone of the module file?
and I have seen also !DIR$ ATTRIBUTES DLL..... what is the difference respect to !DEC$ ATTRIBUTES DLL....?
Thanks for your help.
You cannot put these in the module interface - they must go in the actual procedure. When you put a DLLEXPORT into a module procedure, it turns into a DLLIMPORT when the module is USEd.
There is no difference between !DEC$ and !DIR$. Either prefix works.