Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. mac objective C++, @import not working?
QtWS25 Last Chance

mac objective C++, @import not working?

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
5 Posts 2 Posters 916 Views
  • 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.
  • D Offline
    D Offline
    davecotter
    wrote on last edited by
    #1

    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?

    K 1 Reply Last reply
    0
    • D Offline
      D Offline
      davecotter
      wrote on last edited by
      #5

      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

      1 Reply Last reply
      2
      • D davecotter

        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?

        K Offline
        K Offline
        kenchan
        wrote on last edited by
        #2

        @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.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          davecotter
          wrote on last edited by
          #3

          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

          1 Reply Last reply
          0
          • D Offline
            D Offline
            davecotter
            wrote on last edited by
            #4

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

            1 Reply Last reply
            0
            • D Offline
              D Offline
              davecotter
              wrote on last edited by
              #5

              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

              1 Reply Last reply
              2

              • Login

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