Objective C++ and Qt

  • 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:


    QT += core gui

    TARGET = untitled
    TEMPLATE = app

    SOURCES += main.cpp

    mac {
    OBJECTIVE_HEADERS += mainwindow.h

    OBJECTIVE_SOURCES += mainwindow.mm



    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    class MainWindow{


    #endif // MAINWINDOW_H


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

    NSString *s= @"string"; //if I take this line in a comment of corse it's working




    Why it doesn't work?

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

    LIBS += -framework Foundation

  • really helpful, thank you Volker

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

Log in to reply

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