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

mac objective C++, @import not working?



  • 1: must i name an objective C++ file with .mm extension? i can name it with .cpp in xcode and just tell xcode what compiler to use for that file, and it works. in my pro file i added the .cpp file to OBJECTIVE_SOURCES but that didn't seem to help?

    2: when i have @import <some framework>, i get this error:

    error: use of '@import' when C++ modules are disabled, consider using -fmodules and -fcxx-modules
    

    so i add this to my PRO file:

    QMAKE_CXXFLAGS += -fcxx-modules
    

    and now i see this in my compiler output:

    clang: warning: argument unused during compilation: '-fcxx-modules'
    

    what am i missing here?



  • buried in some obscure forum, apparently the correct method is

    for an objectiveC++ framework, you can't add the path this way:

    QMAKE_LFLAGS += -F$${DIR_PADDLE_FRAMEWORK}
    

    you have to add it this way:

    QMAKE_OBJECTIVE_CFLAGS += -F$${DIR_PADDLE_FRAMEWORK}
    

    Then it will somehow @import



  • @davecotter
    Hi, I use the .mm extension and #include instead of @import.
    I put the path to .mm source file in the OBJECTIVE_SOURCES section of the pro file and it all seems to work fine.



  • I've tried all these and none work:

    //@#import <Paddle/Paddle.h>
    //#include <Paddle.framework/Headers/Paddle.h>
    //#import <Paddle/Paddle.h>
    //#import <Paddle>
    //@import Paddle
    #include <Paddle/Paddle.h>
    

    and yes the folder that contains the framework is in my includes path, and the framework is also added in the pro file

    DIR_PADDLE_FRAMEWORK	= $${DIR_EXTERNAL}Paddle/Mac/framework.4.0.11/
    QMAKE_LFLAGS += -F$${DIR_PADDLE_FRAMEWORK}
    LIBS += -framework Paddle
    INCLUDEPATH += $${DIR_PADDLE_FRAMEWORK}
    

    0_1556038384185_Screen Shot 2019-04-23 at 9.51.49 AM.png

    but really, i want to know how i can use @import



  • i'm praying that someone who uses objC++ in QT with "modules" can chime in here? pretty please?



  • buried in some obscure forum, apparently the correct method is

    for an objectiveC++ framework, you can't add the path this way:

    QMAKE_LFLAGS += -F$${DIR_PADDLE_FRAMEWORK}
    

    you have to add it this way:

    QMAKE_OBJECTIVE_CFLAGS += -F$${DIR_PADDLE_FRAMEWORK}
    

    Then it will somehow @import


Log in to reply