Silverfrost Forums

Welcome to our forums

Linking DLL and LIB files ???

11 Jun 2007 6:38 #1957

Dear Learned Gurus,

I have mudled my way through generating DLL and LIB files for a subroutine library. Can anyone tell me how I actually use this - i.e., link to a program that needs those subroutines?

The idea is to distribute usable subroutines without allowing access to the source code.

Many thanks, Ludwig 😄

11 Jun 2007 7:42 #1958
  1. In Plato create a project to build your DLL.

  2. In Plato create another project to build an application that uses the DLL. This project will contain a REFERENCE to the DLL and this is configured via the Project Explorer window.

  3. If your library subprograms are all EXTERNAL Fortran 77 functions or subroutines then you do not need anything else in your application code (you do not need any special declarations or USE statements). If your application Fortran code contains Fortran 90 code then you may need to declare your library subprograms using an INTERFACE statement (or a USE statement for MODULE procedures).

12 Jun 2007 5:17 #1961

Dear Paul,

Thanks for your help! I did exactly the following:

1.) Built DLL (filename 'mod01.dll') from object file 'mod01.obj', using the SLINK commands:

slink dll lo mod01.obj exportall file

2.) Opened new project in Plato.

3.) Added 'mod01.dll' as a REFERENCE in the Projet Explorer Window on the right hand side.

4.) Used 'Add Existing Items' to incorporate the calling code that is supposed to use the subroutines in 'mod01.dll'.

5.) Tried to BUILD. Only REBUILD was usable on the BUILD menu. Although there was the applicable USE statement in the calling code, the compiler could not fine that module name (which resides within 'mod01.dll').

I am puzzling over what I missed doing - do you know what is amiss? :?:

With many thanks, Ludwig

12 Jun 2007 5:23 #1962

Hello Paul,

One more query - can I do this linking of the DLL using line commands in SLINK? That might be the easiest for me...

Best regards, Ludwig

12 Jun 2007 6:13 #1963

When you compile your application the compiler will need to be able to see the .mod file created with the DLL.

Yes you can do a manual link using SLINK. This is what Plato is doing for you when you do a build or rebuild in Plato.

Note that if you ship an FTN95 DLL tha uses Fortran modules then

  1. Your users will have to use FTN95 as well (because .mod files are compiler dependent).

  2. You will also need to ship all relevant .mod files for them to USE.

You will have a much wider user base if you make your subprograms EXTERNAL rather than put them in a MODULE.

12 Jun 2007 7:44 #1964

Hello Paul,

Finally this makes sense to me. Thank you so much for your help.

Best wishes, Ludwig

14 Nov 2007 3:16 #2437

Hello Ludwig,

I sort of have the same problem as you did. Since there is no 'nice' example to explain when and how to use .mod, .lib and .dll libraries. An especially why the diffrent options.

From your last post itr seems like you got it wright. I am interessted in how you solved it exactly.

What I would like is to have a single directory with all the modules I use. Compile them once and then link them with whatever program I am developing.

Hope you could give me some tipps :lol:

Jacques

19 Jan 2008 9:27 #2681

Hello Jacques,

I happened upon your posting just today - hope this is not way too late.

I went the route of having all of my library routines available as external program units (i.e, not inside modules referenced with USE), which obviated the need to supply all the .mod files in addition to the DLL. Each of these library routines in turn USEs the relevant module(s) in my library.

Therefore, each (external) library routine called by the user is a 'front end' for one of the routines in the list of modules.

By the way, you can download the 3d rendering library, which is now finished and very easy to use:

www.quickie3d.com

Best wishes, Ludwig

19 Jan 2008 9:29 #2682

Hello again,

If you want a short template, I can post one.

Best, Ludwig

28 Jan 2008 2:01 #2710

Hi Ludwig,

thanks for your reply!

I sort of solved my problem in a unsatisfied way due to the lack of examples.

I will appreciate it if you could you please send me a template.

Quickie 3D looks quite impresive! I am going to take a closer look at it!

Best regards Jacques

Please login to reply.