Community Compiler 25.0w中Ada程序.gpr开关配置编译调试报错求助
Ada编译调试报错解决方案
报错信息
[2024-12-12 11:24:45] Could not determine the project for file: D:\ada\project\Sudoku\Sudoku_main.gpr
[2024-12-12 11:24:45] Could not expand argument in command line: %fp
[2024-12-12 11:24:45] Build command not launched。
1. 修复GPR文件的不完整分支配置
你的Sudoku_main.gpr中relocatable分支为空,这会导致项目解析失败,IDE无法正常识别项目结构。补全该分支的必要配置:
with "gtkada"; project Sudoku_main is for Object_Dir use "./build"; for Exec_Dir use "./execute"; type Build_Kind is ("static", "relocatable"); Library_Type : Build_Kind := external ("LIBRARY_TYPE", "static"); case Library_Type is when "static" => for Source_Dirs use ("./src", "../../Standaarden/Standaard Packages/Pipe/", "../../Standaarden/Standaard Packages/Init/", "../../Standaarden/Standaard Packages/Strings/"); -- "../../Standaarden/Standaard Packages/Debugging/"); for Main use ("Sudoku_main.adb"); when "relocatable" => -- 补全relocatable分支的核心配置 for Source_Dirs use ("./src", "../../Standaarden/Standaard Packages/Pipe/", "../../Standaarden/Standaard Packages/Init/", "../../Standaarden/Standaard Packages/Strings/"); for Main use ("Sudoku_main.adb"); end case; package Ide is for Documentation_Dir use "./doc"; end Ide; package Builder is case Library_Type is when "static" => for Default_Switches ("ada") use ("-s", "-m", "-j4", "-g"); when "relocatable" => for Default_Switches ("ada") use ("-s"); end case; end Builder; package Compiler is case Library_Type is when "static" => for Default_Switches ("ada") use ("-gnatQ", "-g", "-gnata", "-gnatf"); when "relocatable" => for Default_Switches ("ada") use ("-O2"); end case; end Compiler; package Linker is -- for Windows production only ;; remove for Linux / Mac / Win debug case Library_Type is when "static" => for Default_Switches ("ada") use ("-mwindows", "-g"); when "relocatable" => for Default_Switches ("ada") use ("-mwindows"); end case; end Linker; end Sudoku_main;
2. 修正IDE构建命令变量
%fp无法展开说明IDE的构建命令模板存在问题,需调整配置:
- 打开IDE的构建/调试设置页面
- 替换错误的
%fp变量为IDE支持的项目路径变量(比如GNAT Studio中用%PP) - 或手动指定构建命令:
gprbuild -P "D:\ada\project\Sudoku\Sudoku_main.gpr" -XLIBRARY_TYPE=static
3. 验证依赖与路径有效性
- 确认
gtkada库已正确安装,可通过gnatls -v命令查看库路径是否被系统识别 - 检查
Source_Dirs中的相对路径是否正确,确保目标目录真实存在 - 先在命令行执行
gprbuild -P Sudoku_main.gpr -XLIBRARY_TYPE=static,验证项目本身能否正常构建,排除IDE配置干扰
内容的提问来源于stack exchange,提问作者ldries46
相关产品推荐
相关产品推荐

