Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Using libraries

h-faber
Beginner
1,198 Views
Hi,
another question:
Is it possible, if so, how, to use libraries (within MS Visual Studio.NET) which contain compiled Fortran sources, mainly subroutines.
The idea behind is clear: Take several tools and helpful functions within one library and use it in different projects.
So far I have built the library as a MS Visual Studio.NET Fortran project, but how can I use it in another project?
0 Kudos
10 Replies
Steven_L_Intel1
Employee
1,198 Views
There are several ways. If the other project is in the same "solution", you can make the library project a "dependent" of the executable project. Or you can add the .lib as a source file to the executable. Or you can specify the path to the .lib in the Linker input property page.

Note that, by default, a Fortran library project is built with the option to "disable default library search rules", meaning that it depends on the linkable project to specify the correct Fortran run-time libraries to link against. If the linkable project is not Fortran, you will need to specify these libraries explicitly, or turn off the option in the library project and rebuild (I recommend building as a Release configuration if you do this.)
0 Kudos
h-faber
Beginner
1,198 Views
OK I will give it a try.
I wonder if it is possible to build one big package which creates all the needed applications. Right now I am building one project for each program so that I get different .exe applications. Is there another way?
0 Kudos
Steven_L_Intel1
Employee
1,198 Views
You can have one "solution" which contains many executable application projects. Then when you do a "Build Solution", it builds them all. This also makes it easy to use a dependent library project and makes sure that if the library project has changed it is rebuilt automatically.
0 Kudos
h-faber
Beginner
1,198 Views
>There are several ways. If the other project is in the same "solution", you can make the library project a "dependent" of the executable project.


Does not work - more than one MAIN program is found.


>Or you can add the .lib as a source file to the executable.


Does not help either. As if the file wasn't there, but of course it is.


>Or you can specify the path to the .lib in the Linker input property page.


I find the possiblity in the General and Advanced section, not in the Input. But also does not work.

Still confused why.
0 Kudos
Steven_L_Intel1
Employee
1,198 Views
I don't know what you are doing, but what I suggested does work. You can have multiple executable projects in a solution - I have done it. The other things I suggested do work.
0 Kudos
h-faber
Beginner
1,198 Views


sblionel wrote:
I don't know what you are doing, but what I suggested does work. You can have multiple executable projects in a solution - I have done it. The other things I suggested do work.

Hi Steve,

thanks for your patience. What I did was to add the library project to the exe project and set it to dependent, also set the build order. This alone is not enough for using functions and subroutines from the library. What I need to know: How can I use the functions and subroutines contained in the library? Consider a line of code in the exe project like

CALL MYFUNC

This MYFUNC is contained in a myfunc.for which itself is contained in the tools.lib (which gets built before the exe in my solution). Using the code line above does not work - MYFUNC cannot be found.

The master question now is: What do I have to do so that the compiler canfind this MYFUNC in the libraryor even inmyfunc.for?

The other idea withinserting the library as source directly in the project (e.g. tools.lib) confrontates me with the same problem. How can I say: When I call MYFUNC, look it up in the tools.lib - and maybe even look it up in the myfunc.for which is contained in the tools.lib?

0 Kudos
Steven_L_Intel1
Employee
1,198 Views
All you need to do is make the library project a dependent of the executable project. I have done this many, many times and it always works. Doing this causes the library to automatically be linked in. You should be able to see this in the build log.
0 Kudos
h-faber
Beginner
1,198 Views
I have no idea why it works now. I tried it the same way I tried before, now it works. Strange. Is there a special order one has to follow?
0 Kudos
Steven_L_Intel1
Employee
1,198 Views
No special order.
0 Kudos
glyn
Beginner
1,198 Views

Hi,

I hope that someone can help me -and that I've posted this in the correct place.

I have a solution with about 50 projects. Some are static libraries, some dll's and some exe's. There's also a couple of c++ projects in for good measure!

When we do a release of our product we have to build all of these projects, hence why they are in a single solution. However, as it can take a long time for the compiler to recongise what is built and what isn't, there are occasions when the same projectsare in smaller solutions, possibly without all the dependancies which have been pre-built.

If I link an exe or dll to a lib by both entering the dependancies in the "additional dependancies" option, under the linker properties AND the project dependancies tick box, then there are no problems, thus the project can be used both in a solution with and without the project it depends upon.

If I have a static lib, which may depend upon other static libs, I also like to use the project dependancies option to ensure that the build order is correct. However, if I also enter an additional dependency in the project options - so that the project can be used independantly of the solution -then I get many warnings as it is included twice.

I could get round this by entering all the dependant libs at the exe/dll project stage, but this is not very managable. Is there another way, or is this behaviour unexpected?

0 Kudos
Reply