Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Objective C++ and Qt

Objective C++ and Qt

Scheduled Pinned Locked Moved C++ Gurus
4 Posts 2 Posters 5.2k 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.
  • K Offline
    K Offline
    ksiedzulek
    wrote on last edited by
    #1

    Hi,

    I would like to mix up objective C++ and Qt to work bluetooth in my mac desktop project. here is what I did for testing and it's not working. It's 'no sense code', but I would like to run it without errors:

    @
    //untitled.pro

    QT += core gui

    TARGET = untitled
    TEMPLATE = app

    SOURCES += main.cpp

    mac {
    OBJECTIVE_HEADERS += mainwindow.h

    OBJECTIVE_SOURCES += mainwindow.mm
    

    }

    //mainwindow.h

    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    class MainWindow{

    public:
    MainWindow();
    ~MainWindow();
    };

    #endif // MAINWINDOW_H

    //mainwindow.mm

    #include "mainwindow.h"
    #include <Foundation/Foundation.h>

    MainWindow::MainWindow()
    {
    NSString *s= @"string"; //if I take this line in a comment of corse it's working
    }

    MainWindow::~MainWindow()
    {

    }

    @

    Why it doesn't work?

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      You need to add this line to your .pro file:

      @
      LIBS += -framework Foundation
      @

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • K Offline
        K Offline
        ksiedzulek
        wrote on last edited by
        #3

        really helpful, thank you Volker

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          If you're using Qt Creator, then unfortunately the error pane doesn't show that useful error messages. It's just a "symbol(s) not found" and "collect2: ld returned exit status 1". You should go to the compilation pane then, the error messages there are more elaborate.

          In your special case here, if you use a Mac framework, you will have to add it to the LIBS variable. Some of them are added by Qt by default, some need manual addition.

          http://www.catb.org/~esr/faqs/smart-questions.html

          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