My friend and I are porting our software to Mac OSX. The application is heavily built on SDL and we are having a hard time getting SDL linked and compiling in Qt5. We are not using any part of Qt in our code other then using the IDE for cross-platform ease.
Currently, I have SDL framework inside /Library/Frameworks/
Inside application.pro I have:
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp
macx {
INCLUDEPATH += "/Library/Frameworks/SDL.framework/headers/"
}
In main.cpp I obviously have #include "SDL.h" and if I ctrl Click on the SDL.h it shows that it is linking to the framework…
When I go to build/compile I get this error:
14:21:24: Running steps for project BDGame...
14:21:24: Configuration unchanged, skipping qmake step.
14:21:24: Starting: "/usr/bin/make" -w
make: Entering directory `/Users/Kite/Dropbox/Wizardry Games/BDGame/BDGame-build-Desktop_Qt_5_0_0_clang_64bit_SDK-Release'
g++ -headerpad_max_install_names -mmacosx-version-min=10.6 -o BDGame main.o
Undefined symbols for architecture x86_64:
"_main", referenced from:
start in crt1.10.6.o
(maybe you meant: _SDL_main)
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [BDGame] Error 1
make: Leaving directory `/Users/Kite/Dropbox/Wizardry Games/BDGame/BDGame-build-Desktop_Qt_5_0_0_clang_64bit_SDK-Release'
14:21:24: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project BDGame (kit: Desktop Qt 5.0.0 clang 64bit (SDK))
When executing step 'Make'

What am I doing incorrect that is stopping Qt from using SDL?
In your
main.cppfile you have to declareint SDL_main(int, char**)function instead ofmain(). You also need to getSDLMain.handSDLMain.mfiles distributed along with SDL bundle for OS X. These two are required to bootstrap your Cocoa application that will invoke further theSDL_mainfunction.I suppose you use Qt project (*.pro) file. You should have something like this in yours:
qtsdl.pro
QT -= core gui TARGET = qtsdl CONFIG += console CONFIG -= app_bundle TEMPLATE = app INCLUDEPATH += /Library/Frameworks/SDL.framework/Headers LIBS += -framework Cocoa -framework SDL SOURCES += \ main.cpp OBJECTIVE_SOURCES += \ SDLMain.m HEADERS += \ SDLMain.hmain.cpp
SDLMain.h and SDLMain.m take them from SDL framework distribution.