Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Linker: Qt 5 + Intel Visual Fortran 2019
Forum Updated to NodeBB v4.3 + New Features

Linker: Qt 5 + Intel Visual Fortran 2019

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 2 Posters 1.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fem_dev
    wrote on last edited by fem_dev
    #1

    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?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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 :-)

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      F 1 Reply Last reply
      1
      • SGaistS SGaist

        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 :-)

        F Offline
        F Offline
        fem_dev
        wrote on last edited by
        #3

        @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'
        
        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          How are you including it ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • F Offline
            F Offline
            fem_dev
            wrote on last edited by
            #5

            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"?

            1 Reply Last reply
            0
            • F Offline
              F Offline
              fem_dev
              wrote on last edited by aha_1980
              #6

              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]

              1 Reply Last reply
              1
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Thank for the feedback !

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved