Upd. To help test for various Linux distributions, join the Friends of Risovaska group
Back in early January, I assembled the first working version of
Risasovka for Mac, and only two days ago there was a version that I am not ashamed to show to other people. First, I’ll tell you why porting to Mac took so much time, and then how to build a project on Qt under Mac OS X
Why so long
There was no Mac expert on the team.
Somehow it so happened that the whole Risasaska team was little acquainted with Mac OS X — they used Ubuntu and Windows. We bought a couple of Mac Book's last year, but used them only as additional tools. And only when our long-time friend and experienced makovod
Valery Hiora took us to help, things got off the ground. Especially invaluable was his help in assembling the Universal-version - I tried to assemble it five times in a swoop, without a deep understanding of the internal mechanisms, and each time I didn’t succeed a bit. But now I can read config.log :)
There are bugs in Qt (4.5.0 and 4.5.1) on Mac OS X
I suspect that few people write Mac programs using C ++ and Qt. Apparently, they mostly use native tools - Objective-C, Cocoa. Here and there, in Qt there are minor shortcomings, different behavior of styles and layouts and other troubles.
')
XCode is very different from Visual Studio
Completely different interface schemes, completely different (very weak) Qt support. Until you get used to it, it takes a lot of time for the most simple actions. Moreover, since this is still Unix, so many things need to be taken out into batch files, and not done by hand each time, which also distinguishes development in Mac OS X from development in Windows. I personally really loved the console.
Mac OS X is a completely different world.
For the rest, there was not enough courage to decide for myself that Mac OS X is really another world that needs to be studied, loved and with which to be friends.
A quick tutorial for building a Qt project on Mac OS X
If you have written some kind of Windows application using Qt and want to build it under Mac OS X, here is a brief instruction for you:
1. Install the latest version of Xcode, along with it installs the gcc compiler
2. Download Qt - www.qtsoftware.com/downloads , we downloaded Framework Only (122 Mb)
3. We collect Qt taking into account specifics of the project (we collected the static version):
cd /tmp/qt-mac-opensource-desktop-4.5.1
./configure -prefix /Developer/Qt -qt-zlib -qt-libpng -qt-libjpeg -svg -qt-libtiff
-qt-libmng -qt-gif -qt-sql-sqlite -openssl -universal -sdk /Developer/SDKs/MacOSX10.4u.sdk -static -release
-prefix / Developer / Qt - where to install Qt
-qt-zlib -qt-libpng -qt-libjpeg -svg -qt-libtiff -qt-libmng -qt-gif -qt-sql-sqlite - list of plug-in Qt-plugins
-openssl - build with openssl support (you need to install it in advance)
-universal - to work on Intel and PowerPC processors
-sdk /Developer/SDKs/MacOSX10.4u.sdk - path to SDK 10.4 universal
-static - static version
-release - only release version, because we have already debugged the main Qt bugs
make -j 4 sub-src
sudo make install
-j 4 - to collect in 4 threads, speeds up the assembly in the presence of a dual-core processor, though the machine loads
sub-src - build only Qt “core”, do not collect any examples and additional utilities
Add to ~ / .bash_profile:
PATH="/Developer/Qt/bin:$PATH"
export PATH
export QTDIR=/Developer/Qt
export QMAKESPEC=macx-g++
Everything, Qt is installed.
4. Generate an Xcode project file
Windows project files are typically .sln and .vcproj. They indicate which files belong to the project, which additional libraries to connect, etc. We need to create the same file, but for Xcode. The good news is that you will not have to collect it manually every time you change a project, because this process can be automated.
Assume that our project consists of two folders - MoodBox (UI, network and everything else) and Velasquez (drawing engine). Under Windows, we have MoodBox.vcproj, which includes all the necessary files from the Velasques folder
4.1 Create a file in your favorite editor with a description of the project MacOS.pro
#
TRANSLATIONS = moodbox_en.ts \
moodbox_ru.ts
# Qt
QT += network xml svg
QTPLUGIN += qjpeg qgif qmng qsvg qtiff
#
ICON = moodbox-dock.icns
TARGET = MoodBox
# include
INCLUDEPATH += /sw/include/ImageMagick /sw/include/ImageMagick/Magick++
LIBS += -lMagick++ -lMagickCore -lMagickWand
LIBS += -L/sw/lib/
# DEBUG,
DEFINES += DEBUG
# bundle
data.path = Contents/Resources
data.files = $$(PWD)/Avatars $$(PWD)/Clipart $$(PWD)/Sound $$(PWD)/catalogue.pal
QMAKE_BUNDLE_DATA += data
QMAKE_INFO_PLIST = MoodBox_Info.plist
# , MoodBox,
HEADERS -= _PaletteConverter/stdafx.h \
_PaletteConverter/targetver.h
SOURCES -= _PaletteConverter/PaletteConverter.cpp \
_PaletteConverter/stdafx.cpp \
qtsingleapplication_win.cpp \
qtsingleapplication_x11.cpp
# Velasquez
HEADERS += ../../Velasquez/Qt/backgroundelement.h \
../../Velasquez/Qt/backgroundtool.h \
../../Velasquez/Qt/undocommands.h \
../../Velasquez/Qt/varianthash.h \
../../Velasquez/Qt/vcommon.h
SOURCES += ../../Velasquez/Qt/backgroundelement.cpp \
../../Velasquez/Qt/backgroundtool.cpp \
../../Velasquez/Qt/brushdrawingelement.cpp \
../../Velasquez/Qt/undocommands.cpp \
../../Velasquez/Qt/varianthash.cpp
This file needs to be changed only when changing settings or when including / excluding files from other folders. New files from the MoodBox folder will connect automatically.
4.2 And now we create the make-pro.sh script, which will generate the Xcode project
qmake -project -o MoodBox_Mac.pro
cat MoodBox_Mac.pro MacOS.pro > tmp.pro
mv tmp.pro MoodBox_Mac.pro
qmake -spec macx-xcode MoodBox_Mac.pro
4.3 Open the received MoodBox_Mac.xcodeproj in XCode, agree with the choice of the project folder.
4.4 Go to the menu Xcode: Project - Edit Active Target and set the following parameters:
Architectures = Standard (32-bit Universal)
Base SDK = Mac OS X 10.5
Build active architectures only = disabled
5. Click the big button “Build and Go”
If the project is not very complicated, then the program will compile, link and run. And if it’s complicated (there are dependencies with other libraries, there is a windows-specific code, .qss styles are used extensively), then you will have to do more work - select the platform-specific code in #ifdef, separate the style file into general styles and styles specific to platforms and then glue these files when downloading the application, build third-party libraries with universal support, and much, much more.
But
Mac version of Risovaska -
static.risovaska.ru/Risovaska_Mac.zipSend feedback to this post or to the
Friends of Risovaska community
"