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. Mixing Objective C and C++11
QtWS25 Last Chance

Mixing Objective C and C++11

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 2.4k 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.
  • S Offline
    S Offline
    szatmary
    wrote on last edited by
    #1

    I am unable to mix objective C and C++11 in a single Qt Project. When I try, I get the error:

    error: invalid argument '-std=c++11' not allowed with 'C/ObjC'

    I can however manually modify the Makefile to remove -std=c++11 and -stdlib=libc++ from QMAKE_COMP_QMAKE_OBJECTIVE_CFLAGS, and it works.
    Is this a bug in qmake? Should qmake not be including these values? Or I am missing something? Is there a way to setup my .pro file to create a working Makefile?

    1 Reply Last reply
    0
    • GianlucaG Offline
      GianlucaG Offline
      Gianluca
      wrote on last edited by
      #2

      I use a mix of C++ and Obj-C in the Qt project without any problems.
      What I did it's just to add a source file with exentsion .mm in .pro file:
      @
      OBJECTIVE_SOURCES += objectiveSource.mm
      @

      1 Reply Last reply
      0
      • S Offline
        S Offline
        szatmary
        wrote on last edited by
        #3

        HA! that totally worked. Renaming .m to .mm solved it.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          m -> pure objective-c
          mm -> objective-c++

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          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