replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - Including pre-compiled object files at linking
forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Including pre-compiled object files at linking

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
jjgermis



Joined: 21 Jun 2006
Posts: 404
Location: N�rnberg, Germany

PostPosted: Wed Jan 20, 2010 9:46 am    Post subject: Including pre-compiled object files at linking Reply with quote

Plato allows me to specify, among others, the following:
1.) include paths (Project->Properties->Source->Specifiy include paths) and
2.) include modules (Project->Properties->Source->Specifiy module paths).

This works fine when compiling. However, when the program is linked the object files are required as well. Is there some way to instruct Plato to search for the object files in a path?
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8210
Location: Salford, UK

PostPosted: Wed Jan 20, 2010 10:29 am    Post subject: Reply with quote

The usual approach is to create a project, then everything is done for you.
Can you supply further details about the setup.
Back to top
View user's profile Send private message AIM Address
jjgermis



Joined: 21 Jun 2006
Posts: 404
Location: N�rnberg, Germany

PostPosted: Wed Jan 20, 2010 10:43 am    Post subject: Reply with quote

I usually work with projects. Previously I had a reference to a dll in the project. To be more precise, I have the following structure (all paths relative to the project directory):
1.) project\source.f95
2.) project\inclucde\file1.inc (common include files)
3.) project\modules\module.MOD (pre-compiled module files)

I can compile my project with this. When I link I need module.obj as well but do not know how to instruct the linker from Plato. The other option (which I use) is to make a .lib or .dll from the module and include it as a reference to the project.

The reason beyond this is to compile common files that occur in several projects only once. I do not want to include the common files explicitly in the project.
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2615
Location: Sydney

PostPosted: Wed Jan 20, 2010 1:12 pm    Post subject: Reply with quote

I'm a bit puzzled by this and other similar threads.
What is wrong with making a static .lib library and loading this in slink ?

I've got at least 8 libraries which I've used for years and they provide me with significant functionality when developing new software for new projects. These are stable libraries of often sophistocated utility software that greatly improve my productivity.

I find that new programing styles that do not appear to utilise this approach are flawed. They appear to be taking a step back in numerical methods programming.

I wonder what will be around in 2100 to use with Dan's evolved Fortran.
Back to top
View user's profile Send private message
jjgermis



Joined: 21 Jun 2006
Posts: 404
Location: N�rnberg, Germany

PostPosted: Wed Jan 20, 2010 1:28 pm    Post subject: Reply with quote

Hi John,

thanks for the reply.

It is of course not my aim to puzzle you - I think that I am not expressing myself clear. I also have "components" that appear in several projects. Until now I have copied the individual source files in each new project (using Plato3). When I change one of these common files, I have to copy it in each new project. So I would like to make some static library (like you) using Plato. However, a static library is not a default project template in Plato3 (at least in my version). My attempts in the past failed all.

The concept of a .lib (or a dll) is clear to me. The problem is the implementation. And again I have no example.
Back to top
View user's profile Send private message
jjgermis



Joined: 21 Jun 2006
Posts: 404
Location: N�rnberg, Germany

PostPosted: Wed Jan 20, 2010 1:44 pm    Post subject: Reply with quote

Here some example that I did by manualy. I have the following files:
1.) xmlparse.f90;
2.) write_xml_parse.f90;
3.) read_xml_parse.f90;
4.) read_from_buffer.inc
5.) read_xml_array.inc
6.) read_xml_scalar.inc

All the above .f90 files are compiled from the command line using FTN95 file.f90. Afterwards I use slink as follows:
slink
* archive static_xml.lib
* addobj xmlparse.obj
* addobj write_xml_prims.obj
* addobj read_xml_prims.obj
* file

The result is a static_xml.lib file. However, I would like to do this using Plato3.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8210
Location: Salford, UK

PostPosted: Wed Jan 20, 2010 1:58 pm    Post subject: Reply with quote

To create a project for a static library in Plato, create one for a DLL and then use the Project menu to "Set Target" for a .LIB.

You may not be able to do this with a very old Plato.
Back to top
View user's profile Send private message AIM Address
jjgermis



Joined: 21 Jun 2006
Posts: 404
Location: N�rnberg, Germany

PostPosted: Wed Jan 20, 2010 2:18 pm    Post subject: Reply with quote

Thanks! My Plato can do this.

This allows me to add my static library as a reference in my Plato project. This brings me to the following questions:
1.) Can I keep the directory of the static library relavtive to my project directory, i.e. in the case that I copy my project to some other directory?
2.) Do I use the .MOD files when I use a static library?

If I do not need the .MOD files I think that using .lib files are beter than using dll's (at least in my case).
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8210
Location: Salford, UK

PostPosted: Wed Jan 20, 2010 4:16 pm    Post subject: Reply with quote

1) I think that the paths in the project file (*.ftn95prj) are relative by default. If not then there is an option in the Plato Options Dialog box to change this.

2) If your static library contains MODULEs then you will need to use the associated .mod files whenever you have a USE statement in your code. I am assuming that you can do this for a static library although I have not tried this. However, in the case of a dynamic library, it does not make much sense to use MODULEs in a dynamic library because data cannot be shared and there is little point in using MODULEs without data.
Back to top
View user's profile Send private message AIM Address
jjgermis



Joined: 21 Jun 2006
Posts: 404
Location: N�rnberg, Germany

PostPosted: Wed Jan 20, 2010 11:20 pm    Post subject: Reply with quote

I tried the following:
1.) included my static library as a reference in my Plato project;
2.) deleted all .MOD files;
3.) removed all include/module paths from the project options and
4.) build the project.

In the static library there were some modules. Everthing seemed to be working fine. From this I concluded that the .MOD files are not required.

I thought that static and dynamic libraries are only a way of keeping some program parts together that are often used. I did not know that modules should not be used in dynamic libraries - I used it before and it seemed to work. Since I never actually "learned" Fortran, I notice that there are still some concepts that I do not understand. The only thing I can do good is to debug existing programs.
Back to top
View user's profile Send private message
jjgermis



Joined: 21 Jun 2006
Posts: 404
Location: N�rnberg, Germany

PostPosted: Thu Jan 21, 2010 9:41 am    Post subject: Reply with quote

Paul, for me a useful implementation of a static library would be the numerical recipies in Fortran for example. It has three base files and the individual subroutines for the specific functions. Instead of adding all the files to a project I create a static library and each time only have to add the .lib as a reference. When I add a function/subruotine to the library I re-compile it and only have to update the .lib reference in my projects.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8210
Location: Salford, UK

PostPosted: Thu Jan 21, 2010 10:16 am    Post subject: Reply with quote

OK. You could create either a static library or a dynamic library for this purpose.

With a static library the object code in the library is built into the executable at link time.

With a dynamic library the object code in the library is always external and is linked in at run time. So the DLL must be present at runtime.

Static library - large executable - library not used at run time
Dynamic library - small executable - library must be shipped with exe.
Back to top
View user's profile Send private message AIM Address
jjgermis



Joined: 21 Jun 2006
Posts: 404
Location: N�rnberg, Germany

PostPosted: Thu Jan 21, 2010 3:05 pm    Post subject: Reply with quote

Paul, thanks for your comments on the static and dynamic libraries. There is however still one point that is not clear to me:
Does one require the .MOD files when using a static library?
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8210
Location: Salford, UK

PostPosted: Thu Jan 21, 2010 5:09 pm    Post subject: Reply with quote

If you have a USE statement in your Fortran code then you will need a MOD file to go with it. Each MODULE generates its own MOD file.

If you define a MODULE in the static library and USE it in code that is not in this library then you will need the MOD file so that the compiler knows what is in the MODULE.

A MOD file provides the interface to the MODULE but not its body.
Back to top
View user's profile Send private message AIM Address
jjgermis



Joined: 21 Jun 2006
Posts: 404
Location: N�rnberg, Germany

PostPosted: Thu Jan 21, 2010 5:18 pm    Post subject: Reply with quote

Thank you for the explanation. If I understood this correct I can:
1.) have a single common directory with my all my .MOD files
2.) specify this as a module path in the Plato project options
3.) add the static library as a reference.

This can make life much easier!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group