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/link: Creating an archive from an installed package fails #12461

Closed
17twenty opened this issue Sep 3, 2015 · 2 comments
Closed

cmd/link: Creating an archive from an installed package fails #12461

17twenty opened this issue Sep 3, 2015 · 2 comments
Milestone

Comments

@17twenty
Copy link

17twenty commented Sep 3, 2015

Me again testing weird cross-compilation options and think I've found another problem

I have created a package and installed it that contains a few functions, structs and interfaces and have been able to use it successfully when using go build.

I'd like to write a shim package for interfacing with C code and have run up against the following error:

$ go build -v -buildmode=c-archive fli_wrapper.go 
command-line-arguments
# command-line-arguments
/usr/local/go/pkg/tool/linux_386/link: running ar failed: exit status 1
ar: /go.o: No such file or directory

I have my custom package modemmanager built and installed:

ls ../../pkg/linux_386/
github.com/     golang.org/     gopkg.in/       modemmanager.a 

But when I try and build the following I get the previous error:

package main

import (
    mm "modemmanager"
    "log"
    "net"
    "net/rpc/jsonrpc"
)

func GetAvailableModems() {

    log.Println("Getting Modems...")

    // Dial up the remote server
    conn, err := net.Dial("tcp", "localhost:8222")
    if err != nil {
        panic(err)
    }
    defer conn.Close()
    c := jsonrpc.NewClient(conn)

    // Get the available modems
    modems := make([]mm.Modem, 0)
    log.Println("Empty:", modems)

    // calling method on RPC server
    err = c.Call("ModemManager.GetAvailableModems", &modems, &modems)
    if err != nil {
        log.Fatal("error:", err)
    }
    log.Println("Success: ", modems)

}

func main() { }

The modemmanager package consists of simply ~/gopath/src/modemmanager/common.go which defines the package modemmanager.

It makes no difference if I have the package available locally and specify the relative package location. Any ideas on why it can't run ar?

@minux
Copy link
Member

minux commented Sep 3, 2015 via email

@ianlancetaylor ianlancetaylor changed the title Creating an archive from an installed package fails cmd/link: Creating an archive from an installed package fails Sep 3, 2015
@ianlancetaylor ianlancetaylor added this to the Go1.6 milestone Sep 3, 2015
@17twenty
Copy link
Author

17twenty commented Sep 3, 2015

I had a weird path issue and it was picking up the wrong library (one without an import "C" and //export directives) so just user-error in that case.

The only real take-home from this is that the error message makes no reference to the lack of exports/import "C" and gives an AR failure instead. Closing as, well, it's solved.

@17twenty 17twenty closed this as completed Sep 3, 2015
@golang golang locked and limited conversation to collaborators Sep 4, 2016
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

4 participants