スポンサーサイト
上記の広告は1ヶ月以上更新のないブログに表示されています。
新しい記事を書く事で広告が消せます。
新しい記事を書く事で広告が消せます。
LinuxにObjective-C 2.0環境作成
前回の方法だとプロパティとか高速列挙とかのObjective-C 2.0の機能を利用できないはず。
で、それらを利用したい場合の環境構築。
条件としては
・最新のGNUstepをインストールする。
・ソースのコンパイルにはgccではなくclangを使う(GNUstepのコンパイル自体はgccでOK)。
OSはFedora 13を使った。理由はclangをyumでインストールできて簡単だから。
まずclang(とllvm)をインストール
↓
# yum install clang clang-devel llvm
次に最新のGNUstepを入手
↓
# cd /usr/local/src
# svn co svn://svn.gna.org/svn/gnustep/trunk gnustep
で、make、base、gui、backの順にビルド&インストールしていく。基本的な手順は前回と同じ。
【gnustep-makeのインストール】
# cd /usr/include
# ln -s /usr/lib/libffi-3.0.9/include/ffi.h .
# ln -s /usr/lib/libffi-3.0.9/include/ffitarget.h .
# cd /usr/local/src/gnustep/modules/core/make
# ./configure --with-layout=fhs --prefix=/usr
# mkdir -p /root/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS} (もしディレクトリがなければ)
前回と同じで、RPM化しないならmake installで良い。checkinstallでRPM化する場合はRPMファイルのファイル名を修正するために以下のような手間をかける。この辺はbase、gui、backでも同様。バージョンはVersionファイルを見れば分かる。
# checkinstall --inspect
The package documentation directory ./doc-pak does not exist.
Should I create a default set of package docs? [y]:
パッケージのドキュメンテーションを準備..OK
使用するパッケージ方式を選んでください。
Slackwareなら[S], RPMなら[R], Debianなら[D]を入力R
このパッケージの説明を書いてください
説明の末尾は空行かEOFにしてください。
>>
**************************************
**** RPM package creation selected ***
**************************************
このパッケージは以下の内容で構成されます:
1 - Summary: [ Package created with checkinstall 1.6.3 ]
2 - Name: [ make ]
3 - Version: [ ]
4 - Release: [ 1 ]
5 - License: [ GPL ]
6 - Group: [ Applications/System ]
7 - Architecture: [ i386 ]
8 - Source location: [ make ]
9 - Alternate source location: [ ]
10 - Requires: [ ]
11 - Provides: [ make ]
変更するものの番号を入力してください。Enterで続行します: 2
名前を入力:
>> gnustep-make
このパッケージは以下の内容で構成されます:
1 - Summary: [ Package created with checkinstall 1.6.3 ]
2 - Name: [ gnustep-make ]
3 - Version: [ ]
4 - Release: [ 1 ]
5 - License: [ GPL ]
6 - Group: [ Applications/System ]
7 - Architecture: [ i386 ]
8 - Source location: [ make ]
9 - Alternate source location: [ ]
10 - Requires: [ ]
11 - Provides: [ make ]
変更するものの番号を入力してください。Enterで続行します: 11
提供するものを入力:
>> gnustep-make
このパッケージは以下の内容で構成されます:
1 - Summary: [ Package created with checkinstall 1.6.3 ]
2 - Name: [ gnustep-make ]
3 - Version: [ ]
4 - Release: [ 1 ]
5 - License: [ GPL ]
6 - Group: [ Applications/System ]
7 - Architecture: [ i386 ]
8 - Source location: [ make ]
9 - Alternate source location: [ ]
10 - Requires: [ ]
11 - Provides: [ gnustep-make ]
変更するものの番号を入力してください。Enterで続行します: 3
バージョンを入力:
>> 2.4.0
このパッケージは以下の内容で構成されます:
1 - Summary: [ Package created with checkinstall 1.6.3 ]
2 - Name: [ gnustep-make ]
3 - Version: [ 2.4.0 ]
4 - Release: [ 1 ]
5 - License: [ GPL ]
6 - Group: [ Applications/System ]
7 - Architecture: [ i386 ]
8 - Source location: [ make ]
9 - Alternate source location: [ ]
10 - Requires: [ ]
11 - Provides: [ gnustep-make ]
変更するものの番号を入力してください。Enterで続行します:
…
…
# cd /root/rpmbuild/RPMS/i386
# rpm -ivh gnustep-make-2.4.0-1.i386.rpm
# sh /usr/share/GNUstep/Makefiles/GNUstep.sh
【gnustep-baseのインストール】
# cd /usr/local/src/gnustep/modules/core/base
# ./configure --prefix=/usr
# make
で、こんな感じのエラー↓
…
Compiling file GSMDNSNetServices.m ...
GSMDNSNetServices.m: In function ‘-[GSMDNSNetServiceBrowser cleanup]’:
GSMDNSNetServices.m:289: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m:289: error: (Each undeclared identifier is reported only once
GSMDNSNetServices.m:289: error: for each function it appears in.)
GSMDNSNetServices.m:305: error: ‘_netServiceBrowser’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetServiceBrowser executeWithError:]’:
GSMDNSNetServices.m:328: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetServiceBrowser searchForDomain:]’:
GSMDNSNetServices.m:369: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m:387: error: ‘_netServiceBrowser’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetServiceBrowser enumCallback:flags:interface:error:domain:]’:
GSMDNSNetServices.m:416: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m:420: error: ‘_netServiceBrowser’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetServiceBrowser browseCallback:flags:interface:error:name:type:domain:]’:
GSMDNSNetServices.m:483: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m:487: error: ‘_netServiceBrowser’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetServiceBrowser loop:]’:
GSMDNSNetServices.m:579: error: ‘_netServiceBrowser’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetServiceBrowser removeFromRunLoop:forMode:]’:
GSMDNSNetServices.m:611: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetServiceBrowser scheduleInRunLoop:forMode:]’:
GSMDNSNetServices.m:643: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetServiceBrowser searchForServicesOfType:inDomain:]’:
GSMDNSNetServices.m:725: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m:743: error: ‘_netServiceBrowser’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetServiceBrowser stop]’:
GSMDNSNetServices.m:770: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetServiceBrowser init]’:
GSMDNSNetServices.m:809: error: ‘_netServiceBrowser’ undeclared (first use in this function)
GSMDNSNetServices.m:811: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetServiceBrowser dealloc]’:
GSMDNSNetServices.m:828: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService executeWithError:]’:
GSMDNSNetServices.m:881: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService cleanup]’:
GSMDNSNetServices.m:936: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m:952: error: ‘_netService’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService stopResolving:]’:
GSMDNSNetServices.m:976: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService resolverCallback:flags:interface:error:fullname:target:port:length:record:]’:
GSMDNSNetServices.m:1009: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m:1013: error: ‘_netService’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService addAddress:]’:
GSMDNSNetServices.m:1104: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService addAddress:length:type:interface:]’:
GSMDNSNetServices.m:1139: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService queryCallback:flags:interface:error:fullname:type:class:length:data:ttl:]’:
GSMDNSNetServices.m:1261: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m:1265: error: ‘_netService’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService registerCallback:flags:error:name:type:domain:]’:
GSMDNSNetServices.m:1407: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m:1411: error: ‘_netService’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService loop:]’:
GSMDNSNetServices.m:1441: error: ‘_netService’ undeclared (first use in this function)
GSMDNSNetServices.m:1458: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService initWithDomain:type:name:port:]’:
GSMDNSNetServices.m:1766: error: ‘_netService’ undeclared (first use in this function)
GSMDNSNetServices.m:1768: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService removeFromRunLoop:forMode:]’:
GSMDNSNetServices.m:1789: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService scheduleInRunLoop:forMode:]’:
GSMDNSNetServices.m:1823: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService publishWithFlags:]’:
GSMDNSNetServices.m:1861: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m:1893: error: ‘_netService’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService resolveWithTimeout:]’:
GSMDNSNetServices.m:1950: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m:1996: error: ‘_netService’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService stop]’:
GSMDNSNetServices.m:2024: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService startMonitoring]’:
GSMDNSNetServices.m:2047: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService stopMonitoring]’:
GSMDNSNetServices.m:2082: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService addresses]’:
GSMDNSNetServices.m:2111: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService domain]’:
GSMDNSNetServices.m:2124: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService hostName]’:
GSMDNSNetServices.m:2137: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService name]’:
GSMDNSNetServices.m:2150: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService port]’:
GSMDNSNetServices.m:2155: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService type]’:
GSMDNSNetServices.m:2170: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService protocolSpecificInformation]’:
GSMDNSNetServices.m:2186: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService setProtocolSpecificInformation:]’:
GSMDNSNetServices.m:2209: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService TXTRecordData]’:
GSMDNSNetServices.m:2231: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService setTXTRecordData:]’:
GSMDNSNetServices.m:2247: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m:2272: error: ‘_netService’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService dealloc]’:
GSMDNSNetServices.m:2353: error: ‘_reserved’ undeclared (first use in this function)
make[4]: *** [obj/libgnustep-base.obj/GSMDNSNetServices.m.o] エラー 1
make[3]: *** [internal-library-all_] エラー 2
make[2]: *** [libgnustep-base.all.library.variables] エラー 2
make[1]: *** [internal-all] エラー 2
make: *** [internal-all] エラー 2
GSMDNSNetServices.mはmDNS関連のコードっぽい。とりあえずいらないのでconfigureのオプションを変える。
# ./configure --prefix=/usr --disable-zeroconf
# make
# checkinstall --inspect
# cd /root/rpmbuild/RPMS/i386
# rpm -ivh gnustep-base-1.21.1-1.i386.rpm
【gnustep-guiのインストール】
# cd /usr/local/src/gnustep/modules/core/gui
# yum install libjpeg-devel libtiff-devel libpng-devel
# ./configure --prefix=/usr
# make
# checkinstall --inspect
# cd /root/rpmbuild/RPMS/i386
# rpm -ivh gnustep-gui-0.19.0-1.i386.rpm
【gnustep-backのインストール】
# yum install libX11-devel libXt-devel freetype-devel libart_lgpl-devel libXext-devel
# cd /usr/local/src/gnustep/modules/core/back
# ./configure --prefix=/usr
# make
# checkinstall --inspect
# cd /root/rpmbuild/RPMS/i386
# rpm -ivh gnustep-back-0.19.0-1.i386.rpm
【試しにObjective-Cのソースコンパイルと実行】
ヘッダファイル: Class1.h, Class2.h
ソースファイル: Class1.m, Class2.m
をコンパイルするとすると、前回と違うのはMakefile。こんな感じ
↓
CC = clang
CFLAGS = -O2 -fconstant-string-class=NSConstantString
LIBS = -lgnustep-base -lobjc
OBJS = Class1.o Class2.o
TARGET = a.out
$(TARGET): $(OBJS)
$(CC) -o $@ $(OBJS) $(LIBS)
%.o: %.m
$(CC) $(CFLAGS) -c $*.m -o $*.o
clean:
rm -f $(TARGET) $(OBJS)
で、それらを利用したい場合の環境構築。
条件としては
・最新のGNUstepをインストールする。
・ソースのコンパイルにはgccではなくclangを使う(GNUstepのコンパイル自体はgccでOK)。
OSはFedora 13を使った。理由はclangをyumでインストールできて簡単だから。
まずclang(とllvm)をインストール
↓
# yum install clang clang-devel llvm
次に最新のGNUstepを入手
↓
# cd /usr/local/src
# svn co svn://svn.gna.org/svn/gnustep/trunk gnustep
で、make、base、gui、backの順にビルド&インストールしていく。基本的な手順は前回と同じ。
【gnustep-makeのインストール】
# cd /usr/include
# ln -s /usr/lib/libffi-3.0.9/include/ffi.h .
# ln -s /usr/lib/libffi-3.0.9/include/ffitarget.h .
# cd /usr/local/src/gnustep/modules/core/make
# ./configure --with-layout=fhs --prefix=/usr
# mkdir -p /root/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS} (もしディレクトリがなければ)
前回と同じで、RPM化しないならmake installで良い。checkinstallでRPM化する場合はRPMファイルのファイル名を修正するために以下のような手間をかける。この辺はbase、gui、backでも同様。バージョンはVersionファイルを見れば分かる。
# checkinstall --inspect
The package documentation directory ./doc-pak does not exist.
Should I create a default set of package docs? [y]:
パッケージのドキュメンテーションを準備..OK
使用するパッケージ方式を選んでください。
Slackwareなら[S], RPMなら[R], Debianなら[D]を入力R
このパッケージの説明を書いてください
説明の末尾は空行かEOFにしてください。
>>
**************************************
**** RPM package creation selected ***
**************************************
このパッケージは以下の内容で構成されます:
1 - Summary: [ Package created with checkinstall 1.6.3 ]
2 - Name: [ make ]
3 - Version: [ ]
4 - Release: [ 1 ]
5 - License: [ GPL ]
6 - Group: [ Applications/System ]
7 - Architecture: [ i386 ]
8 - Source location: [ make ]
9 - Alternate source location: [ ]
10 - Requires: [ ]
11 - Provides: [ make ]
変更するものの番号を入力してください。Enterで続行します: 2
名前を入力:
>> gnustep-make
このパッケージは以下の内容で構成されます:
1 - Summary: [ Package created with checkinstall 1.6.3 ]
2 - Name: [ gnustep-make ]
3 - Version: [ ]
4 - Release: [ 1 ]
5 - License: [ GPL ]
6 - Group: [ Applications/System ]
7 - Architecture: [ i386 ]
8 - Source location: [ make ]
9 - Alternate source location: [ ]
10 - Requires: [ ]
11 - Provides: [ make ]
変更するものの番号を入力してください。Enterで続行します: 11
提供するものを入力:
>> gnustep-make
このパッケージは以下の内容で構成されます:
1 - Summary: [ Package created with checkinstall 1.6.3 ]
2 - Name: [ gnustep-make ]
3 - Version: [ ]
4 - Release: [ 1 ]
5 - License: [ GPL ]
6 - Group: [ Applications/System ]
7 - Architecture: [ i386 ]
8 - Source location: [ make ]
9 - Alternate source location: [ ]
10 - Requires: [ ]
11 - Provides: [ gnustep-make ]
変更するものの番号を入力してください。Enterで続行します: 3
バージョンを入力:
>> 2.4.0
このパッケージは以下の内容で構成されます:
1 - Summary: [ Package created with checkinstall 1.6.3 ]
2 - Name: [ gnustep-make ]
3 - Version: [ 2.4.0 ]
4 - Release: [ 1 ]
5 - License: [ GPL ]
6 - Group: [ Applications/System ]
7 - Architecture: [ i386 ]
8 - Source location: [ make ]
9 - Alternate source location: [ ]
10 - Requires: [ ]
11 - Provides: [ gnustep-make ]
変更するものの番号を入力してください。Enterで続行します:
…
…
# cd /root/rpmbuild/RPMS/i386
# rpm -ivh gnustep-make-2.4.0-1.i386.rpm
# sh /usr/share/GNUstep/Makefiles/GNUstep.sh
【gnustep-baseのインストール】
# cd /usr/local/src/gnustep/modules/core/base
# ./configure --prefix=/usr
# make
で、こんな感じのエラー↓
…
Compiling file GSMDNSNetServices.m ...
GSMDNSNetServices.m: In function ‘-[GSMDNSNetServiceBrowser cleanup]’:
GSMDNSNetServices.m:289: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m:289: error: (Each undeclared identifier is reported only once
GSMDNSNetServices.m:289: error: for each function it appears in.)
GSMDNSNetServices.m:305: error: ‘_netServiceBrowser’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetServiceBrowser executeWithError:]’:
GSMDNSNetServices.m:328: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetServiceBrowser searchForDomain:]’:
GSMDNSNetServices.m:369: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m:387: error: ‘_netServiceBrowser’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetServiceBrowser enumCallback:flags:interface:error:domain:]’:
GSMDNSNetServices.m:416: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m:420: error: ‘_netServiceBrowser’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetServiceBrowser browseCallback:flags:interface:error:name:type:domain:]’:
GSMDNSNetServices.m:483: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m:487: error: ‘_netServiceBrowser’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetServiceBrowser loop:]’:
GSMDNSNetServices.m:579: error: ‘_netServiceBrowser’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetServiceBrowser removeFromRunLoop:forMode:]’:
GSMDNSNetServices.m:611: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetServiceBrowser scheduleInRunLoop:forMode:]’:
GSMDNSNetServices.m:643: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetServiceBrowser searchForServicesOfType:inDomain:]’:
GSMDNSNetServices.m:725: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m:743: error: ‘_netServiceBrowser’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetServiceBrowser stop]’:
GSMDNSNetServices.m:770: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetServiceBrowser init]’:
GSMDNSNetServices.m:809: error: ‘_netServiceBrowser’ undeclared (first use in this function)
GSMDNSNetServices.m:811: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetServiceBrowser dealloc]’:
GSMDNSNetServices.m:828: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService executeWithError:]’:
GSMDNSNetServices.m:881: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService cleanup]’:
GSMDNSNetServices.m:936: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m:952: error: ‘_netService’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService stopResolving:]’:
GSMDNSNetServices.m:976: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService resolverCallback:flags:interface:error:fullname:target:port:length:record:]’:
GSMDNSNetServices.m:1009: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m:1013: error: ‘_netService’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService addAddress:]’:
GSMDNSNetServices.m:1104: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService addAddress:length:type:interface:]’:
GSMDNSNetServices.m:1139: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService queryCallback:flags:interface:error:fullname:type:class:length:data:ttl:]’:
GSMDNSNetServices.m:1261: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m:1265: error: ‘_netService’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService registerCallback:flags:error:name:type:domain:]’:
GSMDNSNetServices.m:1407: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m:1411: error: ‘_netService’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService loop:]’:
GSMDNSNetServices.m:1441: error: ‘_netService’ undeclared (first use in this function)
GSMDNSNetServices.m:1458: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService initWithDomain:type:name:port:]’:
GSMDNSNetServices.m:1766: error: ‘_netService’ undeclared (first use in this function)
GSMDNSNetServices.m:1768: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService removeFromRunLoop:forMode:]’:
GSMDNSNetServices.m:1789: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService scheduleInRunLoop:forMode:]’:
GSMDNSNetServices.m:1823: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService publishWithFlags:]’:
GSMDNSNetServices.m:1861: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m:1893: error: ‘_netService’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService resolveWithTimeout:]’:
GSMDNSNetServices.m:1950: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m:1996: error: ‘_netService’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService stop]’:
GSMDNSNetServices.m:2024: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService startMonitoring]’:
GSMDNSNetServices.m:2047: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService stopMonitoring]’:
GSMDNSNetServices.m:2082: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService addresses]’:
GSMDNSNetServices.m:2111: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService domain]’:
GSMDNSNetServices.m:2124: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService hostName]’:
GSMDNSNetServices.m:2137: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService name]’:
GSMDNSNetServices.m:2150: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService port]’:
GSMDNSNetServices.m:2155: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService type]’:
GSMDNSNetServices.m:2170: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService protocolSpecificInformation]’:
GSMDNSNetServices.m:2186: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService setProtocolSpecificInformation:]’:
GSMDNSNetServices.m:2209: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService TXTRecordData]’:
GSMDNSNetServices.m:2231: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService setTXTRecordData:]’:
GSMDNSNetServices.m:2247: error: ‘_reserved’ undeclared (first use in this function)
GSMDNSNetServices.m:2272: error: ‘_netService’ undeclared (first use in this function)
GSMDNSNetServices.m: In function ‘-[GSMDNSNetService dealloc]’:
GSMDNSNetServices.m:2353: error: ‘_reserved’ undeclared (first use in this function)
make[4]: *** [obj/libgnustep-base.obj/GSMDNSNetServices.m.o] エラー 1
make[3]: *** [internal-library-all_] エラー 2
make[2]: *** [libgnustep-base.all.library.variables] エラー 2
make[1]: *** [internal-all] エラー 2
make: *** [internal-all] エラー 2
GSMDNSNetServices.mはmDNS関連のコードっぽい。とりあえずいらないのでconfigureのオプションを変える。
# ./configure --prefix=/usr --disable-zeroconf
# make
# checkinstall --inspect
# cd /root/rpmbuild/RPMS/i386
# rpm -ivh gnustep-base-1.21.1-1.i386.rpm
【gnustep-guiのインストール】
# cd /usr/local/src/gnustep/modules/core/gui
# yum install libjpeg-devel libtiff-devel libpng-devel
# ./configure --prefix=/usr
# make
# checkinstall --inspect
# cd /root/rpmbuild/RPMS/i386
# rpm -ivh gnustep-gui-0.19.0-1.i386.rpm
【gnustep-backのインストール】
# yum install libX11-devel libXt-devel freetype-devel libart_lgpl-devel libXext-devel
# cd /usr/local/src/gnustep/modules/core/back
# ./configure --prefix=/usr
# make
# checkinstall --inspect
# cd /root/rpmbuild/RPMS/i386
# rpm -ivh gnustep-back-0.19.0-1.i386.rpm
【試しにObjective-Cのソースコンパイルと実行】
ヘッダファイル: Class1.h, Class2.h
ソースファイル: Class1.m, Class2.m
をコンパイルするとすると、前回と違うのはMakefile。こんな感じ
↓
CC = clang
CFLAGS = -O2 -fconstant-string-class=NSConstantString
LIBS = -lgnustep-base -lobjc
OBJS = Class1.o Class2.o
TARGET = a.out
$(TARGET): $(OBJS)
$(CC) -o $@ $(OBJS) $(LIBS)
%.o: %.m
$(CC) $(CFLAGS) -c $*.m -o $*.o
clean:
rm -f $(TARGET) $(OBJS)
スポンサーサイト
CentOS 5.4にObjective-C環境作成
インストールするものをRPM化したかったから
# checkinstall --inspect
して
# cd /usr/src/redhat/RPMS/i386
# rpm -ivh ~.rpm
でインストールしてるけど、特に必要ない人はそれぞれ
# make
の後
#make install
で良い。
【libffiのインストール】
http://sourceware.org/libffi/
とかから
libffi-3.0.9.tar.gz
をダウンロード。
# tar zxf libffi-3.0.9.tar.gz
# ./configure --prefix=/usr
# make
# checkinstall --inspect
インストール時に
ファイル /usr/share/info/dir (パッケージ libffi-3.0.9-1.i386 から) は、パッケージ info-4.8-14.el5.i386 からのファイルと競合しています。
とかエラーが出るのでvi編集画面で/usr/share/info/dirの行を削除。
# cd /usr/src/redhat/RPMS/i386
# rpm -ivh libffi-3.0.9-1.i386.rpm
/usr/includeにヘッダファイルがインストールされないから、
# cd /usr/include
# ln -s /usr/lib/libffi-3.0.9/include/ffi.h .
# ln -s /usr/lib/libffi-3.0.9/include/ffitarget.h .
次に
http://www.gnustep.org/
から
gnustep-make-2.2.0.tar.gz
gnustep-base-1.19.3.tar.gz
gnustep-gui-0.16.0.tar.gz
gnustep-back-0.16.0.tar.gz
をダウンロード
【gnustep-makeのインストール】
# tar zxf gnustep-make-2.2.0.tar.gz
# ./configure --with-layout=fhs --prefix=/usr
# checkinstall --inspect
# cd /usr/src/redhat/RPMS/i386
# rpm -ivh gnustep-make-2.2.0-1.i386.rpm
# sh /usr/share/GNUstep/Makefiles/GNUstep.sh
# export GNUSTEP_MAKEFILES=/usr/share/GNUstep/Makefiles
【gnustep-baseのインストール】
# tar zxf gnustep-base-1.19.3.tar.gz
# ./configure --prefix=/usr
# make
# checkinstall --inspect
# cd /usr/src/redhat/RPMS/i386
# rpm -ivh gnustep-base-1.19.3-1.i386.rpm
【gnustep-guiのインストール】
# yum install libjpeg-devel
# yum install libtiff-devel
# yum install libpng-devel
# tar zxf gnustep-gui-0.17.1.tar.gz
# ./configure --prefix=/usr
# make
# checkinstall --inspect
# cd /usr/src/redhat/RPMS/i386
# rpm -ivh gnustep-gui-0.17.1-1.i386.rpm
【gnustep-backのインストール】
# yum install libX11-devel
# yum install libXt-devel
# yum install freetype-devel
# yum install libart_lgpl-devel
# tar zxf gnustep-back-0.17.1.tar.gz
# ./configure --prefix=/usr
# make
# checkinstall --inspect
# cd /usr/src/redhat/RPMS/i386
# rpm -ivh gnustep-back-0.17.1-1.i386.rpm
【試しにObjective-Cのソースコンパイルと実行】
ヘッダファイル: Class1.h, Class2.h
ソースファイル: Class1.m, Class2.m
をコンパイルするとする。
Makefileはこんな感じ↓
CC = gcc
CFLAGS = -O2 -fconstant-string-class=NSConstantString
INCLUDES = Class1.h Class2.h
LIBS = -lgnustep-base
OBJS = Class1.o Class2.o
TARGET = a.out
$(TARGET): $(OBJS)
$(CC) -o $@ $(OBJS) $(LIBS)
%.o: %.m
$(CC) $(CFLAGS) -c $*.m -o $*.o
clean:
rm -f $(TARGET) $(OBJS)
ポイントは、
-fconstant-string-class=NSConstantString
と
-lgnustep-base
を付けること。
で、コンパイル↓
$ make
それから実行↓
$ ./a.out
実行時に
2010-03-14 17:03:34.903 a.out[6391] Unknown time zone name `JST'.
2010-03-14 17:03:34.903 a.out[6391] Using time zone with absolute offset 0.
とか出るのは
/usr/lib/GNUstep/Libraries/gnustep-base/Versions/1.19/Resources/NSTimeZones/zones/JST
がないせい。なので、
# cd /usr/lib/GNUstep/Libraries/gnustep-base/Versions/1.19/Resources/NSTimeZones/zones/
# ln -s Japan JST
# checkinstall --inspect
して
# cd /usr/src/redhat/RPMS/i386
# rpm -ivh ~.rpm
でインストールしてるけど、特に必要ない人はそれぞれ
# make
の後
#make install
で良い。
【libffiのインストール】
http://sourceware.org/libffi/
とかから
libffi-3.0.9.tar.gz
をダウンロード。
# tar zxf libffi-3.0.9.tar.gz
# ./configure --prefix=/usr
# make
# checkinstall --inspect
インストール時に
ファイル /usr/share/info/dir (パッケージ libffi-3.0.9-1.i386 から) は、パッケージ info-4.8-14.el5.i386 からのファイルと競合しています。
とかエラーが出るのでvi編集画面で/usr/share/info/dirの行を削除。
# cd /usr/src/redhat/RPMS/i386
# rpm -ivh libffi-3.0.9-1.i386.rpm
/usr/includeにヘッダファイルがインストールされないから、
# cd /usr/include
# ln -s /usr/lib/libffi-3.0.9/include/ffi.h .
# ln -s /usr/lib/libffi-3.0.9/include/ffitarget.h .
次に
http://www.gnustep.org/
から
gnustep-make-2.2.0.tar.gz
gnustep-base-1.19.3.tar.gz
gnustep-gui-0.16.0.tar.gz
gnustep-back-0.16.0.tar.gz
をダウンロード
【gnustep-makeのインストール】
# tar zxf gnustep-make-2.2.0.tar.gz
# ./configure --with-layout=fhs --prefix=/usr
# checkinstall --inspect
# cd /usr/src/redhat/RPMS/i386
# rpm -ivh gnustep-make-2.2.0-1.i386.rpm
# sh /usr/share/GNUstep/Makefiles/GNUstep.sh
# export GNUSTEP_MAKEFILES=/usr/share/GNUstep/Makefiles
【gnustep-baseのインストール】
# tar zxf gnustep-base-1.19.3.tar.gz
# ./configure --prefix=/usr
# make
# checkinstall --inspect
# cd /usr/src/redhat/RPMS/i386
# rpm -ivh gnustep-base-1.19.3-1.i386.rpm
【gnustep-guiのインストール】
# yum install libjpeg-devel
# yum install libtiff-devel
# yum install libpng-devel
# tar zxf gnustep-gui-0.17.1.tar.gz
# ./configure --prefix=/usr
# make
# checkinstall --inspect
# cd /usr/src/redhat/RPMS/i386
# rpm -ivh gnustep-gui-0.17.1-1.i386.rpm
【gnustep-backのインストール】
# yum install libX11-devel
# yum install libXt-devel
# yum install freetype-devel
# yum install libart_lgpl-devel
# tar zxf gnustep-back-0.17.1.tar.gz
# ./configure --prefix=/usr
# make
# checkinstall --inspect
# cd /usr/src/redhat/RPMS/i386
# rpm -ivh gnustep-back-0.17.1-1.i386.rpm
【試しにObjective-Cのソースコンパイルと実行】
ヘッダファイル: Class1.h, Class2.h
ソースファイル: Class1.m, Class2.m
をコンパイルするとする。
Makefileはこんな感じ↓
CC = gcc
CFLAGS = -O2 -fconstant-string-class=NSConstantString
INCLUDES = Class1.h Class2.h
LIBS = -lgnustep-base
OBJS = Class1.o Class2.o
TARGET = a.out
$(TARGET): $(OBJS)
$(CC) -o $@ $(OBJS) $(LIBS)
%.o: %.m
$(CC) $(CFLAGS) -c $*.m -o $*.o
clean:
rm -f $(TARGET) $(OBJS)
ポイントは、
-fconstant-string-class=NSConstantString
と
-lgnustep-base
を付けること。
で、コンパイル↓
$ make
それから実行↓
$ ./a.out
実行時に
2010-03-14 17:03:34.903 a.out[6391] Unknown time zone name `JST'.
2010-03-14 17:03:34.903 a.out[6391] Using time zone with absolute offset 0.
とか出るのは
/usr/lib/GNUstep/Libraries/gnustep-base/Versions/1.19/Resources/NSTimeZones/zones/JST
がないせい。なので、
# cd /usr/lib/GNUstep/Libraries/gnustep-base/Versions/1.19/Resources/NSTimeZones/zones/
# ln -s Japan JST