Compilation 如何交叉编译.gpr项目文件和gprbuild?

Compilation 如何交叉编译.gpr项目文件和gprbuild?,compilation,cross-compiling,ada,gnat,gprbuild,Compilation,Cross Compiling,Ada,Gnat,Gprbuild,我正试图从Linux(Fedora29)交叉编译一个以Windows为目标的Ada程序。我对汇编一无所知,我是一个无可奈何的人。 我更喜欢在项目文件中使用开关,并尽可能使命令保持最简单。我该怎么办 我尝试了gprbuild-plogfilter.gpr--target=Windows,这会导致 Error: no compiler found for language 'c', target = Windows, default runtime Error: no compiler found

我正试图从Linux(Fedora29)交叉编译一个以Windows为目标的Ada程序。我对汇编一无所知,我是一个无可奈何的人。 我更喜欢在项目文件中使用开关,并尽可能使命令保持最简单。我该怎么办

我尝试了
gprbuild-plogfilter.gpr--target=Windows
,这会导致

Error: no compiler found for language 'c', target = Windows, default runtime
Error: no compiler found for language 'ada', target = Windows, default runtime
logfilter.gpr:3:09: warning: no compiler specified for language "Ada", ignoring all its sources
logfilter.gpr:7:19: "log_filter_main.adb" is not a source of project "logfilter"
gprbuild: problems with main sources

这是我的
gprconfig

prconfig has found the following compilers on your PATH.
  Only those matching the target and the selected compilers are displayed.
   1. GNAT for Ada in /usr/bin/ version 8.3 (default runtime)
   2. GCC-ASM for Asm in /usr/bin/ version 8.3.1
   3. GCC-ASM for Asm2 in /usr/bin/ version 8.3.1
   4. GCC-ASM for Asm_Cpp in /usr/bin/ version 8.3.1
   5. LLVM for C in /usr/bin/ version 7.0.1
   6. GCC for C in /usr/bin/ version 8.3.1
   7. G++ for C++ in /usr/bin/ version 8.3.1
我的
gprconfig——显示目标:

List of targets supported by a compiler:
x86_64-redhat-linux
x86_64-unknown-linux-gnu
这是我的
文件.gpr

with "../../lib/gnat/gtkada";

project LogFilter is
    for Source_Dirs use ("src");
    for Object_Dir  use "obj";
    for Exec_Dir    use "exec";
    for Main use ("log_filter_main.adb");

   package Builder is
      for Executable ("main.adb") use "Logs_Filter";
   end Builder;

   package Compiler is
      for Switches ("ada") use ("-gnat2012");
   end Compiler;

end Logfilter;

有一次我用软呢帽做了这个。但这需要构建一个交叉编译器。我还有一个

我在fedora上填写了一个请求,要求在交叉编译器的windows中包含ada,但他们关闭了它。但是,我找不到错误号

请告诉我您是否对本手册的新版本或使用说明感兴趣

更新:我已经为FC29重建了十字架。您可以这样尝试:

dnf copr enable reznik/ada
dnf install mingw64-gcc-gnat
dnf install gprbuild

sed -i -e 's/-pc-mingw/-w64-mingw/g' /usr/share/gprconfig/*

cat > hello.adb << EOF
with Ada.Text_IO;
procedure Hello is
begin
   Ada.Text_IO.Put_Line ("Hello");
end Hello;
EOF

cat > hello.gpr << EOF
project Hello is
   for Main use ("hello.adb");
end Hello;
EOF
gprbuild --target=x86_64-w64-mingw32 -P hello.gpr
file hello.exe

hello.exe: PE32+ executable (console) x86-64, for MS Windows
dnf copr启用reznik/ada
dnf安装mingw64 gcc gnat
dnf安装gprbuild
sed-i-e's/-pc mingw/-w64 mingw/g'/usr/share/gprconfig/*

cat>hello.adb hello.gpr正如其他人所指出的,您遇到的问题是因为您没有使用。 只是想澄清一下关于
gprbuild
的一些事情,这可能会让事情变得更清楚:
gprbuild
只是系统上
gcc
gnat
版本的前端。本质上,它只是Ada特有的
make
类似物。它处理项目配置文件并计算出要构建的项目的哪些部分。从
gprconfig
输出来看,您使用的似乎是从Fedora repos获得的FSF GNAT
gprconfig--show targets
仅显示在
$PATH
中找到的本机Linux编译器的名称


要解决您的问题,您需要找到一个面向Windows的Ada编译器。AdaCore提供了一个相当不错的本机Windows编译器(如果您可以选择的话)。

您似乎没有安装交叉编译器。grpbuild是否能够使用良好的参数自行交叉编译?不,它需要了解目标编译器,您的
gprconfig--show targets
只列出linux目标…我注意到它只列出linux目标。我将搜索交叉编译器。一般来说,您需要按照以下步骤构建gnat交叉编译器。在执行
dnf搜索交叉编译器时,我发现许多mingw64和32数据包-MinGW Windows交叉编译器。。。遗憾的是,我不知道是否有人能和Ada合作。然而,我对你的解决方案感兴趣!不幸的是,我在Linux发行版中看到的大多数预打包的跨GCC构建都不包括Ada支持。网上有一些为Ada构建交叉编译器的人提供的资源:如果你需要走这条路,这是一个开始。我为FC29编译了交叉编译器,并更新了答案。与你的示例非常吻合。但是,它不适用于我的项目并生成此错误:
Bind[gprbind]log\u filter\u main.bexch[Ada]log\u filter\u main.ali错误:“log\u filter\u main.adb”必须重新编译(“system.ads”已被修改)错误:“s-stalib.adb”必须编译错误:(“/usr/lib/gcc/x86\u 64-w64-mingw32/8.3.0/adalib/s-stalib.ali”已过时且为只读)错误:“log\u filter\u handlers.adb”必须重新编译(“system.ads”已被修改)错误:“a-except.adb”必须编译
以及更多您的项目配置中是否有使用自定义运行时的指令?这看起来像是Ada运行时的问题。我曾经遇到过类似的问题,但这是因为我使用不同的编译器编译了运行时。使用Windows本机工具可以以最少的挫折获得最佳结果。我在Windows 10上使用GPS,为了正确运行我的GtkAda应用程序,我将它运行到外部终端。。。而且它有效!谢谢大家的回答!