0

在 Yocto 和 Golang 方面需要一些帮助。我正在为一个 golang 应用程序开发一个配方,它的导入非常简陋:

import (
    // standart imports skipped
    "github.com/bmizerany/pat"
    _ "github.com/mattn/go-sqlite3"
)

因此,当我构建和运行 Yocto 映像时,问题就出现了,所以CGO_ENABLED=0在 .bb(或 local.conf)中,一切都构建得很好,但在运行时我得到:

Binary was compiled with CGO_ENABLED=0, go-sqlite3 requires cgo to work. This is a stub

好的,然后我正在构建没有CGO_ENABLED=0do_compile 阶段开始分解,实际上我设法编译它,但在我的配方.bb 中没有链接:

### adding sysroot paths because Go uses recipe-sysroot-native by default:
CGO_CFLAGS += "-I${PKG_CONFIG_SYSROOT_DIR}/usr/include"
CGO_CFLAGS += "-mfloat-abi=hard -mfpu=neon"
CGO_LDFLAGS += "-L${PKG_CONFIG_SYSROOT_DIR}/usr/lib -L${PKG_CONFIG_SYSROOT_DIR}/lib"

ld到处都是疯狂地丢失目标文件,例如:

| WARNING: exit code 2 from a shell command.                                                                                                                                                                       
| ERROR: Execution of '<path>/0.1-r0/temp/run.do_compile.17582' failed with exit code 2:                           
| <path>/0.1-r0/recipe-sysroot-native/<path>/10.2.0/ld: cannot find Scrt1.o: No such file or directory
| <path>/0.1-r0/recipe-sysroot-native/<path>/10.2.0/ld: cannot find crti.o: No such file or directory
| <path>/0.1-r0/recipe-sysroot-native/<path>/10.2.0/ld: cannot find crtbeginS.o: No such file or directory
| collect2: error: ld returned 1 exit status

有人可以帮我解决这个问题吗?具有基于 C 的依赖项的 Golang 真的适用于 Yoctohardknott吗?

4

0 回答 0