<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Linking and function multiple definitions in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Linking-and-function-multiple-definitions/m-p/892717#M78683</link>
    <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;P&gt;If I am right, when a function or subroutine is linked from a static library all the functions and subroutine that where included in the same .obj file are linked at the same time.&lt;/P&gt;
&lt;P&gt;Example&lt;/P&gt;
&lt;P&gt;Library A&lt;/P&gt;
&lt;P style="padding-left: 30px;"&gt;A123.for -&amp;gt; A123.obj source containing A1 A2 and A3 functions&lt;/P&gt;
&lt;P&gt;Library B&lt;/P&gt;
&lt;P style="padding-left: 30px;"&gt;Using A1 and A2 functions&lt;/P&gt;
&lt;P&gt;Library C&lt;/P&gt;
&lt;P style="padding-left: 30px;"&gt;Using A1 and A3 functions&lt;/P&gt;
&lt;P&gt;In this case, if you create an .exe including B+A lib and C+A lib, you will have a multiple definition error for A1 function because A123.obj is included in each library.&lt;/P&gt;
&lt;P&gt;So if you want to avoid multiple definition when including the static library A in static libraries B and C, you must build A with each source file includind only one function or subroutine or carrefully check the cross references of your functions and subroutines in each source file of A library.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;I think that Yougoslav advice to not include A library in B and C libraies is the simpliest way.&lt;/P&gt;</description>
    <pubDate>Tue, 02 Dec 2008 09:43:34 GMT</pubDate>
    <dc:creator>GVautier</dc:creator>
    <dc:date>2008-12-02T09:43:34Z</dc:date>
    <item>
      <title>Linking and function multiple definitions</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Linking-and-function-multiple-definitions/m-p/892713#M78679</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I'm working with Intel Fortran 10. I'll try to explain as easy as possible my problem. I've got three static library A,B and C. B and C uses some functions embedded in A. When I create an application which uses B and C I have to link A also.I don't want this, I want to embed the code of A directly inside B and C to make my application linking only B and C. I do this by setting "Link Library Dependencies" to YES when building B and C but when my application links B and C it finds multiple definitions of A.&lt;/P&gt;
&lt;P&gt;Is possible to embed the code of A inside B and C without making the function of A being visible also from B and C ?&lt;/P&gt;
&lt;P&gt;Hope to be clear...&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;roberto&lt;/P&gt;</description>
      <pubDate>Mon, 01 Dec 2008 17:31:41 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Linking-and-function-multiple-definitions/m-p/892713#M78679</guid>
      <dc:creator>Roberto_Sartori</dc:creator>
      <dc:date>2008-12-01T17:31:41Z</dc:date>
    </item>
    <item>
      <title>Re: Linking and function multiple definitions</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Linking-and-function-multiple-definitions/m-p/892714#M78680</link>
      <description>&lt;P&gt;I think you may need to upgrade to version 11 to get this to work right. You've got the right idea - the "library dependences" option should merge library A with B or C when you build those. I am not sure why you'd get multiple definitions, though.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Dec 2008 19:15:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Linking-and-function-multiple-definitions/m-p/892714#M78680</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2008-12-01T19:15:47Z</dc:date>
    </item>
    <item>
      <title>Re: Linking and function multiple definitions</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Linking-and-function-multiple-definitions/m-p/892715#M78681</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="width: 100%; margin-top: 5px;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/336209"&gt;Steve Lionel (Intel)&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;
&lt;P&gt;I think you may need to upgrade to version 11 to get this to work right. You've got the right idea - the "library dependences" option should merge library A with B or C when you build those. I am not sure why you'd get multiple definitions, though.&lt;/P&gt;
&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;Well, suppose the function fprintf() being in A and both B and C calls fprintf(). If I link B and C merged with A then the code of fprintf() is copied inside B and C but fprintf() becomes also "visible" outside B and C. So when I link B and C in the same project, the linker finds 2 definitions of fprintf(), one in library B and the other in library C. If I need to link also the library A the linker will find a third definition of fprintf().&lt;/P&gt;
&lt;P&gt;In my library, I just want to merge the external functions without making this functions visible from my library too. Some kind of "private merging" of external functions.&lt;/P&gt;
&lt;P&gt;No way with version 10 ?&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Dec 2008 07:57:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Linking-and-function-multiple-definitions/m-p/892715#M78681</guid>
      <dc:creator>Roberto_Sartori</dc:creator>
      <dc:date>2008-12-02T07:57:35Z</dc:date>
    </item>
    <item>
      <title>Re: Linking and function multiple definitions</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Linking-and-function-multiple-definitions/m-p/892716#M78682</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="width: 100%; margin-top: 5px;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/288727"&gt;s.robyx&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;
&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;P&gt;If I link B and C merged with A then the code of fprintf() is copied inside B and C but fprintf() becomes also "visible" outside B and C.&lt;/P&gt;
&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;Don't do it, then.&lt;/P&gt;
&lt;P&gt;Seriously, a "normal" way to use static libraries is to maintain A separately from B and C, not to embed A within B and C. Yes, it's a bit inconvenient having to keep all dependent libraries around, but it's still more inconvenient to have multiple copies of the same code hanging around (especially if they come in different versions)...&lt;/P&gt;
&lt;P&gt;In other words, do not include A into projects of B and C -- only in the target exe.&lt;/P&gt;
&lt;P&gt;If you still want to do it the old way, you can try using /force:multiple linker flag. (I'm not sure it will always work, but you can give it a try).&lt;/P&gt;</description>
      <pubDate>Tue, 02 Dec 2008 08:22:50 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Linking-and-function-multiple-definitions/m-p/892716#M78682</guid>
      <dc:creator>Jugoslav_Dujic</dc:creator>
      <dc:date>2008-12-02T08:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: Linking and function multiple definitions</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Linking-and-function-multiple-definitions/m-p/892717#M78683</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;P&gt;If I am right, when a function or subroutine is linked from a static library all the functions and subroutine that where included in the same .obj file are linked at the same time.&lt;/P&gt;
&lt;P&gt;Example&lt;/P&gt;
&lt;P&gt;Library A&lt;/P&gt;
&lt;P style="padding-left: 30px;"&gt;A123.for -&amp;gt; A123.obj source containing A1 A2 and A3 functions&lt;/P&gt;
&lt;P&gt;Library B&lt;/P&gt;
&lt;P style="padding-left: 30px;"&gt;Using A1 and A2 functions&lt;/P&gt;
&lt;P&gt;Library C&lt;/P&gt;
&lt;P style="padding-left: 30px;"&gt;Using A1 and A3 functions&lt;/P&gt;
&lt;P&gt;In this case, if you create an .exe including B+A lib and C+A lib, you will have a multiple definition error for A1 function because A123.obj is included in each library.&lt;/P&gt;
&lt;P&gt;So if you want to avoid multiple definition when including the static library A in static libraries B and C, you must build A with each source file includind only one function or subroutine or carrefully check the cross references of your functions and subroutines in each source file of A library.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;I think that Yougoslav advice to not include A library in B and C libraies is the simpliest way.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Dec 2008 09:43:34 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Linking-and-function-multiple-definitions/m-p/892717#M78683</guid>
      <dc:creator>GVautier</dc:creator>
      <dc:date>2008-12-02T09:43:34Z</dc:date>
    </item>
  </channel>
</rss>

