SunOS 4.x, Solaris 2.x and HP-UX

Under SunOS 4.x, Solaris 2.x and HP-UX, the simple object file must be created by compiling the source file with special compiler flags and a shared library must be produced. The necessary steps with HP-UX are as follows. The +z flag to the HP-UX C compiler produces so-called "Position Independent Code" (PIC) and the +u flag removes some alignment restrictions that the PA-RISC architecture normally enforces. The object file must be turned into a shared library using the HP-UX link editor with the -b option. This sounds complicated but is actually very simple, since the commands to do it are just:

SunOS 4.x、 Solaris 2.x、 HP-UX では、 単純オブジェクトファイルは、ソースファイルを特別なコンパイラフラ グ付でコンパイルして作らなくてはなりません。また、共有ライブラリ を作らなくてはなりません。 HP-UXで必要な手順は次のとおりです。 HP-UXのCコンパイラに +z フラグを与えることで、 いわゆる位置独立なコード(PIC: Position Independent Code)を作り、 +u フラグを与えることで、PA-RISCアーキテクチャ では通常強制的に行われるアライメント制限を取り除きます。 オブジェクトファイルは、HP-UXのリンカの -b フラグを使って、 共有ライブラリに変換しなくてはなりません。 複雑に見えるかも知れませんが、実際は単純です。なぜなら、こ れをするためのコマンドは単に次のようなものだからです。

# simple HP-UX example
% cc +z +u -c foo.c
% ld -b -o foo.sl foo.o

As with the .so files mentioned in the last subsection, the create function command must be told which file is the correct file to load (i.e., you must give it the location of the shared library, or .sl file). Under SunOS 4.x, the commands look like:

最後の節で言及されている .so ファイルもそうであるように、関数生成 コマンドには、ロードすべき正しいファイルがどのファイルであるのかを 指定しなければなりません (すなわち、共有 ライブラリ、もしくは .sl ファイルの場所を指定しなければならないの です)。 SunOS 4.x でのコマンドは次のとおりです。

# simple SunOS 4.x example
% cc -PIC -c foo.c
% ld -dc -dp -Bdynamic -o foo.so foo.o
and the equivalent lines under Solaris 2.x are: そして、Solaris 2.x での、対応するそれぞれの行は次のようになります。
# simple Solaris 2.x example
% cc -K PIC -c foo.c
% ld -G -Bdynamic -o foo.so foo.o
or または
# simple Solaris 2.x example
% gcc -fPIC -c foo.c
% ld -G -Bdynamic -o foo.so foo.o

When linking shared libraries, you may have to specify some additional shared libraries (typically system libraries, such as the C and math libraries) on your ld command line.

共有ライブラリをリンクする時には、ldのコマンド行で、いくつかの追加 の共有ライブラリ(通常は C や数学のライブラリなどのシステムライブ ラリ)を指定することになるでしょう。