I usually develop application on OSX and iOS. I found that Objective-C is quite useful for many tasks and, in many cases, can speed up work.
I would like to port my applications also on Windows systems. I realized (if you have any other solutions please let me know!) that Qt could be a quite useful tool! Creating GUI with Qt is simple and fast. 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 the OBJECTIVE_SOURCES
and OBJECTIVE_HEADERS
makefile variables.
I searched how to configure Qt Creator to accept .mm
files, but I was not able to get it to work.
Inside the .pro
file I have something like 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
...
My very simple project is a widget (.h
and .cpp
), the main.cpp
and test.h
with its test.mm
. To mix C++ and Objective-C I thought about a "bridge" (just like I do in the Cocoa when mixing Objective-C and C++), so I create the test.h
as a simple header (no Objective-C, only a bridge):
// test.h
void testFunction( void );
than:
// test.mm
#import <Foundation/Foundation.h>
void testFunction( void ) {
NSString* string;
string = @"This is a test string";
NSLog( @"%@", string );
}
finally:
// main.cpp
...
#include "test.h"
...
testFunction();
...
The linker gives me the classic "undefined reference to function testFunction". Something like it can not link the .o
object files created from .mm
files.
Can anyone of you tell me if something is wrong with this process or points me to a tutorial on how to configure Qt to accept Objective-C language?
There is another solution that I really like, it's pure Objective-C, i.e. using the GNUStep Gorm interface builder, but, unfortunately, GUIs built with Gorm are completely not accessible with accessibility tools like Jaws or NVDA, and I need to create some applications for visually impaired people!
Thank you very much