代码之家  ›  专栏  ›  技术社区  ›  Josh

如何使用gnatmake编译和链接ADA共享库?

  •  4
  • Josh  · 技术社区  · 14 年前

    我在花店图书馆里又找不到一个申请人。结果发现我在花店有一个更大的问题(同样的错误结果来自Debian存档中最新的2010年Adacore GPL下载和2009年版本)。花店有一些低级的问题,但当我查看生成的文件时,似乎正确地包括errno.h。

    下面是当我建立花店时发生的事情:

    GCC-4.4-C-I/USR/share/ada/adainclude/florsist demo.adb GCC-4.4-C-I./-I/USR/share/ada/adainclude/花店-I-/USR/share/ada/adainclude/花店/posix.adb GCC-4.4-C-I./-I/USR/share/ada/adainclude/花店-I-/USR/share/ada/adainclude/花店/posix-io.adb GCC-4.4-C-I./-I/USR/share/ada/adainclude/florist-I-/USR/share/ada/adainclude/florist/posix-终端_functions.adb GCC-4.4-C-I./-I/USR/share/ada/adainclude/花店-I-/USR/share/ada/adainclude/花店/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.interrupt-management.operations”是一个内部gnat单元 posix实现.gpb:45:06:警告:此单元的使用不可移植,且与版本相关 posix实现.gpb:47:06:警告:“system.software_links”是一个内部gnat单元 posix实现.gpb:47:06:警告:此单元的使用不可移植,且与版本相关 GCC-4.4-C-I./-I/USR/share/ada/adainclude/florsist-I-/USR/share/ada/adainclude/florsist/ada-streams.ads GCC-4.4-C-I./-I/USR/share/ada/adainclude/florsist-I-/USR/share/ada/adainclude/florsist/posix-权限.adb GCC-4.4-C-I./-I/USR/share/ada/adainclude/florist-I-/USR/share/ada/adainclude/florist/posix-permissions-implementation.adb GCC-4.4-C-I./-I/USR/share/ada/adainclude/florist-I-/USR/share/ada/adainclude/florist/posix-process ou identification.adb gnatbind-i/usr/share/ada/adainclude/florsist-x demo.ali gnatlink demo.ali-o demoapp /posix implementation.o:在函数'posix_uu implementation_uu set_ada_error_code'中: posix implementation.adb:(.text+0x19e):未定义对“store_errno”的引用 /posix implementation.o:在函数'posix_uu implementation_u get_ada_error_code'中: posix implementation.adb:(.text+0x1ab):未定义对“fetch-errno”的引用 /posix implementation.o:在函数'posix_uu implementation_uu raise_posix_error'中: posix implementation.adb:(.text+0x234):未定义对“fetch-errno”的引用 /posix implementation.o:在函数'posix_uu implementation_uu check_uu 2'中: posix implementation.adb:(.text+0x2e5):未定义对“fetch-errno”的引用 /posix implementation.o:在函数'posix_uu implementation_uu check_uu 3'中: posix实现.adb:(.text+0x313):未定义对“fetch-errno”的引用 /posix implementation.o:在函数'posix_uuu implementation_uu check_nneg'中: posix implementation.adb:(.text+0x332):未定义对“fetch-errno”的引用 /posix implementation.o:posix implementation.adb:(.text+0x34e):后面是对“fetch-errno”的更多未定义引用 /posix implementation.o:在函数'nosys_neg_one'中: posix实现.adb:(.text+0xaef):未定义对“store_errno”的引用 /posix implementation.o:在函数'notsup_neg_one'中: posix implementation.adb:(.text+0xb15):未定义对“store_errno”的引用 /posix implementation.o:在函数'posix_uu implementation_uu restore_signals_and_raise_posix_error'中: posix实现.adb:(.text+0xc88):未定义对“fetch-errno”的引用 /posix.o:在函数'posix_uuu system_name'中: posix.adb:(.text+0x2f98):未定义对“花店”的引用 /posix.o:在函数'posix_uuu node_name'中: posix.adb:(.text+0x2fef):未定义对“花店”的引用 /posix.o:在函数'posix_uuu release'中: posix.adb:(.text+0x3049):未定义对“花店”的引用 /posix.o:在函数'posix_uuu version'中: posix.adb:(.text+0x30a6):未定义对“花店”的引用 /posix.o:在函数'posix_uuu machine'中: posix.adb:(.text+0x3103):未定义对“花店”的引用 /posix.o:在函数'posix_uuu host_to_network_byte_order'中: posix.adb:(.text+0x4627):未定义的对“c\u htonl”的引用 /posix.o:在函数'posix_uuu host_to_network_byte_order_uuu 2'中: posix.adb:(.text+0x4642):未定义对“c”的引用 /posix.o:在函数'posix_uuu network_to_host_byte_order'中: posix.adb:(.text+0x4655):未定义对“c”的引用 /posix.o:在函数'posix_uuu network_to_host_byte_order_uuu 2'中: posix.adb:(.text+0x4670):未定义对“c”的引用 /posix io.o:在函数'posix_uuu io_uuu open'中: posix io.adb:(.text+0x4d1):未定义对“花店开放”的引用 /posix io.o:在函数'posix_uuu io_uu open_or_create'中: posix io.adb:(.text+0xfca):未定义对“花店开放”的引用 Collect2:ld返回1退出状态 gnatlink:调用/usr/bin/gcc-4.4时出错 gnatmake:***链接失败。 josh@mini10:~/demo$gnatbind-i/usr/share/ada/ada include/florsist-i/usr/include演示 josh@mini10:~/demo$gnatlink演示 /posix implementation.o:在函数'posix_uu implementation_uu set_ada_error_code'中: posix implementation.adb:(.text+0x19e):未定义对“store_errno”的引用 /posix implementation.o:在函数'posix_uu implementation_u get_ada_error_code'中: posix implementation.adb:(.text+0x1ab):未定义对“fetch-errno”的引用 /posix implementation.o:在函数'posix_uu implementation_uu raise_posix_error'中: posix implementation.adb:(.text+0x234):未定义对“fetch-errno”的引用 /posix implementation.o:在函数'posix_uu implementation_uu check_uu 2'中: posix implementation.adb:(.text+0x2e5):未定义对“fetch-errno”的引用 /posix implementation.o:在函数'posix_uu implementation_uu check_uu 3'中: posix实现.adb:(.text+0x313):未定义对“fetch-errno”的引用 /posix implementation.o:在函数'posix_uuu implementation_uu check_nneg'中: posix implementation.adb:(.text+0x332):未定义对“fetch-errno”的引用 /posix implementation.o:posix implementation.adb:(.text+0x34e):后面是对“fetch-errno”的更多未定义引用 /posix implementation.o:在函数'nosys_neg_one'中: posix实现.adb:(.text+0xaef):未定义对“store_errno”的引用 /posix implementation.o:在函数'notsup_neg_one'中: posix implementation.adb:(.text+0xb15):未定义对“store_errno”的引用 /posix implementation.o:在函数'posix_uu implementation_uu restore_signals_and_raise_posix_error'中: posix实现.adb:(.text+0xc88):未定义对“fetch-errno”的引用 /posix.o:在函数'posix_uuu system_name'中: posix.adb:(.text+0x2f98):未定义对“花店”的引用 /posix.o:在函数'posix_uuu node_name'中: posix.adb:(.text+0x2fef):未定义对“花店”的引用 /posix.o:在函数'posix_uuu release'中: posix.adb:(.text+0x3049):未定义对“花店”的引用 /posix.o:在函数'posix_uuu version'中: posix.adb:(.text+0x30a6):未定义对“花店”的引用 /posix.o:在函数'posix_uuu machine'中: posix.adb:(.text+0x3103):未定义对“花店”的引用 /posix.o:在函数'posix_uuu host_to_network_byte_order'中: posix.adb:(.text+0x4627):未定义的对“c\u htonl”的引用 /posix.o:在函数'posix_uuu host_to_network_byte_order_uuu 2'中: posix.adb:(.text+0x4642):未定义对“c”的引用 /posix.o:在函数'posix_uuu network_to_host_byte_order'中: posix.adb:(.text+0x4655):未定义对“c”的引用 /posix.o:在函数'posix_uuu network_to_host_byte_order_uuu 2'中: posix.adb:(.text+0x4670):未定义对“c”的引用 /posix io.o:在函数'posix_uuu io_uuu open'中: posix io.adb:(.text+0x4d1):未定义对“花店开放”的引用 /posix io.o:在函数'posix_uuu io_uu open_or_create'中: posix io.adb:(.text+0xfca):未定义对“花店开放”的引用 Collect2:ld返回1退出状态 gnatlink:调用/usr/bin/gcc-4.4时出错

    如果正确包含errno.h,则此错误似乎很常见。但从posix-c.c文件中我可以看出,所有这些看起来都是正确的。有人对如何解决这个问题有什么建议吗?花店的make文件构建正确,所以我不知道这是从哪里来的。

    3 回复  |  直到 14 年前
        1
  •  6
  •   Josh    14 年前

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

    -aI -aO -lflorist -largs

        2
  •  2
  •   Simon Wright    14 年前

    $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

    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
    
        3
  •  1
  •   T.E.D.    14 年前