doudou348131346 2017-12-19 17:43
浏览 186

无法使用cgo在32位linux上进行构建

I am trying to build a application which will use 32bit Linux libraries via cgo (64bit version doesn't exist).

Trying to build as 64bit doesn't work with the 32bit libraries:

[performance goListen]> go build
# goListen
/usr/bin/ld: skipping incompatible /apps/install/tibco/tibrv/live/lib/libtibrv.so when searching for -ltibrv
/usr/bin/ld: skipping incompatible /apps/install/tibco/tibrv/live/lib/libtibrv.a when searching for -ltibrv
/usr/bin/ld: cannot find -ltibrv
collect2: ld returned 1 exit status

When I try to build it as 32bit it complains that there are no buildable source files:

[performance goListen]> GOARCH=386 go build
can't load package: package goListen: no buildable Go source files in /apps/sierra/shares/sierra_aps/godev/src/goListen

Here is my code - I know it won't work but I just want it to try and compile!

package main

/*
#cgo !windows CFLAGS: -I/apps/install/tibco/tibrv/live/include/tibrv
#cgo !windows LDFLAGS: -L/apps/install/tibco/tibrv/live/lib -ltibrv
#cgo windows CFLAGS: -ID:/Rendez-vous/include/tibrv
#cgo windows LDFLAGS: -LD:/Rendez-vous/lib -ltibrv
#include "tibrv.h"
*/
import "C"
import "fmt"

func main() {
    fmt.Println(C.tibrv_Open())
}

Any advice would be greatly appreciated.

  • 写回答

1条回答 默认 最新

  • dtsc1684 2017-12-20 06:46
    关注

    Thanks to JimB who has it right in the comments:

    You have to enable cgo explicitly when cross-compiling. – JimB

    Specifically, this worked for me:

    CGO_ENABLED=1 GOOS=linux GOARCH=386 go build
    
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器