在将Objective-C与Golang 1.1链接时遇到问题-在Golang 1.1beta上工作正常。

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

Having issues in linking objective-c with golang 1.1 - was working with golang 1.1beta

问题

需要帮助将Objective-C与Go链接起来。

以下Objective-C代码在golang 1.1beta中工作正常,但现在在最新的go 1.1版本中不起作用。

/*
#cgo CFLAGS: -x objective-c
#cgo LDFLAGS: -framework Cocoa
#import <Cocoa/Cocoa.h>

void
log(void) {
    NSLog(@"from objective-c");
}

*/
import "C"
func New() {
    C.log()
}

当我运行go install或go run <main.go路径>时,我得到以下错误:

(__DATA/__cfstring): dynamic symbol __CFConstantStringClassReference的重定位错误
(__DATA/__cfstring): __CFConstantStringClassReference的未处理重定位(类型28 rtype 120)
英文:

Need help with linking objective-c in go.

Following objective-c code was working with golang 1.1beta but now it doesn't work with the latest go 1.1 release.

/*
#cgo CFLAGS: -x objective-c
#cgo LDFLAGS: -framework Cocoa
#import &lt;Cocoa/Cocoa.h&gt;

void
log(void) {
    NSLog(@&quot;from objective-c&quot;);
}

*/
import &quot;C&quot;
func New() {
    C.log()
}

I get following errors when I run go install or go run <path to main.go>:

(__DATA/__cfstring): unexpected reloc for dynamic symbol __CFConstantStringClassReference
(__DATA/__cfstring): unhandled relocation for __CFConstantStringClassReference (type 28 rtype 120)

答案1

得分: 1

报告了问题#5699,并在Go v1.2中修复了该问题。

英文:

Reported the issue #5699, and it got fixed in Go v1.2.

huangapple
  • 本文由 发表于 2013年6月6日 07:35:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/16951564.html
匿名

发表评论

匿名网友

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

确定