Blending Qt and Objective-C on Windows

I usually develop applications on OSX and iOS. I found that Objective-C is very useful for many tasks and can speed things up in many cases.

I would also like to port my applications to Windows systems. I realized (if you have other solutions, let me know!) That Qt can be a very useful tool! Creating a GUI with Qt is quick and easy. The problem is that Qt works with C ++, and OSX works with Objective-C.

I read that Qt can handle Objective-C sources, in fact you can find makefile OBJECTIVE_SOURCESand variables OBJECTIVE_HEADERS.

I was looking for how to configure Qt Creator to receive files .mm, but I could not get it to work.

Inside the file .pro, I have something like the following:

    ...
    OBJECTIVE_SOURCES += \
        test.mm
    INCLUDEPATH += "C:\GNUStep\...\Headers" 
    LIBS += -L"C:\GNUStep\...\Libraries" -lobjc -lgnustep-base
    QMAKE_CXXFLAGS += -fconstant-string-class=NSConstantString -std=c99
    ...

- (.h .cpp), main.cpp test.h test.mm. ++ Objective-C, "" ( Cocoa Objective-C ++), test.h (no Objective-C, ):

    // test.h
    void testFunction( void );

:

    // test.mm
    #import <Foundation/Foundation.h>

    void testFunction( void ) {
       NSString* string;

       string = @"This is a test string";
       NSLog( @"%@", string ); 
    }

:

    // main.cpp
    ...
    #include "test.h"

    ...
    testFunction();
    ...

"undefined testFunction". .o, .mm.

- , - , Qt Objective-C?

, : Objective-C, GNUStep Gorm, , , , Gorm, , Jaws NVDA, !

+4
1

"undefined testFunction", , - testFunction.

, Objective-c Qt C .m .mm, Objective-c .pro OBJECTIVE_SOURCES

Objective-c , NSString, (). Foundation.

, config (.pro): -

LIBS += -framework Foundation 

, Appkit, : -

LIBS += -framework Foundation 
LIBS += -framework AppKit

.pro - : -

QMAKE_CXXFLAGS += -F/Library/Frameworks
QMAKE_CFLAGS += -F/Library/Frameworks
QMAKE_LFLAGS += -F/Library/Frameworks

NSString , , include, Objective-c: -

#import <Foundation/NSString.h>
+1

All Articles