标签: gnat-gps

如何创建ada lib.a并链接到C

我正在尝试创建一个ada库,并尝试了一些不同的东西.我尝试使用makefile编译项目并尝试从所有.o文件创建一个库这似乎不能按预期工作.然后我问adacore支持,他们指出了我在ada和c项目中使用.gpr文件的方向,以及应该创建库的ada.gpr中的文件.这几乎可以工作,但当它试图编译ada我得到未定义的引用.

我试过的:命令行:

ar rc libmy_lib.a *.o
Run Code Online (Sandbox Code Playgroud)

当我尝试阅读lib中的内容时

ld libmy_lib.a
Run Code Online (Sandbox Code Playgroud)

我得到这个错误ld:警告:找不到条目符号_start; 没有设置起始地址

项目文件:我的ada项目文件prj.gpr

project Prj is
for Source_Dirs use ("source1/", "source2", ....);
for Object_Dir use ".";

for Languages use ("Ada");
for Library_Name use "test";
for Library_Dir use "lib";
for Library_Interface use (
 --All my ada packages
        );

package Naming is
      for Spec_Suffix ("ada") use ".1.ada";
      for Body_Suffix ("ada") use ".2.ada";
      for Separate_Suffix use ".2.ada";
      for Dot_Replacement use ".";
   end Naming;

   package Compiler is
      for Default_Switches ("ada") use ("-v", "-g", "-gnato", "-gnatwa", …
Run Code Online (Sandbox Code Playgroud)

c ada gnat gnat-gps

6
推荐指数
1
解决办法
3363
查看次数

在GPS IDE中调试

我正在使用GPS IDE进行Ada 95编码.当我尝试在.adb文件中放置一个断点时,我收到一条消息"没有名为filename.adb的源文件".我构建了项目并初始化了调试器.什么可能出错?

奇怪的是,我能够执行该程序.

ada gnat-gps

5
推荐指数
1
解决办法
1735
查看次数

我如何指定函数或过程 GNATTest 应自动生成测试用例

我正在开发一个巨大的代码包(主要是用 ada 编写的),这是一个极其混乱的情况。到目前为止,尚未应用任何单元测试,并且对于所有现有代码,不得实施单元测试。但我们的团队决定,所有新代码都应该与测试一起实现。在 GPS 中,可以让 GNATtest 自动生成项目中所有功能和程序的测试程序。但正如所写,我们必须从自动生成中排除所有旧代码。

有没有办法将函数和过程标记为“需要测试”?

ada gnat gnat-gps aunit

5
推荐指数
1
解决办法
271
查看次数

在 Ada 中动态链接库会引入额外的依赖项

我在动态和静态链接 Ada 中的库时遇到问题。我准备了一个最低限度的工作示例。这三个文件定义了一个输出“Hello world”的库:

helloworld_lib.gpr :

project Helloworld_Lib is

   for Library_Name use "helloworld_lib";
   for Source_Files use ("helloworld_lib.adb", "helloworld_lib.ads");
   for Library_Kind use "static";
   for Library_Dir use "obj";

end Helloworld_Lib;
Run Code Online (Sandbox Code Playgroud)

helloworld_lib.adb

with Ada.Text_IO;

package body helloworld_lib is

   procedure Hello is
   begin
      Ada.Text_IO.Put_Line("Hello world");
   end Hello;

end helloworld_lib;
Run Code Online (Sandbox Code Playgroud)

helloworld_lib.ads

with Ada.Text_IO;
use Ada.Text_IO;

package helloworld_lib is

   procedure Hello;

end helloworld_lib;
Run Code Online (Sandbox Code Playgroud)

这两个文件定义了一个导入库并运行它的项目:

helloworld_interface.gpr :

with "helloworld_lib.gpr";

project Helloworld_Interface is

   for Create_Missing_Dirs use "True";
   for Main use ("helloworld_interface.adb");
   for Source_Files use ("helloworld_interface.adb");
   for …
Run Code Online (Sandbox Code Playgroud)

dll ada gnat gnat-gps

5
推荐指数
1
解决办法
269
查看次数

我应该怎么做才能解决 GNAT GPS“未找到库”问题并在我的 Mac 上构建我的第一个“Hello World”程序?

我下载了 GNAT Community 2019 并安装在我的 Mac 上的主文件夹“/Users/leon/opt/GNAT”中

我在目录“/Users/leon/opt/GNAT/2019/bin”中运行命令“gps”。GPS出现了,然后我创建了一个项目,输入了“Hello World”代码。正如维基教科书所示。

with Ada.Text_IO;

procedure Hello is
begin
   Ada.Text_IO.Put_Line("Hello, world!");
end Hello;
Run Code Online (Sandbox Code Playgroud)

当我单击构建按钮时,程序无法构建。

以下是建筑输出。

gprbuild -d -P/Users/leon/Documents/ada/helloworld.gpr /Users/leon/Documents/ada/src/hello.adb
Compile
   [Ada]          hello.adb
Bind
   [gprbind]      hello.bexch
   [Ada]          hello.ali
Link
   [link]         hello.adb
ld: library not found for -lSystem
collect2: error: ld returned 1 exit status
gprbuild: link of hello.adb failed
gprbuild: failed command was: /users/leon/opt/gnat/2019/bin/gcc hello.o b__hello.o -L/Users/leon/Documents/ada/obj/ -L/Users/leon/Documents/ada/obj/ -L/users/leon/opt/gnat/2019/lib/gcc/x86_64-apple-darwin17.7.0/8.3.1/adalib/ /users/leon/opt/gnat/2019/lib/gcc/x86_64-apple-darwin17.7.0/8.3.1/adalib/libgnat.a -Wl,-rpath,@executable_path/ -Wl,-rpath,@executable_path/../../..//opt/gnat/2019/lib/gcc/x86_64-apple-darwin17.7.0/8.3.1/adalib -o hello
[2020-02-28 22:36:48] process exited with status 4, elapsed time: …
Run Code Online (Sandbox Code Playgroud)

ada gnat gnat-gps

5
推荐指数
1
解决办法
436
查看次数

你如何在Ada中为向量实现Generic_Sorting?

我正在尝试从许多月前做一些旧C++代码的基本翻译来学习Ada,我一直对如何使用内置Generic_Sorting对矢量进行排序感到困惑.我还没有找到任何具体的实际例子,最接近现在已经不复存在的丹麦维基文章看起来好像有一个完整的例子,但存档没有抓住它:https:// web.archive.org/web/20100222010428/http://wiki.ada-dk.org/index.php/Ada.Containers.Vectors#Vectors.Generic_Sorting

这是我认为应该从上面的链接工作的代码:

with Ada.Integer_Text_IO;    use Ada.Integer_Text_IO;
with Ada.Strings.Unbounded;  use Ada.Strings.Unbounded;
with Ada.Containers.Vectors; use Ada.Containers;

procedure Vectortest is
   package IntegerVector is new Vectors
     (Index_Type   => Natural,
      Element_Type => Integer);
   package IVSorter is new Generic_Sorting;

   IntVec : IntegerVector.Vector;
   Cursor : IntegerVector.Cursor;
begin
   IntVec.Append(3);
   IntVec.Append(43);
   IntVec.Append(34);
   IntVec.Append(8);

   IVSorter.Sort(Container => IntVec);

   Cursor := IntegerVector.First(Input);
   while IntegerVector.Has_Element(Cursor) loop
      Put(IntegerVector.Element(Cursor));
      IntegerVector.Next(Cursor);
   end loop;

end Vectortest;
Run Code Online (Sandbox Code Playgroud)

我试过这么多不同的组合usewith,但所有我能得到的各种错误代码.上面的代码给出了Generic_Sorting is not visible,但是当我尝试明确说明with Ada.Containers.Vectors.Generic_Sorting我得到了错误"Ada.Containers.Vectors.Generic_Sorting" is not a predefined library …

ada gnat gnat-gps ada2012

4
推荐指数
1
解决办法
134
查看次数

如何阻止控制台窗口立即关闭 GNAT-GPS

我有可以使用GNAT-GPS完美运行和编译的Ada程序。当我运行其exe文件并提供用户输入时,而不是说“按任意键继续”,该exe立即关闭。

我已经在线搜索了很多,但是我只使用system('pause')找到了与c / c ++ / visual studio控制台窗口有关的信息;或Console.Readline()。

Ada lanaguage有什么办法解决这个问题吗?

ada gnat-gps

3
推荐指数
1
解决办法
106
查看次数

更新 GPS Community Edition 2019 IDE 的编译器

我最近开始从事一个项目,该项目要求我的编译器高于 GNAT 4.8.5 - 当我去:帮助 > 关于

在此处输入图片说明

可以看到我用的版本是4.8.5

在此处输入图片说明

另外,当我运行 gnatls -v 命令时,我可以看到这个......

[parallels@localhost ~]$ gnatls -v

GNATLS 4.8.5 20150623 (Red Hat 4.8.5-39)
Copyright (C) 1997-2013, Free Software Foundation, Inc.

Source Search Path:
   <Current_Directory>
   /usr/lib/gcc/x86_64-redhat-linux/4.8.5/adainclude/


Object Search Path:
   <Current_Directory>
   /usr/lib/gcc/x86_64-redhat-linux/4.8.5/adalib/


Project Search Path:
   <Current_Directory>
   /usr/x86_64-redhat-linux/lib/gnat
   /usr/share/gpr
   /usr/lib/gnat

[parallels@localhost ~]$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/7.3.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ./configure --disable-multilib --enable-languages=c,c++,ada
Thread model: posix
gcc version 7.3.0 (GCC) 
[parallels@localhost ~]$ 
Run Code Online (Sandbox Code Playgroud)

请问有人能告诉我如何更新我的 GNAT 编译器吗?另外,我使用的是 Centos 7 操作系统。

谢谢,

劳埃德

linux ada gnat gnat-gps

3
推荐指数
1
解决办法
322
查看次数

GNAT Studio - 不能使用非核心 Ada 库

我是 Ada 编程的新手,我正在尝试使用 GNAT Studio IDE 来学习它。

使用 Ada.Text_IO 或 Ada.Numerics 等核心库没有问题,但是当我尝试使用 Libadalang 为例时,编译器没有找到规范文件“libadalang.ads”。

我的代码:

with Ada.Text_IO;
with Libadalang.Analysis;
procedure Main is

begin
   --  Insert code here.
   null;
end Main;
Run Code Online (Sandbox Code Playgroud)

当我点击“Build and Run”按钮时,我得到以下输出:

gprbuild -d -PD:\Users\xxx\prog\ada_workspace\testlibadalang_1\testlibadalang_1.gpr D:\Users\xxx\prog\ada_workspace\testlibadalang_1\src\main.adb
Compile
   [Ada]          main.adb
main.adb:2:06: file "libadalang.ads" not found
gprbuild: *** compilation phase failed
[2020-09-22 19:02:49] process exited with status 4, elapsed time: 01.36s
Run Code Online (Sandbox Code Playgroud)

我在 GNAT Studio 安装文件夹中查找了这个文件,我在C:\GNAT\2020\include\libadalang 中找到了它以及libadalang的所有其他“.ads”和“.adb”文件。

有什么方法可以“告诉”GNAT Studio 在此目录中搜索,以便能够使用“with”关键字调用它们?或者我应该做一些完全不同的事情来使用 Libadalang 吗?

顺便说一句,对不起我的英语不好。

谢谢你。

ada gnat-gps

3
推荐指数
1
解决办法
89
查看次数

如何在 Ada 中添加向量

我有一个 (x,y,x) 形式的向量表示坐标。我希望能够执行 (x,y,z) + (x2,y2,z2) 之类的操作来生成一组新坐标。Ada 说它不能对复合类型使用“+”,但肯定有办法做到这一点吗?

vector ada gnat-gps

2
推荐指数
1
解决办法
157
查看次数

如何在 GNAT CE 2019 中查询 PostgreSQL

我正在尝试使用 GNAT CE 2019 查询 PostgreSQL 数据库。我的数据库中有两个表,car 和 person:

mydb1-# \dt
         List of relations
 Schema |  Name  | Type  |  Owner   
--------+--------+-------+----------
 public | car    | table | postgres
 public | person | table | postgres
(2 rows)
Run Code Online (Sandbox Code Playgroud)

我想执行一个简单的 Select 语句,当我在终端中使用 psql 执行此操作时,返回的是:

mydb1=# SELECT * FROM Person;

              person_uid              | first_name | last_name  | gender |            email             | date_of_birth | country_of_birth |               car_uid                
--------------------------------------+------------+------------+--------+------------------------------+---------------+------------------+--------------------------------------
 75f5e55d-12b2-463e-93ff-1c921e44c3e1 | Audrie     | Vasyukov   | Female | avasyukovd6@domainmarket.com | 1988-11-24    | Guatemala        | 
 9e3f7f90-6e9a-4f2d-ae4e-c852d819ed33 | …
Run Code Online (Sandbox Code Playgroud)

linux postgresql ada gnat-gps ada2012

1
推荐指数
1
解决办法
335
查看次数

Adacore GNATCOLL Postgres 库未安装在 CentOS 8 上

我发布了一个问题,一个几天前就在CentOS 8,这是好心回答安装GNATCOLL库。

我现在尝试安装 gnatcoll postgres 库,我希望这将是相同的过程。但是,当我尝试这样做时,我收到以下错误:

[lloyd@localhost gnatcoll-db-20.0]$ cd postgres
[lloyd@localhost postgres]$ ls
gnatcoll_postgres.gpr              gnatcoll-sql-ranges.ads
gnatcoll-sql-postgres.adb          lib
gnatcoll-sql-postgres.ads          Makefile
gnatcoll-sql-postgres-builder.adb  makefile.setup
gnatcoll-sql-postgres-builder.ads  obj
gnatcoll-sql-postgres-gnade.adb    postgres_support.c
gnatcoll-sql-postgres-gnade.ads    README.md
gnatcoll-sql-ranges.adb
[lloyd@localhost postgres]$ make setup
[lloyd@localhost postgres]$ make
gprbuild -p -m --target=x86_64-linux  -j0 -XGNATCOLL_HASPQPREPARE=yes -XGNATCOLL_VERSION=0.0 -XBUILD=PROD  -XLIBRARY_TYPE=static -XXMLADA_BUILD=static -XGPR_BUILD=static \
    gnatcoll_postgres.gpr
Compile
   [C]            postgres_support.c
   [Ada]          gnatcoll-sql-ranges.adb
   [Ada]          gnatcoll-sql-postgres.adb
   [Ada]          gnatcoll-sql-postgres-gnade.adb
   [Ada]          gnatcoll-sql-postgres-builder.adb
gnatcoll-sql-postgres-gnade.ads:43:14: warning: license of withed unit "GNATCOLL.Strings" may be inconsistent
gnatcoll-sql-postgres-builder.adb:37:14: warning: license of withed unit "GNATCOLL.Strings" may be …
Run Code Online (Sandbox Code Playgroud)

linux postgresql ada gnat-gps centos8

1
推荐指数
1
解决办法
99
查看次数

ada中的object.method表示法

有没有人知道一个很好的资源来解释何时object.method可以在ada中使用符号?

例如:

person.walk(10);
Run Code Online (Sandbox Code Playgroud)

我一直在做一些谷歌搜索,还没有想出来.它只适用于标记记录吗?

我使用GPS作为我的Ada IDE,我非常希望能够bla.<type something>获得建议的方法来调用.

我也有点困惑为什么点符号不能用于第一个参数匹配相关类型的任何东西.

谢谢

马特

oop ada gnat-gps

0
推荐指数
1
解决办法
313
查看次数

标签 统计

ada ×13

gnat-gps ×13

gnat ×6

linux ×3

ada2012 ×2

postgresql ×2

aunit ×1

c ×1

centos8 ×1

dll ×1

oop ×1

vector ×1