Ada库GPR项目中gprinstall命令无法正常工作的问题
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_Dirsin InterfaceA: YourInterfaceAproject declares an emptySource_Dirseven though you defineInterface_Filespointing to its source directory.gprinstallrelies on projectSource_Dirsto 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_DirinLibApoints toPublic_Interfaces, but there's no guarantee this directory exists or contains the necessary interface files. Additionally, the link betweenInterfaceA's sources and whatgprinstallshould install isn't explicit enough. - Path Concatenation Clarity: While your
Installpackage 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
GPRfolder with the generatedLibA.gprproject file - A
SRCfolder containing yourInterfaceA.adsfile - A
BINfolder with the static librarylibLibA.a - An
ALIfolder 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

