[Solved]Class Definitions by Plattform - Problem with Mac



  • Hi!

    I´m having a little issue here that i dont know to solve in MAC compilations.

    I have some classes on my system that are generated in the compilation/build (Object Files .o) depending on the host platform.

    Everyting is working fine , and for Window and Android (MSVC and MinGw) the compiler "remove" the class definiton and build the final code, but in XCode it are generation a empty symbol file error and not compile the Code...

    I´m Using the Qt platform definitions to do that, and this is a example:

    @
    #ifdef Q_OS_WIN
    #include <QOpenGLFunctions>

    class MyMacWin
    {
    MyMacWin();
    }
    #endif
    @
    @
    #ifdef Q_OS_MAC
    #include <QOpenGLFunctions>

    class MyMacOS
    {
    MyMacOS();
    }
    #endif
    @

    If i compile the program in Windows the MSVC compiler properly remove the .o file generated by MyMacOS class and mantain only the definition of MyMacWin class, but when i compile it in MAC instead of be removed or ignored in the Build a error are emmited and the build fails.

    Anyone know how can i setup this in Qt, to tell the compiler remove the .o file and do not generate the error since the clas will not be used?

    Any help will be much appreciated.

    Kind Regards.


  • Lifetime Qt Champion

    Hi,

    The most clean way to do that is to have seperated files for these classes and only build them on the correct platform.

    @
    win32{
    HEADERS += mywinclass.h
    SOURCES += mywinclass.cpp
    }

    macx{
    HEADERS += mymacclass.h
    SOURCES += mymacclass.cpp
    }
    @
    Thus you avoid to build things you shouldn't

    Hope it helps



  • Hi SGaist

    Thanks so much for your help!
    it fits perfectly for my need.

    Its impressive how powerful is the .pro structure/setup of Qt!

    Kind Regards.


  • Lifetime Qt Champion

    You welcome !

    Since you have now your build up and running, please update the thread title prepending [solved] so other forum users may know a solution has been found :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.