C 程序不在 buildroot 上 运行

C program does not run on buildroot

我为 buildroot 工作。我的目的是在我的 buildroot 上使用 Gtk3.0Gstreamer1.0 工作 GUI。我使用 Olinuxino A13,所以我用代码块在上面编写了 GUI 代码(Gtk3.0 hello world 示例)。我使用 Debian wheezy。我想将此代码从 Debian wheezy 转移到 buildroot。

我试过了:

  1. 我转移了 /path_to_proectfile/bin/Debug/my_program.my_program 由 codeblocks 创建的。我在终端和代码工作中写了 ./my_program。我将此文件传输到我的 buildroot,但 ./my_program 不起作用。它returnsNo such file or directory错误。

  2. 我认为问题可能出在编译上,并尝试在终端上编译。我再次使用 gcc -o my_program main.c 'pkg-config --cflags --libs gtk+-3.0' 在 Debian wheezy 终端上工作。在我转移到 buildroot 但结果没有改变之后。我尝试了不同的编译类型,如 ccarm-linux-gnueabi-gcc 等,但每次都出现 No such file or directory 错误。

最后,当我不使用 gtk 库(只使用 printf Hello World)时,我看到了 Hello world。当我添加 gtk 库时 returns No such file or directory 错误。你有什么建议吗?

您需要使用相应的buildroot 工具链交叉编译您的程序。看起来您已经传输了一个针对不同 libc 构建的二进制文件(这会产生 "No such file or directory" 错误)。

可以通过将 CC 设置为 "path_to_buildroot_output/host/bin/arm-linux-*-gcc" 来使用具有正确 libc 的 buildroot 交叉编译器(确切名称取决于您选择的工具链选项)。