Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/ld: cannot link objective-C code #1781

Closed
rogpeppe opened this issue May 6, 2011 · 10 comments
Closed

cmd/ld: cannot link objective-C code #1781

rogpeppe opened this issue May 6, 2011 · 10 comments
Milestone

Comments

@rogpeppe
Copy link
Contributor

rogpeppe commented May 6, 2011

When cgo is used to compile objective-C code (see also CL 4476049), the resulting
objects cannot be linked.
I get errors like this:

_test/tst-go.nowhere.com/tst.a(tst.cgo2.o)(__DATA/__objc_classrefs): unhandled
relocation for OBJC_CLASS_$_NSApplication (type 20 rtype 120)

Given that it is necessary to use Objective-C to interact with much of the Mac OS system
functionality (e.g. graphics), it would be nice to be able to fix this.

Attached is a package that demonstrates the problem (gotest to try).

6g darwin 502384dd99e8+ tip

Attachments:

  1. tstcgo.zip (788 bytes)
@robpike
Copy link
Contributor

robpike commented May 6, 2011

Comment 1:

Labels changed: added cgo.

Status changed to Accepted.

@robpike
Copy link
Contributor

robpike commented May 6, 2011

Comment 2:

Owner changed to @rsc.

@rsc
Copy link
Contributor

rsc commented May 6, 2011

Comment 3:

thanks for the CL

@rsc
Copy link
Contributor

rsc commented Dec 9, 2011

Comment 4:

Labels changed: added priority-later, removed priority-medium.

@gopherbot
Copy link
Contributor

Comment 6 by mcphail_colin@hotmail.com:

I'm seeing something very similar with C-compiled code:
/Users/...../pkg/darwin_amd64/cmcp/gcd.a(queue.cgo2.o)(__DATA/__const): unhandled
relocation for _dispatch_queue_attr_concurrent (type 23 rtype 120)

@rsc
Copy link
Contributor

rsc commented Sep 12, 2012

Comment 9:

Labels changed: added go1.1.

@rsc
Copy link
Contributor

rsc commented Dec 10, 2012

Comment 10:

Labels changed: added size-l.

@skelterjohn
Copy link
Contributor

Comment 11:

This seems off to be. My go.wde cocoa implementation
(https://github.com/skelterjohn/go.wde/tree/master/cocoa) makes heavy use of a framework
I wrote using ObjC. I use some straight C code as an intermediary, but there were no
linking problems.

@cookieo9
Copy link
Contributor

cookieo9 commented Jan 6, 2013

Comment 12:

#11: I believe the issue is about using cgo & the go tool to build the ObjC part and
thus the entire package becomes go-gettable (and possibly self-contained), not as your
package does where the user must install an xcode-built framework first.

@rsc
Copy link
Contributor

rsc commented Mar 11, 2013

Comment 13:

We will be fixing this by making gcc do the final link, and then 6l doesn't need to know
about all these terrible details. Getting that working is issue #4069.

Status changed to Duplicate.

Merged into issue #4069.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
@rsc rsc removed their assignment Jun 22, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants