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

How to call a subroutine in a project from another project?

Iranmanesh__Faezeh
390 Views

Hello everybody,

I have a project which includes a lot of subroutines. Now I built a new project and I need to call the subroutines that I have in my previous project but I don't know how to do so...Could you please help me with this problem..

 

Regards,

Faezeh

0 Kudos
1 Reply
jimdempseyatthecove
Honored Contributor III
390 Views

Assuming both project are in the same solution:

If (when) both projects generate an executable, then create a third project in the same solution that generates a library (static or dynamic). Then place the common subroutines to both executable projects into this library project. Make both executable projects dependent upon the library.

While you could add the .obj files of the other project directly, this would not permit a auto-rebuild should one be necessary.

If both current executable projects are in separate solutions, then you can either make a new solution containing the two executable projects as above. Or create the library project (or a library in both projects) an then add the previously built library to the link phase (note, this will not cause the external library to get rebuilt if necessary).

Jim Dempsey

0 Kudos
Reply