Yocto无法交叉编译GoLang Wails应用程序。

huangapple go评论123阅读模式
英文:

Yocto Fails to Cross-Compile GoLang Wails Application

问题

我正在使用Yocto Kirkstone为ARMv7定制嵌入式Linux板构建系统。在我的Yocto meta层中,我有go-runtime版本1.20。

我正在尝试在我的目标设备上构建一个简单的GoLang 'wails'应用程序(https://github.com/wailsapp/wails),这个应用程序我在我的Mac上已经构建成功。构建这个应用程序需要安装wails 'cli'。我不确定如何在Yocto中进行交叉编译。请问我该如何完成这个任务?谢谢。

在do_compile()中,以下命令失败:

wails build .

我得到的错误信息如下:

...
| HASH
: "packagefile internal/lazyregexp=PNiPFusr6BDvpzrFOO2q\n" | HASH
: 58443e84e42fc0e5254356b82561065095a39a1606a457c34cf63d8dd364173c | HASH subkey a9f4ce5dc6a5c97cab06b5c8cfec3a64e5db0f7bcc79e02fc0002cafcc719a67 "link-stdout" = 80ee6464b934ca7407296396849147804b0862ee25e2b844a6e9cc98cfa588b3 | qemu-arm: Could not open '/lib/ld-linux-armhf.so.3': No such file or directory | WARNING: /home/sensonix/poky/build-microchip/tmp/work/cortexa5t2hf-neon-vfpv4-poky-linux-gnueabi/go-example/1.0.0-r0/temp/run.do_compile.87405:178 exit 255 from './bin/linux_arm/wails build .' | WARNING: Backtrace (BB generated script): | #1: do_compile, /home/sensonix/poky/build-microchip/tmp/work/cortexa5t2hf-neon-vfpv4-poky-linux-gnueabi/go-example/1.0.0-r0/temp/run.do_compile.87405, line 178 | #2: main, /home/sensonix/poky/build-microchip/tmp/work/cortexa5t2hf-neon-vfpv4-poky-linux-gnueabi/go-example/1.0.0-r0/temp/run.do_compile.87405, line 186

Bitbake配方:

DESCRIPTION = "Wails示例应用程序"
LICENSE = "CLOSED"
LIC_FILES_CHKSUM=""

SRC_URI = "file://wails.json"
SRC_URI += "file://README.md"
SRC_URI += "file://main.go"
SRC_URI += "file://app.go"
SRC_URI += "file://frontend"

GO_IMPORT = "import"
GO_LINKSHARED = ""
PTEST_ENABLED="0"
export GO111MODULE="auto"
CGO_ENABLED = "1"

inherit go goarch

do_compile() {

    cd ${WORKDIR}/build
    export TMPDIR="${GOTMPDIR}"

    ${GO} install github.com/wailsapp/wails/v2/cmd/wails@latest

    export GOPATH="$GOPATH:${S}/src/import/.gopath"

    # 传递所需的cflags/ldflags,以便cgo
    # 可以找到所需的头文件和库
    export CGO_CFLAGS="${CFLAGS} --sysroot=${STAGING_DIR_TARGET}"
    export CGO_LDFLAGS="${LDFLAGS} --sysroot=${STAGING_DIR_TARGET}"

    ./bin/linux_arm/wails build .

    #${GO} build ${GO_LINKSHARED} ${GOBUILDFLAGS} -o streamerapp

    cd ${OLDPWD}

}

do_install() {

    cd ${WORKDIR}/build
    #install -m <permisions> SRC DEST

    mkdir -p ${D}${bindir}
    #install -m 0755 ./wailsapp ${D}${bindir}

    cd ${OLDPWD}

}
英文:

I am using Yocto Kirkstone to build a system for an ARMv7 custom embedded Linux board. I have go-runtime version 1.20 in my Yocto meta layers.

I am trying to build a simple example GoLang 'wails' (https://github.com/wailsapp/wails) application that I am able to build on my Mac for my target. This requires the wails 'cli' to be installed to build the application. I'm not sure how to cross-compile this app with Yocto. How can I accomplish this? Thanks.

This command fails in do_compile():

wails build .

The error I am getting is shown here:

...
| HASH
: &quot;packagefile internal/lazyregexp=PNiPFusr6BDvpzrFOO2q\n&quot; | HASH
: 58443e84e42fc0e5254356b82561065095a39a1606a457c34cf63d8dd364173c | HASH subkey a9f4ce5dc6a5c97cab06b5c8cfec3a64e5db0f7bcc79e02fc0002cafcc719a67 &quot;link-stdout&quot; = 80ee6464b934ca7407296396849147804b0862ee25e2b844a6e9cc98cfa588b3 | qemu-arm: Could not open &#39;/lib/ld-linux-armhf.so.3&#39;: No such file or directory | WARNING: /home/sensonix/poky/build-microchip/tmp/work/cortexa5t2hf-neon-vfpv4-poky-linux-gnueabi/go-example/1.0.0-r0/temp/run.do_compile.87405:178 exit 255 from &#39;./bin/linux_arm/wails build .&#39; | WARNING: Backtrace (BB generated script): | #1: do_compile, /home/sensonix/poky/build-microchip/tmp/work/cortexa5t2hf-neon-vfpv4-poky-linux-gnueabi/go-example/1.0.0-r0/temp/run.do_compile.87405, line 178 | #2: main, /home/sensonix/poky/build-microchip/tmp/work/cortexa5t2hf-neon-vfpv4-poky-linux-gnueabi/go-example/1.0.0-r0/temp/run.do_compile.87405, line 186

Bitbake Recipe:

DESCRIPTION = &quot;Wails Example App&quot;
LICENSE = &quot;CLOSED&quot;
LIC_FILES_CHKSUM=&quot;&quot;

SRC_URI = &quot;file://wails.json&quot;
SRC_URI += &quot;file://README.md&quot;
SRC_URI += &quot;file://main.go&quot;
SRC_URI += &quot;file://app.go&quot;
SRC_URI += &quot;file://frontend&quot;

GO_IMPORT = &quot;import&quot;
GO_LINKSHARED = &quot;&quot;
PTEST_ENABLED=&quot;0&quot;
export GO111MODULE=&quot;auto&quot;
CGO_ENABLED = &quot;1&quot;

inherit go goarch

do_compile() {

    cd ${WORKDIR}/build
    export TMPDIR=&quot;${GOTMPDIR}&quot;

    ${GO} install github.com/wailsapp/wails/v2/cmd/wails@latest

    export GOPATH=&quot;$GOPATH:${S}/src/import/.gopath&quot;

    # Pass the needed cflags/ldflags so that cgo
    # can find the needed headers files and libraries
    export CGO_CFLAGS=&quot;${CFLAGS} --sysroot=${STAGING_DIR_TARGET}&quot;
    export CGO_LDFLAGS=&quot;${LDFLAGS} --sysroot=${STAGING_DIR_TARGET}&quot;

    ./bin/linux_arm/wails build .

    #${GO} build ${GO_LINKSHARED} ${GOBUILDFLAGS} -o streamerapp

    cd ${OLDPWD}

}

do_install() {

    cd ${WORKDIR}/build
    #install -m &lt;permisions&gt; SRC DEST

    mkdir -p ${D}${bindir}
    #install -m 0755 ./wailsapp ${D}${bindir}

    cd ${OLDPWD}

}

答案1

得分: 0

我用以下配方解决了这个问题。

DESCRIPTION = "Wails示例应用程序"
LICENSE = "CLOSED"
LIC_FILES_CHKSUM=""

LICENSE = "CLOSED"

SRC_URI = "git://git@github.com/abc/go-wails-demo.git;branch=master;protocol=ssh"
SRCREV = "eaa61c30bff997c811da1d176c7273cea4f6b7d8"

GO_IMPORT = "import"
GO_LINKSHARED = ""
PTEST_ENABLED="0"
CGO_ENABLED = "1"

DEPENDS = "nodejs-native"
DEPENDS += "gtk+3 webkitgtk"

INSANE_SKIP:${PN} += "already-stripped"

inherit go goarch pkgconfig

do_compile() {

    # 允许克隆专有存储库
    git config --global --add url."git@github.com:".insteadOf "https://github.com/"
    ${GO} env -w GOPRIVATE="github.com/abc"

    cd ${WORKDIR}/go-wails-demo-1.0.0/src/import
    export TMPDIR="${GOTMPDIR}"

    # 传递所需的cflags/ldflags,以便cgo
    # 可以找到所需的头文件和库
    export QEMU_LD_PREFIX="${STAGING_DIR_TARGET}"
    export GOARCH=${TARGET_GOARCH}
    export CGO_ENABLED="1"
    export CGO_CFLAGS="${CFLAGS} --sysroot=${STAGING_DIR_TARGET}"
    export CGO_LDFLAGS="${LDFLAGS} --sysroot=${STAGING_DIR_TARGET}"
    export GO111MODULE="on"
    export GOPATH="${WORKDIR}/build"
    export GIT_TERMINAL_PROMPT=1

    ${GO} install github.com/wailsapp/wails/v2/cmd/wails@latest

    /usr/bin/sync
    sleep 0.5

    ${WORKDIR}/build/bin/linux_arm/wails build .

}

do_install() {

    cd ${WORKDIR}/go-wails-demo-1.0.0/src/import/build/bin

    mkdir -p ${D}${bindir}
    install -m 0755 ./react-wails-demo ${D}${bindir}

    cd ${OLDPWD}

}
英文:

I solved it with the following recipe.

DESCRIPTION = &quot;Wails Example App&quot;
LICENSE = &quot;CLOSED&quot;
LIC_FILES_CHKSUM=&quot;&quot;

LICENSE = &quot;CLOSED&quot;

SRC_URI = &quot;git://git@github.com/abc/go-wails-demo.git;branch=master;protocol=ssh&quot;
SRCREV = &quot;eaa61c30bff997c811da1d176c7273cea4f6b7d8&quot;

GO_IMPORT = &quot;import&quot;
GO_LINKSHARED = &quot;&quot;
PTEST_ENABLED=&quot;0&quot;
CGO_ENABLED = &quot;1&quot;

DEPENDS = &quot;nodejs-native&quot;
DEPENDS += &quot;gtk+3 webkitgtk&quot;

INSANE_SKIP:${PN} += &quot;already-stripped&quot;

inherit go goarch pkgconfig

do_compile() {

    # Allow cloning of properietary repositories
    git config --global --add url.&quot;git@github.com:&quot;.insteadOf &quot;https://github.com/&quot;
    ${GO} env -w GOPRIVATE=&quot;github.com/abc&quot;

    cd ${WORKDIR}/go-wails-demo-1.0.0/src/import
    export TMPDIR=&quot;${GOTMPDIR}&quot;

    # Pass the needed cflags/ldflags so that cgo
    # can find the needed headers files and libraries
    export QEMU_LD_PREFIX=&quot;${STAGING_DIR_TARGET}&quot;
    export GOARCH=${TARGET_GOARCH}
    export CGO_ENABLED=&quot;1&quot;
    export CGO_CFLAGS=&quot;${CFLAGS} --sysroot=${STAGING_DIR_TARGET}&quot;
    export CGO_LDFLAGS=&quot;${LDFLAGS} --sysroot=${STAGING_DIR_TARGET}&quot;
    export GO111MODULE=&quot;on&quot;
    export GOPATH=&quot;${WORKDIR}/build&quot;
    export GIT_TERMINAL_PROMPT=1

    ${GO} install github.com/wailsapp/wails/v2/cmd/wails@latest

    /usr/bin/sync
    sleep 0.5

    ${WORKDIR}/build/bin/linux_arm/wails build .

}

do_install() {

    cd ${WORKDIR}/go-wails-demo-1.0.0/src/import/build/bin

    mkdir -p ${D}${bindir}
    install -m 0755 ./react-wails-demo ${D}${bindir}

    cd ${OLDPWD}

}

huangapple
  • 本文由 发表于 2023年4月1日 02:18:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/75901591.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定