HotShotsのMac Lion版を作っては見たが...

Post date: 2013/09/25 15:48:21

HotShotsは、screen captureソフトだがannotationと元画像の両方を保存できるのが特長。Qtベースで、Linux版とWindows版がリリースされているオープンソース。1.2.1でMacはテストしてないと書いてあったがなんとかなるだろうと思ってmakeしてみた。

結局、スクリーン全体capture以外のWindowGrabberルーチンがMac用に作成されてないのと、画像エディタでマウスの位置が実際の位置から少しずれるので現時点では実用に耐えない。ただこれらの問題が解決すれば、Linux版、Windows版と全く同じに使えるので期待は大きい。

以下、とりあえず動くようにするためのメモ:

1。Qtは、4.8.5をhome brewで入れる。Qt-5も入れることはできるがまだあまり使われておらず標準はQt-4の印象。

2。libqxtというのが使われているので、http://dev.libqxt.org/libqxt/wiki/Home から落とすこともできるが、home brewにも入って

いた。formulaを見ると、Mac用のパッチがかかっていることがわかる。

3。HotShotsは、 qmake と cmakeのどちらでもMakefileを作ってくれるので両方試した

cmakeの方は、build/CmakeList.txtがMac対応がされてないので、以下のようにいじった:

SET( CMAKE_OSX_ARCHITECTURES ppc;i386 )をコメントアウト

FIND_PACKAGE(Qxt COMPONENTS QxtGui REQUIRED) を APPLEでも設定

INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR} "/usr/local/Cellar/libqxt/0.6.2/include/QxtGui" "/usr/l\

ocal/Cellar/libqxt/0.6.2/include/QxtCore") をAPPLE用に設定

APPLE用に -lQxtGui --lX11を削除して、TARGET_LINK_LIBRARIES( ${PROGNAME} ${QT_LIBRARIES} -ldl ) に

makeすろと、以下のようなエラー

Building CXX object CMakeFiles/hotshots.dir/var/root/HotShots-1.2.1/src/3rdparty/qxt/qxtgl\

obalshortcut_mac.o

/var/root/HotShots-1.2.1/src/3rdparty/qxt/qxtglobalshortcut_mac.cpp:102:5: error: use of undeclar\

ed identifier

'KLGetCurrentKeyboardLayout'

KLGetCurrentKeyboardLayout(&layout);

^

これは、上記のMac用のパッチを適用すれば解決する

しかし、以下のようなエラーで結局give up

"_TISGetInputSourceProperty", referenced from:

QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key) in qxtglobalshortcut_mac.o

"_UnregisterEventHotKey", referenced from:

QxtGlobalShortcutPrivate::unregisterShortcut(unsigned int, unsigned int) in qxtglobalshortc\

ut_mac.o

"WindowGrabber::grabCurrent(bool)", referenced from:

GrabManager::grabCurrentMode() in GrabManager.o

"_kTISPropertyUnicodeKeyLayoutData", referenced from:

QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key) in qxtglobalshortcut_mac.o

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

make[2]: *** [hotshots.app/Contents/MacOS/hotshots] Error 1

make[1]: *** [CMakeFiles/hotshots.dir/all] Error 2

make: *** [all] Error 2

qmakeの方は、build/HotShots.proをいじる必要がある

#unix:INCLUDEPATH += /usr/include/qxt/QxtGui /usr/include/qxt/QxtCore /usr/include/QxtGui /usr/in\

clude/QxtCore /usr/local/Qxt/include/QxtGui /usr/local/Qxt/include/QxtCore をコメントにし、以下のように変更

unix:INCLUDEPATH += /usr/include/qxt/QxtGui /usr/include/qxt/QxtCore /usr/include/QxtGui /usr/inc\

lude/QxtCore /usr/local/Qxt/include/QxtGui /usr/local/Qxt/include/QxtCore /usr/local/Cellar/libqx\

t/0.6.2/include/QxtGui /usr/local/Cellar/libqxt/0.6.2/include/QxtCore

これでコンパイルはできるようになるが、リンクのライブラリの指定方法がわからない、結局、リンクのコマンドの最後の部分を

以下のようにマニュアルで変更した:

-F/usr/local/Cellar/qt/4.8.5/lib -L/usr/local/Cellar/qt/4.8.5/lib -lX11 -framework QxtGui -F/usr/local/Cellar/libqxt/0.6.2/lib -framework QtXml -L/usr/X11/lib -L/usr/local/Cellar/qt/4.8.5/lib -F/usr/local/Cellar/qt/4.8.5/lib -framework QtCore -framework QtGui -framework QtNetwork

4。qmakeのリンクで失敗し以下のエラー

Undefined symbols for architecture x86_64:

"WindowGrabber::grabCurrent(bool)", referenced from:

GrabManager::grabCurrentMode() in GrabManager.o

ld: symbol(s) not found for architecture x86_64

WindowGrabber_x11.cppが使われているが、#ifdef Q_WS_X11 が生きてないので、grabCurrent

が定義されていない。そもそも、MacのQtでは Q_WS_MACが定義され、Q_WS_X11は使われて

ないようだ。Qt-X11を作るという方法もあるが、今更Mac Lionで追求するのは大変そうなのでやめる。

WindowGrabber_mac.cppを作成する、あるいは、WindowsGrabber_x11.cppで、#ifdef Q_WS_MACを追加する

のが正解であろう。

5。無理矢理リンクし、動作確認

GrabManager.cppで、grabCurrentを呼んでいる部分をコメントして無理矢理リンクした。

build/release/hotshots.app を/Applicationsにrsyncすれば、普通に起動できる。

Hotshots on Mac

6。screenは取れるのだが、イメージエディタでカーソルの位置がずれる。これが痛い。