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. Setting Up Qt Creator for MPIC++
Forum Updated to NodeBB v4.3 + New Features

Setting Up Qt Creator for MPIC++

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 997 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.
  • ModelTechM Offline
    ModelTechM Offline
    ModelTech
    wrote on last edited by ModelTech
    #1

    I am trying to configure Qt Creator to use the mpic++ wrapper compiler, but I am experiencing linking issues...

    Starting from what does work: I have created a standard HelloWorld example with the following .pro file

    QMAKE_CC = mpicc
    QMAKE_CXX = mpicxx
    QMAKE_CFLAGS = $$system(mpicc --showme:compile)
    QMAKE_CXXFLAGS = $$system(mpic++ --showme:compile)
    QMAKE_LFLAGS = $$system(mpic++ --showme:link)
    SOURCES += \
        main.cpp
    HEADERS +=
    

    where main.cpp contains the HelloWorld code

    #include <mpi.h>
    #include <stdio.h>   
    int main(int, char **) {
        int Rank, Size, Length;
        char Name[MPI_MAX_PROCESSOR_NAME];
        MPI::Init();
        MPI_Get_processor_name(Name, &Length);
        MPI_Comm_size(MPI_COMM_WORLD, &Size);
        MPI_Comm_rank(MPI_COMM_WORLD, &Rank);
        printf("Hello world from processor %s, rank %d out of %d processors\n", Name, Rank, Size);
        MPI::Finalize();
    }
    

    I managed to get qmake work on my little Ubuntu-based Beowulf cluster (which has the openmpi-bin and libopenmpi-dev packages installed) by simply installing qt5-default package and using qmake (which correctly uses the mpic++ wrapper compiler). This works perfectly and allows me to properly deploy my eventual MPI program. Great :)

    Now, I would like to develop my MPI program on my Ubuntu workstation. So, I have installed the openmpi-bin and libopenmpi-dev packages there. Hence, the mpic++ wrapper compiler and mpirun command are appropriately available on my Ubuntu workstation, meaning that I can compile and run the HelloWorld example by using direct command line execution of the mpic++ wrapper compiler (and subsequently mpirun to execute the program). Also this works perfectly.

    However, using the qmake executable (from the command line) that came with the Qt Creator installation on my Ubuntu workstation gives a bunch of linking errors, which basically state 'undefined reference' for all MPI code. What am I missing?

    I also would like to compile and run my MPI program from the Qt Creator GUI. Apart from the linking errors, I also get the warning that qmake uses the mpic++ wrapper compiler, while the 'kit' is configured to g++. How to fix this warning? I have tried to add a kit by first attempting to auto-detect the mpic++ compiler, but it is not detected. Any ideas on this?

    1 Reply Last reply
    0
    • ModelTechM Offline
      ModelTechM Offline
      ModelTech
      wrote on last edited by ModelTech
      #2

      Ok, diving a bit more into it. This is strange:

      mpic++ --showme:link
      

      returns

      -pthread -L/usr//lib -L/usr/lib/x86_64-linux-gnu/openmpi/lib -lmpi_cxx -lmpi
      

      on my Ubuntu workstation. If I add

      LIBS += -L/usr/lib/x86_64-linux-gnu/openmpi/lib -lmpi_cxx -lmpi
      

      to my .pro file, then it all works. However, I want to avoid adding this to the .pro file as the link flags are different on my Beowulf cluster. So, what is wrong with my original .pro file in the following line?

      QMAKE_LFLAGS = $$system(mpic++ --showme:link)
      
      JoeCFDJ 1 Reply Last reply
      0
      • ModelTechM ModelTech

        Ok, diving a bit more into it. This is strange:

        mpic++ --showme:link
        

        returns

        -pthread -L/usr//lib -L/usr/lib/x86_64-linux-gnu/openmpi/lib -lmpi_cxx -lmpi
        

        on my Ubuntu workstation. If I add

        LIBS += -L/usr/lib/x86_64-linux-gnu/openmpi/lib -lmpi_cxx -lmpi
        

        to my .pro file, then it all works. However, I want to avoid adding this to the .pro file as the link flags are different on my Beowulf cluster. So, what is wrong with my original .pro file in the following line?

        QMAKE_LFLAGS = $$system(mpic++ --showme:link)
        
        JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by
        #3

        @ModelTech in your pro file use similar settings like the following
        win32: {
        }
        unix: {
        LIBS += -L/usr/lib/x86_64-linux-gnu/openmpi/lib -lmpi_cxx -lmpi
        }

        you can even define some env variables for different platforms and use them in your pro file.

        1 Reply Last reply
        0
        • ModelTechM Offline
          ModelTechM Offline
          ModelTech
          wrote on last edited by
          #4

          Both my workstation and Beowulf cluster run the same Ubuntu 18.04 LTS, so I cannot distinguish between them in this way.

          JoeCFDJ 1 Reply Last reply
          0
          • ModelTechM ModelTech

            Both my workstation and Beowulf cluster run the same Ubuntu 18.04 LTS, so I cannot distinguish between them in this way.

            JoeCFDJ Offline
            JoeCFDJ Offline
            JoeCFD
            wrote on last edited by JoeCFD
            #5

            @ModelTech Define an env variable Beowulf for your cluster and query it in the pro file. On your workstation it is not defined.

            1 Reply Last reply
            0
            • ModelTechM Offline
              ModelTechM Offline
              ModelTech
              wrote on last edited by
              #6

              Ok, that is a good idea.

              What I find strange however is that the g++ linker command on my workstation now actually shows two times "-L/usr/lib/x86_64-linux-gnu/openmpi/lib -lmpi_cxx -lmpi" and I do not see why that is needed. This is the shown message:

              g++ -pthread -L/usr//lib -L/usr/lib/x86_64-linux-gnu/openmpi/lib -lmpi_cxx -lmpi -Wl,-rpath,/home/user/Qt/5.12.5/gcc_64/lib -o mpi main.o   -L/usr/lib/x86_64-linux-gnu/openmpi/lib -lmpi_cxx -lmpi /home/user/Qt/5.12.5/gcc_64/lib/libQt5Gui.so /home/user/Qt/5.12.5/gcc_64/lib/libQt5Core.so -lGL -lpthread
              
              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