Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

where compiler and kit info is saved



  • Hi,

    I have written a simple hello project using qt creator using msvc compilers. And trying to import the same as existing project,
    after deleting pro.user and generated makefiles. however while writing the project i see build section has qmake and nmake entry under the project setting. while importing the same project as a existing one, I do not see qmake entry in build settings. Can any one tell me how can we save qmake , nmake locations, toolkit info and settings in the project so that while importing the project next time I do not need to set all these things once again and just opening .pro file in qtcreater should set these exactly the same when I was writing the project as new one? I am using the same machine for writing and importing the project.

    thanks


  • Lifetime Qt Champion

    @ravi2k18 said in where compiler and kit info is saved:

    how can we save qmake , nmake locations, toolkit info and settings in the project so that while importing the project next time

    You should not do that as it can be different on different machines!
    When opening the project in QtCreator you simply need to select a proper Kit, that's all.
    And if you're working on the same machine why do you need to import your project so often?



  • @jsulm

    if you're working on the same machine why do you need to import your project so often?

    I have work on a existing project to which I need to import, but it is giving me lots of errors. so I thought to write a simple test program and import just to know the root cause of my failures.

    When opening the project in QtCreator you simply need to select a proper Kit.

    Is there a way to write a settings/info of kit in the project. I mean if I have to ship the source code how second person will know about the kits required for building? how will he come to know if the project is written with VS 2015 , 2016, mingw etc and with what setting.

    this is happening in my case even though machine and tools are same.

    thanks.....


  • Lifetime Qt Champion

    @ravi2k18 said in where compiler and kit info is saved:

    but it is giving me lots of errors

    In this case something is wrong on the machine where you're importing. Storing project settings will not help you. What errors do you get? Do you have a valid Kit?

    It doesn't make sense to to store Kit configuration in your project. Because the Kit must be there when importing a project. So, Kit is something the development machine must have in order to be able to load a project.
    A Kit is simply a collection of a compiler and matching Qt version. If one of these things is missing you do not have a working Kit. If for example you do not have Qt matching your compiler then you will not be able to load a project even if you store Kit information inside the project (how can this information install missing Qt?).



  • @jsulm

    Please see the message in qt creator while importing the existing qmake project.
    It has no option to support qmake cmake etc. this is what is creating problem in my exiting qmake project.
    do we have any option to import qmake projects?

    while writing hello project, I choose empty qmake project option and fill up with my code. however while importing the same project I do not have qmake support.

    0_1547470839280_Screenshot from 2019-01-14 18-27-42.jpg


  • Lifetime Qt Champion

    @ravi2k18 There is no need to import a qmake based project - simply open it "File/Open File or Project...".



  • thanks @jsulm it works.

    BTW I have a doubt on qmake project,
    what if someone has written a qmake project under linux qt.
    and if any one else wants to use that project under windows with MSVC. How come the c++ (originally written for linux) source will compile in visual studio? Is the qt framework for linux and windows are exactly same? what about native c++ source code ?

    once again thanks for helping me.....


  • Lifetime Qt Champion

    @ravi2k18 This is exactly why you should NOT store Kits inside your project!
    Usually you simply open your project, written on Linux, on Windows in QtCreator and build. You just need to make sure you have a working Kit on Windows. Sometimes some differences needs to be considered, but this is done inside the pro file.


  • Moderators

    @ravi2k18 to expand a bit to what @jsulm said

    One of the strength of the Qt-Framework is it's cross platform compatibility.
    That means except from a few os-specific quirks, you do not have to change very little when porting to other platforms, if you stick with the Qt_Libary and pure c/cpp code.

    If you have platfrom specific classes / code segments, than Qt comes with a few handy defines.

    //inside the *.pro file
    win32{
    ....
    }
     macx{
    ....
    }
    
    ios {
    ...
    }
    
    android{
    ...
    }
    //etc
    

    inside classes:

    #if defined (Q_OS_ANDROID)
    ...
    #if defined(Q_OS_WIN) 
    ...
    #if defined(Q_OS_MACOS)
    //etc
    

    For more information see here:
    http://doc.qt.io/qt-5/qtglobal.html#Macros



  • @jsulm

    does it mean, qmake will generate different makefiles in windows and linux (optimised and configured based on the OS compilers and used kit) for the same .pro file?

    what about the native c++ code ? is it developers resposibity to write a code supporting both the OS?


  • Lifetime Qt Champion

    @ravi2k18 Yes and Yes.
    It is your responsibility to write platform independent C++ code. Qt helps here as its APIs are platform independent. But if you, for example use Windows API, then this code will only work on Windows. In such cases you can do what @J-Hilk showed.



  • thanks @jsulm and @J-Hilk I really appreciate your help.

    After spending 4 sleepless nights on this, I now got my answer.


Log in to reply