Planned maintenance has been done but it did not solve the problem. So work will continue on this and a new time for trying updates will be announced asap.

Linker: Qt 5 + Intel Visual Fortran 2019



  • I wrote 2 simple fortran static libraries which have a proper "C ISO Binding" to mix these two with QT 5.13 C/C++ applications.

    a) The first one only sends a single number from Fortran lib to my C++ application: Works perfect
    b) The second one only try to send a simple Fortran string from Fortran lib to my C++ application: linker error!

    unresolved external symbol for_cpystr referenced in function my_long_calc
    

    I don't understand why the first library works well but the second one not link with the QT / C++ application.

    Trying to solve the second library issue, I added to my *.pro file all IVF include/library folders that Microsoft Visual Studio 2019 describes inside your IVF 2019 configuration, but I got the same linker error.

    Maybe should I need to include the IVF library files inside my *.pro file? I don't know...And, if yes, how can I know which library?

    Could you help me?


  • Lifetime Qt Champion

    Hi,

    @fem_dev said in Linker: QT5 + Intel Visual Fortran 2019:

    for_cpystr

    From what I could gather this symbol comes from a runtime library related to FORTRAN. You need to also link to that library.

    On a side note, it's Qt. QT stands for Apple QuickTime which is not what you are currently looking for :-)



  • @sgaist thanks,

    Now I include the path to the Intel Visual Fortran Libs and this error is gone.
    The path is:

    C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.4.245\windows\compiler\lib\ia32_win
    

    Now QT Creator is asking me about a *.obj file. What I have to do?

    error: LNK1104: cannot open file 'C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.4.245\windows\compiler\lib\ia32_win.obj'
    

  • Lifetime Qt Champion

    How are you including it ?



  • Sorry, I was incluing the 32 bit folder....but now I change it to x64 bit lib folder and this error is gone.

    LIBS += -L"C:/Program Files (x86)/IntelSWTools/compilers_and_libraries_2019.4.245/windows/compiler/lib/intel64_win"
    LIBS += ifconsol.lib
    

    The last problem is that my Fortran string is wrong in the output terminal.
    It should be "nyck" and "sara" but it is "nnnnnn" and "sssss"....the first letter repeating 5 times (the allocation size that I set in Fortran string variable).

    My C++ code:

    #include <QCoreApplication>
    #include <iostream>
    
    extern "C" {
      void my_long_calc(void);
      void fortran_message(int* value, char* msg1, size_t* len1, char* msg2, size_t* len2);
    }
    
    void fortran_message(int* value, char* msg1, size_t* len1, char* msg2, size_t* len2)
    {
      std::cout << "value: " << *value << std::endl;
      std::cout << "msg1: " << msg1 << std::endl;
      std::cout << "len1: " << *len1 << std::endl;
      std::cout << "msg2: " << msg2 << std::endl;
      std::cout << "len2: " << *len2 << std::endl;
    }
    
    int main(int argc, char *argv[])
    {
        QCoreApplication a(argc, argv);
    
        my_long_calc();
    
        return a.exec();
    }
    

    My Fortran code:

    module my_interfaces
    interface
      subroutine fortran_message (value, msg1, len1, msg2, len2) bind(C)
        use, intrinsic :: ISO_C_BINDING
        integer(C_INT), intent(in) :: value
        character(kind=C_CHAR), intent(in) :: msg1(*)
        integer(C_SIZE_T), intent(in) :: len1
        character(kind=C_CHAR), intent(in) :: msg2(*)
        integer(C_SIZE_T), intent(in) :: len2
      end subroutine fortran_message
    end interface
    end module my_interfaces
    
    ! My long calc subroutine
    subroutine my_long_calc() BIND(C, name = 'my_long_calc')
        use, intrinsic :: ISO_C_BINDING
        use my_interfaces
        implicit none
        
        integer(C_INT) :: value
        character(kind=C_CHAR) :: msg1(5)
        integer(C_SIZE_T) :: len1
        character(kind=C_CHAR) :: msg2(5)
        integer(C_SIZE_T) :: len2
        
        value = 10
        msg1 = "nyck"//C_NULL_CHAR
        len1 = 13
        msg2 = "sara"//C_NULL_CHAR
        len2 = 15
        
        ! Send a message to the C++ application:
        call fortran_message(value, msg1, len1, msg2, len2)
    end subroutine my_long_calc
    

    The len1 and len2 variables are not important in this example.

    How can I get the correct C++ terminal output "nyck" and "sara"?



  • The complete answer and some details about Qt + IVF can be found here:
    https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/815889#comment-1943689

    [Edit aha_1980: Fixed link]


  • Lifetime Qt Champion

    Thank for the feedback !


Log in to reply