Gnatmakeを使用してADA共有ライブラリを使用してコンパイルおよびリンクするにはどうすればよいですか?

StackOverflow https://stackoverflow.com/questions/3902597

  •  29-09-2019
  •  | 
  •  

質問

私は再び花屋図書館を申請者にコンパイルするのに苦労しています。私は花屋に大きな問題を抱えていることがわかりました(2010年の最新のAdacore GPLダウンロードとDebian's Archiveの2009バージョンの両方から同じエラーの結果)。花屋にはいくつかの低レベルの問題がありますが、生成されたファイルを調べると、errno.hを正しく含めているようです。

これが私が花屋を作ったときに起こることです:

GCC -4.4 -C -I/usr/share/ada/adainclude/florist demo.adb gcc -4.4 -c -i ./ -i/usr/share/ada/adainclude/florist -i-/usr/share/ada /dainclude/florist/posix.adb gcc-4.4 -c -i./ -i/usr/share/ada/adainclude/florist -ifly/share/adainclude/florist/posix-io.adb gcc- 4.4 -c -i ./ -i/usr/share/ada/adainclude/florist -ifly/share/ada/adainclude/florist/posix-terminal_functions.adb gcc-4.4 -i./ -i/ usr/share/ada/ada/adainclude/florist -i-/usr/share/ada/adainclude/florist/posix-c.adb gcc-4.4 -c -i./ -i/usr/share/ada/adainclude/florist- i-/usr/share/ada/adainclude/florist/posix-implementation.adb posix-implementation.gpb:45:06:警告:「System.interput_management.operations」は内部gnatユニットposix-implementation.gpb:45: 06:警告:このユニットの使用は、ポータブルでバージョンに依存しないPOSIX-Implementation.GPB:47:06:警告:「System.Soft_Links」は内部GNATユニットposix-implementation.gpb:47:06:警告:このユニットの使用は、ポータブルでバージョンに依存しないGCC -4.4 -C -I ./ -I/ U sr/share/ada/ada/adainclude/florist -i-/usr/share/ada/adainclude/florist/ada_streams.ads gcc-4.4 -c -i./ -i/usr/share/ada/adainclude/florist -i- /usr/share/adainclude/florist/posix-permissions.adb gcc-4.4 -c -i./-i/usr/share/ada/adainclude -i-/usr/share/ada/adainclude/florist/florist /posix-permissions -implementation.adb gcc -4.4 -c -i./ -i/usr/share/ada/adainclude/florist -if-ifrusr/share/ada/adainclude/florist/posix-process_identification.adb gnatbind- i/usr/share/ada/adainclude/florist -x demo.ali gnatlink demo.ali -o demoapp ./posix-implementation.o:in function `posix__ implementation_set_ada_code ':posix-implementation.adb :(。テキスト+0x19e): `store_errno './posix-implementation.oへの未定義の参照:infunction` posix__ implementation_get_ada_error_code':posix-implementation.adb :(。テキスト+0x1ab): `fetch_errno './ posix-implementation.oへの未定義の参照posix__implementation_raise_posix_error ':posix-implementation.adb :(。テキスト+0x234): `への未定義の参照FETCH_ERRNO './POSIX-IMPLEMENTATION.O:機能 `posix__ implementation_check__2':posix-implementation.adb :(。テキスト+0x2e5):「fetch_errno 'への未定義の参照' ./posix-implementation.o -Implementation.Adb :(。テキスト+0x313):「fetch_errno './posix-implementation.oへの未定義の参照:infunction `posix__implementation_check_nneg':posix-implementation.adb :(。 './posix-implementation.o:posix-implementation.adb :(.text+0x34e):「fetch_errno' follow .o follow ./posix-implementation.o:in function `nosys_neg_one ':posix-implementation.adb: (.text+0xaef): `store_errno './posix-implementation.oへの未定義の参照:infunction` notsup_neg_one':posix-implementation.adb :(。実装.O:infunction `posix__ prementation_restore_signals_and_raise_posix_error ':posix-implementation.adb :(。text+0xc88):未定義の参照`fetch_errno './posix.o:infunction` posix__system_name':posix.adb :(。テキスト+0x2ff98): `__gnat_florist_uname 'への未定義の参照' ./posix.o:in function` posix__node_name ':posix.adb: (.text+0x2fef): `__gnat_florist_uname 'への未定義の参照' ./posix.o:infunction` posix__release ':posix.adb :(。テキスト+0x3049): `__gnat_florist_uname' ./posix.oへの未定義の参照:機能`posix__version ':posix.adb :(テキスト+0x30a6):` __gnat_florist_uname' ./posix.o:infunction `posix__machine ':posix.adb :(。テキスト+0x3103):` __gnat_gnat_gnat_florist_uname'への未定義の参照 ' ./posix.o:in function` posix__host_to_network_byte_order ':posix.adb :(。テキスト+0x4627): `c_htonl' ./posix.oへの未定義の参照:infunction` posix__host_to_network_byte_order__2 ' ): `c_htons './posix.oへの未定義の参照:関数` posix__network_to_host_byte_order':posix.adb :(。text+0x4655): `c_ntohl './posix.o:in function` posix_network_to_to_to_to_hos t_byte_order__2 ':posix.adb :(。テキスト+0x4670): `c_ntohs' ./posix-io.oへの未定義の参照:関数「posix__io __open ':posix-io.adb :(。テキスト+0x4d1):未定義の参照`__gnat_florist_open './posix-io.o:infunction` posix__o_open_or_create':posix-io.adb :(。text+0xfca): `__gnat_florist_open 'collect2:ld to returned 1 exit gnatlink:usring /usrinkのexit estatus gnatlinkを返す` __gnat_florist_open' collect2:ld /bin/gcc-4.4 gnatmake:***リンクが失敗しました。 Josh@mini10:〜/demo $ gnatbind -i/usr/share/ada/adainclude/florist -i/usr/include demo josh@mini10:〜/demo $ gnatlink demo ./ posix-implementation.o:in function `posix__implementation__set_ada_ada_code_code_code ':posix-implementation.adb :(。テキスト+0x19e):「store_errno' ./posix-implementation.oへの未定義の参照:infunction `posix__ implementation_get_ada_eror_code ':posix-implementation.adb:(。 `fetch_errno './posix-implementation.o:infunction` posix__plementation_raise_posix_error':posix-implementation.adb :(。テキスト+0x234):「fetch_errno './ posix-implementation.oへの未定義の参照: :posix-implementation.adb :(。テキスト+0x2e5):「fetch_errno './posix-implementation.oへの未定義の参照:infunction `posix__implementation_check__3':posix-implementation.adb :(。テキスト+0x313):未定義の参照`fetch_errno './posix-implementation.o:in function` posix__ implementation_check_nneg':posix-implementation.adb :(。テキスト+0x332):「fetch_errno './posix-implementation.o:posix-implementation.adb :(.text+0x34e)への未定義の参照:「fetch_errno' folow ./posix-implementation.oへの詳細な参照:機能`nosys_neg_one ':posix-implementation.adb :(。text+0xaef):` store_errno' ./posix-implementation.oへの未定義の参照 `notsup_neg_one ':posix-implementation.adb :(。テキスト+0xb15): `store_errno './posix-implementation.oへの未定義の参照:関数` posix__ implementation_restore_signals_and_raise_posix_error':posix-implementation.adb :(。テキスト+0xc88) :posix.adb :(。テキスト+0x2f98): `__gnat_florist_uname './posix.o:infunction` posix__node_name':posix.adb :(。text+0x2fef): `__gnat_nat_uname './ posix .o:関数「posix__release」:posix.adb :(。テキスト+0x3049): `__gnat_florist_uname 'への未定義の参照。 .adb :(。テキスト+0x30a6): `__gnat_florist_uname './posix.o:infunction` posix__machine':posix.adb :(。text+0x3103)への未定義の参照: `__gnat_florist_uname 'への未定義の参照:infunction `posix__host_to_network_byte_order ':posix.adb :(。テキスト+0x4627):` c_htonl' ./posix.o:in function `posix_to_network_byte_order__2 ':posix.adb :(。 `c_htons './posix.o:関数` posix__network_to_host_byte_order':posix.adb :(。テキスト+0x4655): `c_ntohl 'への未定義の参照:` c_ntohl' ./posix.o:in function `posix__network_to_to_host_byte_ord__2 ':posix.adbb :)テキスト+0x4670):「c_ntohs './posix-io.oへの未定義の参照:関数「posix__io__open」:posix-io.adb :(。テキスト+0x4d1): `__gnat_florist_open' ./posix-ioへの未定義の参照。 O:機能 `posix__o__open_or_create ':posix-io.adb :(。text+0xfca):` __gnat_florist_open' collect2への未定義の参照:ldは1 Exitステータスgnatlinkを返します:呼び出すときのエラー/usr/bin/gcc-4.4.4.4.4.4.4.4.4.

Errno.hが正しく含まれていることに問題がある場合、このエラーは一般的であるようです。しかし、POSIX-CCファイルから私が知る限り、それはすべて正しいように見えます。誰かがこれを解決する方法について何か提案をしていますか? Florist's Makeファイルは正しく構築されるので、これがどこから来ているのかわかりません。

役に立ちましたか?

解決

わかりました、これは大きな痛みであることが判明しましたが、私はそれを見つけました。

花屋のバインディングは、共有ライブラリと静的ライブラリの両方として利用できます(両方ともインストールされています)。すべての参照を解決するには、ライブラリに対してリンクする必要があります(実際にライブラリソースをアプリケーションにコンパイルすることはできません)。引数を渡して、ライブラリについてコンピレーション段階に伝えると、解決する.AD(少なくとも)ファイルを提供する必要があります。

最後の解決策はこれで終わりました:

gnatmake -aI/usr/share/ada/adainclude/florist -aO/usr/lib/ada/adalib/florist demo.adb -largs -lflorist

-aI ライブラリの広告ファイルへのパスを提供します。 -aO (この場合は)libflorist.soライブラリファイルへのパスを提供し、最後に(そしてこれはトリッキーなものです)あなたは渡さなければなりません -lflorist これを共有するものを伝えるためにこれはすべてです...しかし、それを渡すことは機能しません。あなたはaを配置する必要があります -largs コンパイルフェーズをパラメーターに渡すために、その前に(コンパイルとリンカー用)!それがなければ、これらのフェーズは議論を見ることはありません!

だからあなたは皆がいます! Linux(GCC)の下の共有ADAライブラリに対してコードをコンパイルしてリンクするには、ライブラリのヘッダー/仕様、ライブラリの場所、-llibname引数と-largsを適切な場所に渡す必要があります。

私は今幸せです。これが他の誰かを助けることを願っています。

他のヒント

これは、GNATプロジェクトを使用して花屋を構築する簡単な例です。私はそれを想定しています $ADA_PROJECT_PATH ディレクトリが含まれています florist.gpr インストールされています(私の場合、 $HOME/local/lib/gnat).

サンプルプログラム(ウェブ上にシンプルな花屋のデモが見つかりませんでしたか?) id.adb:

with POSIX.Process_Identification;
with Ada.Text_IO; use Ada.Text_IO;
procedure Id is
begin
   Put_Line (POSIX.To_String (POSIX.Process_Identification.Get_Login_Name));
end Id;

プロジェクトファイル(id.gpr)、同じディレクトリと id.adb:

with "florist";
project Id is
   for Main use ("id.adb");
   for Object_Dir use ".build_id";
   for Exec_Dir use ".";
end Id;

一緒にビルドします

$ gnatmake -p -P id.gpr
object directory "/Users/simon/florist-gpl-2010-src/demo/.build_id" created for project id
gcc -c -I- -gnatA /Users/simon/florist-gpl-2010-src/demo/id.adb
gnatbind -I- -x /Users/simon/florist-gpl-2010-src/demo/.build_id/id.ali
gnatlink /Users/simon/florist-gpl-2010-src/demo/.build_id/id.ali -lflorist -o /Users/simon/florist-gpl-2010-src/demo/id

と実行:

$ ./id
simon

かなり庭の変動リンクエラーのように見えます。 .hファイル、ADAオブジェクトファイル、およびCリンクライブラリの間の何かが完全に交尾していません。しかし、何を伝えるのは難しい。

あなたの最善の策は、同じ問題に遭遇したかもしれない他の花屋のユーザーを探していることです。彼らのプロジェクトページはです SourceForgeでこちら, 、しかし、過去6年間は恐ろしく活動的ではなかったようです。最新バージョンは古いので、それが作業するために古いコンパイラ(およびOS?)が必要である可能性があります。 ICK。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top