使用Eclipse的C应用程序的交叉编译

时间:2021-09-02 12:28:17

I'm developing a java application which uses native code with JNI, so I developped a C shared library using Eclipse with the CDT plugin on Linux Redhat. Everything works fine since I can launch my java application and call the native methods without any problem. But my problem is, I need to compile my code on every platform (Linux, Windows, x86/x64). It's not a problem to get the libXXX.so file but I also need a .dll to run on Windows, except I can't just compile my code on it, I need a way to do that locally on Linux with Eclipse. So I am looking for some simple solutions to do that locally with Eclipse using cross compilation.

我正在开发一个使用JNI本机代码的java应用程序,所以我使用Eclipse和Linux Redhat上的CDT插件开发了一个C共享库。一切正常,因为我可以启动我的java应用程序并调用本机方法没有任何问题。但我的问题是,我需要在每个平台(Linux,Windows,x86 / x64)上编译我的代码。获取libXXX.so文件不是问题,但我还需要一个.dll才能在Windows上运行,除了我不能在其上编译我的代码,我需要一种方法在Linux上使用Eclipse本地执行。所以我正在寻找一些简单的解决方案,使用交叉编译在Eclipse本地完成。

I've made some researches but I can't find a real tutorial to explain how to do that, each time people say to compile on the specified platform. So if someone could help me with this that would be great.

我做了一些研究,但是每次人们说要在指定的平台上编译时,我都找不到真正的教程来解释如何做到这一点。所以,如果有人可以帮助我,这将是伟大的。

My configuration is : Linux RedHat, Eclipse Juno, CDT plugin 8.1

我的配置是:Linux RedHat,Eclipse Juno,CDT插件8.1

1 个解决方案

#1


1  

You need a Linux -> Windows cross compiler. The MinGW tools would do the job, but, last I checked, they only provide binary downloads to run on Windows (i.e. not a cross-compiler). There are some (old) instructions for building your own here.

你需要一个Linux - > Windows交叉编译器。 MinGW工具可以完成这项工作,但是,最后我检查过,它们只提供在Windows上运行的二进制下载(即不是交叉编译器)。这里有一些(旧)指令可用于构建自己的指令。

The CodeBench compiler is probably exactly what you want, but it's not free (there is a free trial though). It's basically a professional build of the MinGW tools, and comes with it's own customized Eclipse so there's no fiddling about needed in that department.

CodeBench编译器可能正是您想要的,但它不是免费的(虽然有免费试用版)。它基本上是MinGW工具的专业版本,并且附带了自己定制的Eclipse,因此在该部门中无需摆弄。

A quick google also comes up with these tools on sourceforge, but I've not tried them.

一个快速谷歌也在sourceforge上提出了这些工具,但我没试过它们。

#1


1  

You need a Linux -> Windows cross compiler. The MinGW tools would do the job, but, last I checked, they only provide binary downloads to run on Windows (i.e. not a cross-compiler). There are some (old) instructions for building your own here.

你需要一个Linux - > Windows交叉编译器。 MinGW工具可以完成这项工作,但是,最后我检查过,它们只提供在Windows上运行的二进制下载(即不是交叉编译器)。这里有一些(旧)指令可用于构建自己的指令。

The CodeBench compiler is probably exactly what you want, but it's not free (there is a free trial though). It's basically a professional build of the MinGW tools, and comes with it's own customized Eclipse so there's no fiddling about needed in that department.

CodeBench编译器可能正是您想要的,但它不是免费的(虽然有免费试用版)。它基本上是MinGW工具的专业版本,并且附带了自己定制的Eclipse,因此在该部门中无需摆弄。

A quick google also comes up with these tools on sourceforge, but I've not tried them.

一个快速谷歌也在sourceforge上提出了这些工具,但我没试过它们。