如何在没有cmakelists.txt的情况下为Android进行交叉编译?

发布于 2025-02-04 05:21:39 字数 306 浏览 0 评论 0原文

我知道,如果一个C ++项目具有CMakelists.txt,我可以创建一个新项目,并使用Android Studio来编译可执行文件以通过控制台在Android上运行。 但是,有些项目没有cmakelist.txt,需要运行。 /配置然后进行。例如 https://github.com/strukturag/libheif 是否有一个简单的工具可以在Windows上为Android编译它?

I know that if a C++ project has CMakeLists.txt, I can create a new project and use Android studio to compile the executable to run on Android via console.
However, some projects don't have CMakeList.txt and need to run . /configure and then make. e.g. https://github.com/strukturag/libheif
Is there a easy tool that can compile it for Android on Windows?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谁把谁当真 2025-02-11 05:21:39

以下假设您已安装了mingw,并且还与平台兼容了交叉兼容器。另外,我不是此类开发的Windows的忠实拥护者。因此,我的解释是针对Linux。但是我相信您可以轻松地适应您的情况。

首先,您需要安装交叉补偿器。为了解释,我将在这里使用GCC-Linaro。

如果打开回购,您会发现有一个称为 autogen.sh 的文件。
您需要运行它。该文件将创建配置工具。
完成后,将出现一个称为配置的文件。
这是您要使用的工具来配置要编译的库,并根据您的特定需求进行自定义。

您要运行的下一个命令是

./configure --help

上面的命令将向您显示您可以设置的所有选项。您可以与它们一起玩,但是通常,您至少要设置以下内容:

  • cc
  • -prefix
  • -includedir -
  • libdir-主机
  • - 主机

这些选项都在配置工具中解释。为了让您了解如何使用它们,以下是您可能要运行的通用命令:

CC="<path to your gcc compiler>" ./configure --prefix="<path_to_the_folder_where_you_want_to_install>" --includedir="<path_to_the_include_dir>" --libdir="<path_to_the_lib_dir>" --host=arm

在我的情况下,我已经在以下路径上安装了交叉编译器

/home/alexis/gcc-linaro/bin/arm-linux-gnueabi-gcc

,因此我需要运行命令:

CC="/home/alexis/gcc-linaro/bin/arm-linux-gnueabi-gcc" ./configure --prefix=/home/alexis/gcc-linaro --includedir=/home/alexis/gcc-linaro/include --libdir=/home/alexis/gcc-linaro/lib --host=arm

希望此帮助。

The following assumes that you have mingw installed and also a cross-compiler compatible with your platform. Also, I'm not a big fan of Windows for this type of development. So my explanation is for Linux. But I believe you can easily adapt it to your case.

First of all, you need to install a cross-compiler. For the sake of explanation, I'm going to use gcc-linaro here.

If you open the repo, you'll see that there is a file called autogen.sh.
You will need to run it. This file will create the configuration tool.
Once it finishes, a file called configure will appear.
This is the tool you want to use for configuring the library to be compiled, customized for your specific needs.

The next command you want to run is

./configure --help

The above command will show you all the options that you can set. You can play with them but, typically, you want to set the following, at least:

  • CC
  • --prefix
  • --includedir
  • --libdir
  • --host

These options are explained in the configure tool. To give you an idea on how to use them, the following is the generic command that you might want to run:

CC="<path to your gcc compiler>" ./configure --prefix="<path_to_the_folder_where_you_want_to_install>" --includedir="<path_to_the_include_dir>" --libdir="<path_to_the_lib_dir>" --host=arm

In my situation, I have installed the cross compiler at the following path

/home/alexis/gcc-linaro/bin/arm-linux-gnueabi-gcc

Therefore, I would need to run the command:

CC="/home/alexis/gcc-linaro/bin/arm-linux-gnueabi-gcc" ./configure --prefix=/home/alexis/gcc-linaro --includedir=/home/alexis/gcc-linaro/include --libdir=/home/alexis/gcc-linaro/lib --host=arm

Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文