<?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 UPDATE 1: in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168142#M145080</link>
    <description>&lt;P&gt;&lt;STRONG&gt;UPDATE 1:&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;I followed the Intel Tutorial about mixed-language applications and set the configurations for use Intel Visual Fortran 2019 for build x64 applications.&lt;/P&gt;&lt;P&gt;After this, I cleaned my Solution and rebuild.&lt;/P&gt;&lt;P&gt;The Fortran Static library project compiles Ok!&lt;STRONG&gt; No errors!&lt;/STRONG&gt;&lt;BR /&gt;But the C++ linker shows me these&lt;STRONG&gt; 2 old erros:&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE class="brush:bash; class-name:dark;"&gt;unresolved external symbol ISO_C_BINDING_mp_C_LOC_PRIVATE referenced in function f_subroutine&amp;nbsp;&amp;nbsp; &amp;nbsp;c_str_test

unresolved external symbol c_f_pointer_set_scalar referenced in function f_subroutine&amp;nbsp;&amp;nbsp; &amp;nbsp;c_str_test&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&lt;STRONG&gt;Before &lt;/STRONG&gt;this configuration I had only the linker error about 'ifconsol.lib'...and if I go back to the old configurations (without Intel Tutorial) these 2 erros above still the same.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;What I'm doing wrong?&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 24 Sep 2019 17:49:21 GMT</pubDate>
    <dc:creator>Maia__Nycholas</dc:creator>
    <dc:date>2019-09-24T17:49:21Z</dc:date>
    <item>
      <title>Interoperability: Linux (Segmentation fault)</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168135#M145073</link>
      <description>&lt;P&gt;Hi @Steve,&lt;/P&gt;&lt;P&gt;Thank you so much for your `module str_routines`. It can convert C char array to a Fortran string and works great in Windows x64 (Microsoft Visual Studio 2019 + Intel Visual Fortran 2019).&lt;/P&gt;&lt;P&gt;Now, I'm trying to use it on Linux (Ubuntu 18 x64) but I got a segmentation fault error inside of it and I don't know why it's happening.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Here is my C++ source-code:&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE class="brush:cpp; class-name:dark;"&gt;extern "C" {
	void f_subroutine(const char* c_str);
}

int main(void)
{
	const char c_str[5] = "test";

	f_subroutine(c_str);

	return 0;
}&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Here is my Fortran source-code:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE class="brush:fortran; class-name:dark;"&gt;module str_routines
    contains        
        subroutine C_F_STRPOINTER (STRARRAY, FSTRPTR, MAXLEN)
            use, intrinsic :: ISO_C_BINDING

            implicit none
            character, dimension(*), target, intent(in) :: STRARRAY
            character(:), pointer, intent(out) :: FSTRPTR
            integer, intent(in), optional :: MAXLEN

            integer :: curlen

            curlen = 0

            do
                curlen = curlen +1
                if (PRESENT(MAXLEN)) THEN
                    if (curlen &amp;gt; MAXLEN) exit
                end if

                if (STRARRAY(CURLEN) == CHAR(0)) exit
            end do

            call doassign(C_LOC(STRARRAY), FSTRPTR, curlen-1)

            contains
                subroutine doassign(CSTRPTR, FSTRPTR, STRLEN)
                    type(C_PTR), intent(in) :: CSTRPTR
                    character(:), pointer, intent(out) :: FSTRPTR
                    integer, intent(in) :: STRLEN
                    character(STRLEN), pointer :: p

                    call C_F_POINTER(CSTRPTR, p)
                    FSTRPTR =&amp;gt; p
                    return
                end subroutine doassign
        end subroutine C_F_STRPOINTER
end module str_routines

subroutine f_subroutine(c_str) bind(C)
    use, intrinsic :: ISO_C_BINDING
    use str_routines

    implicit none
    character(kind=C_CHAR), target, intent(in) :: c_str(*)
    character(kind=C_CHAR, len=:), pointer :: f_str

    ! Convert C char array to Fortran string:
    call C_F_STRPOINTER (c_str, f_str)
end subroutine f_subroutine&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Compile and link sequence:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE class="brush:bash; class-name:dark;"&gt;// Compile the Fortran file to a object:
gfortran -c -g fortran.90

// Create a Linux static library
ar -cr libmylib.a fortran.o

// Compile C++ and link it with the Fortran static library
g++ -Wall main.cpp -L. -lmylib -lgfortran -o app

// Run it:
./app

// Console error:
Segmentation fault (core dumped)&lt;/PRE&gt;

&lt;P&gt;To inspect what it causing this run-time error, I debugged it using Qt Creator IDE on Linux.&lt;BR /&gt;&lt;STRONG&gt;Here is my debug session and local variables values:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="seg_fault_linux.png"&gt;&lt;img src="https://community.intel.com/t5/image/serverpage/image-id/10554iC0AEC96D01D370EE/image-size/large?v=v2&amp;amp;px=999&amp;amp;whitelist-exif-data=Orientation%2CResolution%2COriginalDefaultFinalSize%2CCopyright" role="button" title="seg_fault_linux.png" alt="seg_fault_linux.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;As you can see, I got a&lt;STRONG&gt; "Segmentation Fault" &lt;/STRONG&gt;error in the &lt;STRONG&gt;line 34.&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE class="brush:fortran; class-name:dark;"&gt;FSTRPTR =&amp;gt; p&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Could you please help me to solve it?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Thank you again,&lt;BR /&gt;Nycholas Maia&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2019 18:29:29 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168135#M145073</guid>
      <dc:creator>Maia__Nycholas</dc:creator>
      <dc:date>2019-09-23T18:29:29Z</dc:date>
    </item>
    <item>
      <title>You're using gfortran - I can</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168136#M145074</link>
      <description>&lt;P&gt;You're using gfortran - I can't help with that. It may be that gfortran doesn't fully or properly implement deferred-length character pointers. I notice in your screenshot that the debugger claims that the type of _fstrptr is integer(4) - that doesn't seem right.&lt;/P&gt;&lt;P&gt;Come back here if it doesn't work in Intel Fortran.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2019 20:33:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168136#M145074</guid>
      <dc:creator>Steve_Lionel</dc:creator>
      <dc:date>2019-09-23T20:33:35Z</dc:date>
    </item>
    <item>
      <title>This is for other readers who</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168137#M145075</link>
      <description>&lt;P&gt;This is for other readers who may be open to advice such as the one provided by Jim Dempsey where he states, "As it stands, a helper function is required on one side or the other. My preference is to do this on the C/C++ side.", in this other thread by OP:&amp;nbsp;https://software.intel.com/en-us/forums/intel-fortran-compiler/topic/815905 which then can lead to really short and simple code that is easier on both readers as well as processors:&lt;/P&gt;
&lt;PRE class="brush:cpp; class-name:dark;"&gt;#include &amp;lt;cstring&amp;gt;

extern "C" {
	void f_subroutine(const char* , size_t);
}

int main(void)
{
	char c_str[] = "Test"; //&amp;lt;-- Note no hard-wired length

	f_subroutine(c_str, strlen(c_str));

	return 0;
}
&lt;/PRE&gt;

&lt;PRE class="brush:fortran; class-name:dark;"&gt;subroutine f_subroutine(c_str, lens) bind(C, name="f_subroutine")
! Module procedures are recommended
   use, intrinsic :: iso_c_binding, only : c_loc, c_f_pointer, c_char, c_size_t

   ! Argument list
   character(kind=c_char, len=1), target, intent(in) :: c_str(*)
   integer(kind=c_size_t), intent(in), value         :: lens

   if ( lens &amp;gt; 0 ) then
      block
         character(kind=c_char, len=lens), pointer :: pfstr
         call c_f_pointer( c_loc(c_str), fptr=pfstr )
         print *, "In f_subroutine: Fortran incarnation of c_str: ", pfstr
         pfstr =&amp;gt; null()
      end block
   end if

   return

end subroutine f_subroutine
&lt;/PRE&gt;

&lt;P&gt;Upon execution of code built with either gfortran or Intel Fortran, the output is as follows:&lt;/P&gt;

&lt;PRE class="brush:plain; class-name:dark;"&gt; In f_subroutine: Fortran incarnation of c_str: Test

&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Sep 2019 00:48:28 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168137#M145075</guid>
      <dc:creator>FortranFan</dc:creator>
      <dc:date>2019-09-24T00:48:28Z</dc:date>
    </item>
    <item>
      <title>Hi Steve and FortranFan,</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168138#M145076</link>
      <description>&lt;P&gt;Hi Steve and FortranFan,&lt;/P&gt;&lt;P&gt;Thank you all for the informations.&lt;BR /&gt;&lt;BR /&gt;I tried the FortranFan solution and&lt;STRONG&gt; it works perfect using gfortran&lt;/STRONG&gt;. Just "copy and paste" and it &lt;STRONG&gt;works great!&lt;/STRONG&gt;&lt;BR /&gt;Now, when I did the same thing using&lt;STRONG&gt;&amp;nbsp;Intel Visual Fortran 2019&lt;/STRONG&gt; I got a compile-time error related with this Fortran source-code&amp;nbsp;line:&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="brush:fortran; class-name:dark;"&gt;call c_f_pointer( c_loc(c_str), fptr=pfstr )&lt;/PRE&gt;

&lt;P&gt;So, Visual Studio 2019 give me theses erros below:&lt;/P&gt;

&lt;PRE class="brush:bash; class-name:dark;"&gt;unresolved external symbol ISO_C_BINDING_mp_C_LOC_PRIVATE referenced in function f_subroutine

unresolved external symbol c_f_pointer_set_scalar referenced in function f_subroutine&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Question 1:&lt;/STRONG&gt;&lt;BR /&gt;Do you have any ideas why it's happening when I &lt;STRONG&gt;use IVF 2019? How can I solve it?&lt;BR /&gt;&lt;BR /&gt;Question 2:&lt;/STRONG&gt;&lt;BR /&gt;FortranFan, in the C++ side, your source-code exemple have this C string observation:&lt;/P&gt;

&lt;PRE class="brush:cpp; class-name:dark;"&gt;char c_str[] = "Test"; //&amp;lt;-- Note no hard-wired length&lt;/PRE&gt;

&lt;P&gt;It works good!&lt;BR /&gt;But this modified version below&lt;STRONG&gt; works good&lt;/STRONG&gt; &lt;STRONG&gt;too (at moment, only tested using gfortran)&lt;/STRONG&gt;.&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:cpp; class-name:dark;"&gt;char&amp;nbsp;c_str[30] =&amp;nbsp;"Test";&lt;/PRE&gt;

&lt;P&gt;It prints the correct C string with no blank spaces like the original one.&lt;/P&gt;
&lt;P&gt;So, why should I use the original "hard-wired length"? &lt;STRONG&gt;Is there any C-Fortran interoperability advantages?&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;Thank you all,&lt;/P&gt;</description>
      <pubDate>Tue, 24 Sep 2019 14:26:11 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168138#M145076</guid>
      <dc:creator>Maia__Nycholas</dc:creator>
      <dc:date>2019-09-24T14:26:11Z</dc:date>
    </item>
    <item>
      <title>You did not get a compile</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168139#M145077</link>
      <description>&lt;P&gt;You did not get a compile-time error. This is a link-time error and indicates you did not supply the proper libraries when you linked your code. You need to add ifmodintr.lib if you've disabled default library search rules.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Sep 2019 15:43:19 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168139#M145077</guid>
      <dc:creator>Steve_Lionel</dc:creator>
      <dc:date>2019-09-24T15:43:19Z</dc:date>
    </item>
    <item>
      <title>&gt;&gt;unresolved external symbol</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168140#M145078</link>
      <description>&lt;P&gt;&amp;gt;&amp;gt;unresolved external symbol&lt;/P&gt;&lt;P&gt;Either bug or linking in incorrect Fortran runtime library.&lt;/P&gt;&lt;P&gt;BTW - c_loc should be an intrinsic function resolved at compile time, not an external function executed at runtime. This would seem to indicate bug.&lt;/P&gt;&lt;P&gt;Try adding just below BLOCK:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; use, intrinsic :: iso_c_binding, only : c_loc, c_f_pointer, c_char&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&lt;EM&gt;So, why should I use the original "hard-wired length"? Is there any C-Fortran interoperability advantages?&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;In the event you want to receive text. In this case though you would likely pass sizeof(c_str) as opposed to strlen(c_str), and modify helper function to, for input, use lesser value of the search for NULL or passed in length.&lt;/P&gt;&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Tue, 24 Sep 2019 15:46:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168140#M145078</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2019-09-24T15:46:46Z</dc:date>
    </item>
    <item>
      <title>@Steve, you are right!Now, I</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168141#M145079</link>
      <description>&lt;P&gt;@Steve, &lt;STRONG&gt;you are right!&lt;/STRONG&gt;&lt;BR /&gt;Now, I change the Fortran project configuration to:&lt;BR /&gt;disabled default library search rules: &lt;STRONG&gt;NO&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;And that "unresolved external" old error is gone.&lt;BR /&gt;&lt;BR /&gt;So, in Visual Studio 2019, I have&lt;STRONG&gt; 1 solution with 2 projects:&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;C++ console app&lt;/LI&gt;&lt;LI&gt;Fortran Static Library&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;With this help from Steve, now I can compile the Fortran library project with &lt;STRONG&gt;no errros. Good!&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;So, the last linker error is when I try to build and link the C++ project with the Fortran library file. I got this linker error:&lt;/P&gt;
&lt;PRE class="brush:; class-name:dark;"&gt;cannot open file 'ifconsol.lib'&lt;/PRE&gt;

&lt;P&gt;I already added in the C++ project properties:&lt;/P&gt;
&lt;P&gt;Linker -&amp;gt; General -&amp;gt; Additional Library Directories:&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;&lt;LI&gt;C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.4.245\windows\compiler\lib\intel64_win&lt;/LI&gt;&lt;LI&gt;C:\Users\lamar\Desktop\f_str_lib\x64\Debug&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Linker -&amp;gt; General -&amp;gt; Link Library Dependencies: YES&lt;BR /&gt;Linker -&amp;gt; Input -&amp;gt; Additional Dependecies: f_str_lib.lib; %(AdditionalDependencies)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2- Right-click on Solution name -&amp;gt; Project Dependencies: and set the correct dependency order.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;AND&amp;nbsp;&lt;/STRONG&gt;In my Fortran Static Library project I setted:&lt;/P&gt;
&lt;P&gt;Tools -&amp;gt; Options -&amp;gt; Intel Compilers and Tools -&amp;gt; Visual Fortran -&amp;gt; Compilers -&amp;gt; x64:&lt;BR /&gt;&lt;STRONG&gt;Includes:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE class="brush:bash; class-name:dark;"&gt;C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.4.245\windows\compiler\include&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Libraries:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE class="brush:bash; class-name:dark;"&gt;C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.4.245\windows\compiler\lib\intel64_win&lt;/PRE&gt;

&lt;P&gt;Finally, I followed this Intel&amp;nbsp;tutorial:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://software.intel.com/en-us/articles/configuring-visual-studio-for-mixed-language-applications"&gt;https://software.intel.com/en-us/articles/configuring-visual-studio-for-mixed-language-applications&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;What more I have to do to link the 'ifconsol.lib' to my C++ application?&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Sep 2019 16:25:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168141#M145079</guid>
      <dc:creator>Maia__Nycholas</dc:creator>
      <dc:date>2019-09-24T16:25:00Z</dc:date>
    </item>
    <item>
      <title>UPDATE 1:</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168142#M145080</link>
      <description>&lt;P&gt;&lt;STRONG&gt;UPDATE 1:&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;I followed the Intel Tutorial about mixed-language applications and set the configurations for use Intel Visual Fortran 2019 for build x64 applications.&lt;/P&gt;&lt;P&gt;After this, I cleaned my Solution and rebuild.&lt;/P&gt;&lt;P&gt;The Fortran Static library project compiles Ok!&lt;STRONG&gt; No errors!&lt;/STRONG&gt;&lt;BR /&gt;But the C++ linker shows me these&lt;STRONG&gt; 2 old erros:&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE class="brush:bash; class-name:dark;"&gt;unresolved external symbol ISO_C_BINDING_mp_C_LOC_PRIVATE referenced in function f_subroutine&amp;nbsp;&amp;nbsp; &amp;nbsp;c_str_test

unresolved external symbol c_f_pointer_set_scalar referenced in function f_subroutine&amp;nbsp;&amp;nbsp; &amp;nbsp;c_str_test&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&lt;STRONG&gt;Before &lt;/STRONG&gt;this configuration I had only the linker error about 'ifconsol.lib'...and if I go back to the old configurations (without Intel Tutorial) these 2 erros above still the same.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;What I'm doing wrong?&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Sep 2019 17:49:21 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168142#M145080</guid>
      <dc:creator>Maia__Nycholas</dc:creator>
      <dc:date>2019-09-24T17:49:21Z</dc:date>
    </item>
    <item>
      <title>Same problem as above. If you</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168143#M145081</link>
      <description>&lt;P&gt;Same problem as above. If you're building a mixed language application where the main program is not Fortran, set the "Disable default library search rules" to No in the Fortran Library project. It defaults to Yes as this is generally what you want when the main is Fortran.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Sep 2019 19:16:51 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168143#M145081</guid>
      <dc:creator>Steve_Lionel</dc:creator>
      <dc:date>2019-09-24T19:16:51Z</dc:date>
    </item>
    <item>
      <title>I already did it...but it</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168144#M145082</link>
      <description>&lt;P&gt;I already did it...but it doesn't resolved the C++ linker problem.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="fortran1.jpg"&gt;&lt;img src="https://community.intel.com/t5/image/serverpage/image-id/10555iAD4B7C3B32A1F9AC/image-size/large?v=v2&amp;amp;px=999&amp;amp;whitelist-exif-data=Orientation%2CResolution%2COriginalDefaultFinalSize%2CCopyright" role="button" title="fortran1.jpg" alt="fortran1.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Do you have any idea?&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Sep 2019 19:31:11 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168144#M145082</guid>
      <dc:creator>Maia__Nycholas</dc:creator>
      <dc:date>2019-09-24T19:31:11Z</dc:date>
    </item>
    <item>
      <title>Did you rebuild the Fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168145#M145083</link>
      <description>&lt;P&gt;Did you rebuild the Fortran library after changing the setting? If yes and you still have the problem, add ifmodintr.lib to "Additional Dependencies" in the C++ project's Linker properties.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Sep 2019 20:25:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168145#M145083</guid>
      <dc:creator>Steve_Lionel</dc:creator>
      <dc:date>2019-09-24T20:25:17Z</dc:date>
    </item>
    <item>
      <title>Thank you @Steve! You are</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168146#M145084</link>
      <description>&lt;P&gt;Thank you @Steve! You are great!&lt;BR /&gt;Yes, I just add the 'ifmodintr.lib' to&amp;nbsp;&amp;nbsp;"Additional Dependencies" in the C++ project's Linker properties and all goes Ok!&lt;BR /&gt;&lt;BR /&gt;Is there any documentation about this 'libraries dependencies'? In a future, how could I known which library name is missing in the "Additional Dependencies" field?&lt;BR /&gt;&lt;BR /&gt;Thank you again!&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2019 12:44:42 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168146#M145084</guid>
      <dc:creator>Maia__Nycholas</dc:creator>
      <dc:date>2019-09-25T12:44:42Z</dc:date>
    </item>
    <item>
      <title>Normally, when you compile a</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168147#M145085</link>
      <description>&lt;P&gt;Normally, when you compile a Fortran source, it adds linker directives to the object file naming the libraries it wants the linker to pull in. When you USE ISO_C_BINDING it adds a directive for ifmodintr.lib (you can see the OBJCOMMENT directive in the source for the module in the ifort include folder).&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is a compiler option to disable adding these directives (/libdir:[no]auto), which is what the "Disable OBJCOMMENT Library Names" property adjusts. For static library projects the default is Yes (don't include OBJCOMMENT directives), as one typically wants the main program to control this.&lt;/P&gt;&lt;P&gt;With a non-Fortran main, however, there's nothing to specify which Fortran support libraries are pulled in other than the OBJCOMMENT directives, so you generally want to include those in your library build.&lt;/P&gt;&lt;P&gt;I still think that if you had rebuilt your library with the option properly set that it would have worked ok for you. I had thought there was documentation on the list of libraries, but I can't find it. I did find a page "Specifying Consistent Library Types", but it is not only incomplete but woefully out of date (mentions libc.lib, which no longer exists, plus says "ifcore.lib" which never existed.) I will report this to Intel.&lt;/P&gt;&lt;P&gt;If you want to see the list of libraries the compiler wants, do a:&lt;/P&gt;&lt;P&gt;dumpbin -directives&lt;/P&gt;&lt;P&gt;on a compiled .obj. You'll get something like this:&lt;/P&gt;
&lt;PRE class="brush:plain; class-name:dark;"&gt;   Linker Directives
   -----------------
   -defaultlib:ifconsol
   -defaultlib:libifcoremt
   -defaultlib:libifport
   -defaultlib:libmmt
   -defaultlib:LIBCMT
   -defaultlib:libirc
   -defaultlib:svml_dispmt
   -defaultlib:OLDNAMES&lt;/PRE&gt;

&lt;P&gt;I would ignore OLDNAMES - that's a historical artifact. Note that the list of libraries will vary depending on other compiler options and modules used.&lt;/P&gt;
&lt;P&gt;Last, now that this forum has been merged for all platforms, I need to say that all of the above applies to Windows only. Linux/Mac doesn't have a similar mechanism, leaving you to explicitly name all of the support libraries needed if you're not using "ifort" to link.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2019 14:54:16 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168147#M145085</guid>
      <dc:creator>Steve_Lionel</dc:creator>
      <dc:date>2019-09-25T14:54:16Z</dc:date>
    </item>
    <item>
      <title>Quote:Maia, Nycholas wrote:</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168148#M145086</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;Maia, Nycholas wrote:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;..&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Question 2:&lt;/STRONG&gt;&lt;BR /&gt;FortranFan, in the C++ side, your source-code exemple have this C string observation:&lt;/P&gt;
&lt;PRE class="brush:cpp; class-name:dark;"&gt;char c_str[] = "Test"; //&amp;lt;-- Note no hard-wired length&lt;/PRE&gt;

&lt;P&gt;It works good!&lt;BR /&gt;But this modified version below&lt;STRONG&gt; works good&lt;/STRONG&gt; &lt;STRONG&gt;too (at moment, only tested using gfortran)&lt;/STRONG&gt;.&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:cpp; class-name:dark;"&gt;char&amp;nbsp;c_str[30] =&amp;nbsp;"Test";&lt;/PRE&gt;

&lt;P&gt;It prints the correct C string with no blank spaces like the original one.&lt;/P&gt;
&lt;P&gt;So, why should I use the original "hard-wired length"? &lt;STRONG&gt;Is there any C-Fortran interoperability advantages?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;..&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Re: "why should I use the original "hard-wired length"?," yes, why should you!?&amp;nbsp; That was my point, that it's high-time coders moved beyond hard-wired string lengths that lead to so many issues: compile-time errors, run-time errors, wasted space.&amp;nbsp; As a matter of good coding practice, whether it be in Fortran or other languages, coders can try to utilize the capabilities to &lt;STRONG&gt;right-size&lt;/STRONG&gt; their data.&amp;nbsp; And where Fortran falls short (like a true intrinsic derived type for strings, they should expect and request language improvements:&lt;/P&gt;

&lt;PRE class="brush:cpp; class-name:dark;"&gt;#include &amp;lt;iostream&amp;gt;
using namespace std;

extern "C" {
	void f_subroutine(const char* , size_t);
}

int main(void)
{
   // No guessing as to the length of string constant
	string s = "../files/json_files/my_json_file.json";
   cout &amp;lt;&amp;lt; "length of string: " &amp;lt;&amp;lt; s.size() &amp;lt;&amp;lt; endl;

   f_subroutine( s.c_str(), s.size() );

	return 0;
}
&lt;/PRE&gt;

&lt;P&gt;Upon execution,&lt;/P&gt;

&lt;PRE class="brush:plain; class-name:dark;"&gt;length of string: 37
 In f_subroutine: Fortran incarnation of c_str: ../files/json_files/my_json_file.json
&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2019 21:53:52 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168148#M145086</guid>
      <dc:creator>FortranFan</dc:creator>
      <dc:date>2019-09-25T21:53:52Z</dc:date>
    </item>
    <item>
      <title>Thank you @FortranFan for</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168149#M145087</link>
      <description>&lt;P&gt;Thank you @FortranFan for your &lt;STRONG&gt;good &lt;/STRONG&gt;explanation about this issue.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2019 13:06:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168149#M145087</guid>
      <dc:creator>Maia__Nycholas</dc:creator>
      <dc:date>2019-09-26T13:06:04Z</dc:date>
    </item>
    <item>
      <title>FWIW&gt;&gt;</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168150#M145088</link>
      <description>&lt;P&gt;FWIW&amp;gt;&amp;gt;&lt;/P&gt;
&lt;PRE class="brush:fortran; class-name:dark;"&gt;   // No guessing as to the length of string constant
	string s = "../files/json_files/my_json_file.json";
&lt;/PRE&gt;

&lt;P&gt;s is not a string constant, it is declared as variable. Also note that&amp;nbsp;the attribute of the segment(linker section)&amp;nbsp;holding the buffer for s should contain Read/Write.&lt;/P&gt;
&lt;P&gt;There is nothing to say that f_subroutine could not modify s. s could be declared with const and &lt;EM&gt;may &lt;/EM&gt;place the buffer in a Read-Only segment when you really desire to have it a string constant.&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2019 14:49:33 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168150#M145088</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2019-09-26T14:49:33Z</dc:date>
    </item>
    <item>
      <title>Quote:jimdempseyatthecove</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168151#M145089</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;jimdempseyatthecove (Blackbelt) wrote:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FWIW&amp;gt;&amp;gt;&lt;/P&gt;
&lt;PRE class="brush:fortran; class-name:dark;"&gt;   // No guessing as to the length of string constant
	string s = "../files/json_files/my_json_file.json";
&lt;/PRE&gt;

&lt;P&gt;s is not a string constant, it is declared as variable. Also note that&amp;nbsp;the attribute of the segment(linker section)&amp;nbsp;holding the buffer for s should contain Read/Write.&lt;/P&gt;
&lt;P&gt;There is nothing to say that f_subroutine could not modify s. s could be declared with const and &lt;EM&gt;may &lt;/EM&gt;place the buffer in a Read-Only segment when you really desire to have it a string constant.&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Just to be clear: s is a variable, an object instance of 'string' class in C++.&amp;nbsp; It's the string literal on the right-hand side of the assignment is what I meant by constant; per Fortran standard terminology, that would be a "character literal constant"&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2019 17:08:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Interoperability-Linux-Segmentation-fault/m-p/1168151#M145089</guid>
      <dc:creator>FortranFan</dc:creator>
      <dc:date>2019-09-26T17:08:17Z</dc:date>
    </item>
  </channel>
</rss>

