Linuxの開発言語ツールは、gccである。gccは、今、versionは、4.6まで来た。  ちなみに、手元のDebian wheezyのマシンで、gcc -vとやると
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/i386-linux-gnu/gcc/i486-linux-gnu/4.6.1/lto-wrapper
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.6.1-4' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-multiarch --with-multiarch-defaults=i386-linux-gnu --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib/i386-linux-gnu --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib/i386-linux-gnu --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc --enable-targets=all --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.6.1 (Debian 4.6.1-4)

と出る。
つまり、サポート言語は、
  • C
  • C++
  • Fortran
  • Objective-C
  • Objective-C++
  • Go
ということである。それで、Linuxの上でも、ほんとに、Objective-Cでプログラムが書けるのか、と調べてみたのだが。
 普通のObjective-Cの教科書では、すべてのオブジェクトの祖先は、ルート・オブジェクトであるNSObjectの子孫である。と書いてある。  また、Xcodeで、Objective-Cの雛形を生成させると、必ずヘッダーファイルには、Foundation/Foundation.hが、インポートされている。
 だが、Linuxの上のgccには、たとえ、gobjc(GCCのObjective-C)関連パッケージを一式導入しても、NSObjectも、Foundation.hもない。  というのは、NSObjectもFoundation.hも、CocoaなりCocoa Touchのものなので、Objective-Cという言語の物ではないからだ。  しかも、gobjcというコマンドすらない。たしかに、gcc test1.m とかやって、Objective-Cのソースファイルとは、認識してくれているようだが。

ヘッダーファイルもほとんどない
 ヘッダーファイルは、私の環境では、/usr/lib/i386-linux-gnu/gcc/i486-linux-gnu/4.6/include/objc/ にあるが、そこにあるのは、

-rw-r--r-- 1 root root  1399 2011-07-15 12:51 NXConstStr.h
-rw-r--r-- 1 root root  2242 2011-07-15 12:51 Object.h
-rw-r--r-- 1 root root  1588 2011-07-15 12:51 Protocol.h
drwxr-xr-x 2 root root  4096 2011-08-05 14:46 deprecated
-rw-r--r-- 1 root root  3930 2011-07-15 12:51 encoding.h
-rw-r--r-- 1 root root    48 2011-07-15 12:51 hash.h
-rw-r--r-- 1 root root  5985 2011-07-15 12:51 message.h
-rw-r--r-- 1 root root 12041 2011-07-15 12:51 objc-api.h
-rw-r--r-- 1 root root  1483 2011-07-15 12:51 objc-decls.h
-rw-r--r-- 1 root root  4823 2011-07-15 12:51 objc-exception.h
-rw-r--r-- 1 root root    35 2011-07-15 12:51 objc-list.h
-rw-r--r-- 1 root root  2337 2011-07-15 12:51 objc-sync.h
-rw-r--r-- 1 root root  7056 2011-07-15 12:51 objc.h
-rw-r--r-- 1 root root 52741 2011-07-15 12:51 runtime.h
-rw-r--r-- 1 root root    32 2011-07-15 12:51 sarray.h
-rw-r--r-- 1 root root  4014 2011-07-15 12:51 thr.h
-rw-r--r-- 1 root root    84 2011-07-15 12:51 typedstream.h
だけだ。もちろん、この中には、NSObjectもない。

Hello worldは?
 Wikipediaの記事では、Objective-CのHello worldは、こうであるそうだが、これは、Objective-Cとは認めがたい代物だ。

結論
Linuxの上にあるObjective-Cは使えない。GNUStepの環境を入れれば、使えるようになるのかもしれないが、そういう予定はない。ということで、いまのところ、使えるObjective-Cは、Apple環境だけなのだろう。 人気ブログランキングへ