You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ada库GPR项目中gprinstall命令无法正常工作的问题

Troubleshooting gprinstall Not Performing Installation Actions

I've looked through your project setup and the issue you're facing—where gprinstall only outputs "Install project LibA" without any actual installation steps—boils down to a few key configuration gaps in your GPR files. Let's break down the problems and fix them step by step.

Key Issues Identified

  • Empty Source_Dirs in InterfaceA: Your InterfaceA project declares an empty Source_Dirs even though you define Interface_Files pointing to its source directory. gprinstall relies on project Source_Dirs to locate interface files (.ads) for installation, so this prevents it from finding the files you want to expose.
  • Ambiguous Library Source Configuration: The Library_Src_Dir in LibA points to Public_Interfaces, but there's no guarantee this directory exists or contains the necessary interface files. Additionally, the link between InterfaceA's sources and what gprinstall should install isn't explicit enough.
  • Path Concatenation Clarity: While your Install package path logic is technically correct, it's convoluted, which can make debugging harder. We'll streamline it to avoid unintended path issues.

Fixed GPR File Configurations

1. Update InterfaceA.gpr

First, fix the Source_Dirs to include the interface files directory so gprinstall can detect the unit you want to expose:

project InterfaceA is
   Interface_Files := (project'Project_Dir & "src");
   Interface_Name := "InterfaceA";
   -- 修正Source_Dirs,明确包含接口文件所在目录
   for Source_Dirs use Interface_Files;
end InterfaceA;

2. Update LibA.gpr

Adjust the Install package to clarify paths, explicitly reference sources to install, and ensure library configuration aligns with gprinstall expectations:

with "../Production_Options/Production_Options.gpr";
with "../InterfaceA/InterfaceA.gpr";

library project LibA is
   for Source_Dirs use ("src") & InterfaceA.Interface_Files;
   for Object_Dir use "obj";
   for Library_Name use project'Name;
   for Library_Dir use "Library";
   for Library_Ali_Dir use "Library_Ali";
   -- 保留Library_Src_Dir,确保目录存在(gprinstall会用它整理安装的接口文件)
   for Library_Src_Dir use "Public_Interfaces";
   for Library_Interface use (InterfaceA.Interface_Name);
   for Library_Kind use "static";

   package Install extends Production_Options.Install is
      -- 使用预定义的Install_Root_Libs简化路径拼接,避免错误
      for Prefix use Production_Options.Install.Install_Root_Libs & project'Name;
      for Mode use "dev";
      for Side_Debug use "true";
      -- 明确告诉gprinstall要安装InterfaceA的源文件
      for Sources use InterfaceA.Interface_Files;
   end Install;

   -- 保留原有的Production_Options重命名设置
end LibA;

3. Production_Options.gpr (Minor Clarification)

Your existing configuration here is mostly fine, so we'll keep it as-is since the main issues lie in the other projects.

Test the Fixed Setup

First, ensure the Public_Interfaces directory exists in your LibA project root (create it if it doesn't). Then run gprinstall without --dry-run and with verbose logging to see detailed actions:

E:\DEV\Projets\Ada\LibA>gprinstall -p -m -f -vv -P LibA.gpr

The -vv flag will output detailed logs showing which files are being collected, where they're being installed, and any errors if they occur.

Verify Installation

After running the command, check the target installation directory ../INSTALL_BUILDS/LIBS/LibA—you should see:

  • A GPR folder with the generated LibA.gpr project file
  • A SRC folder containing your InterfaceA.ads file
  • A BIN folder with the static library libLibA.a
  • An ALI folder with the corresponding ALI files

Once installed, users can simply with "LibA"; in their Ada projects and access the InterfaceA unit without manually referencing paths.

内容的提问来源于stack exchange,提问作者LoneWanderer

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 07:20:06