Building golang libraries

365 views
Skip to first unread message

desaia...@gmail.com

unread,
Sep 29, 2017, 12:21:54 AM9/29/17
to golang-nuts
Want to create libraries ( static or dynamic ) so that that I don't want to compile every time when I build my executable

"github.com/everjit/Ion" <--- should not refer to code rather it should refer to build library like .so or .dll ( in windows ) and will provide that to go build command line.

package main

import (
"strings"
}

func main(){
    Ion.Invoke()
}

Please help

Thanks

Ian Lance Taylor

unread,
Sep 29, 2017, 12:25:53 AM9/29/17
to desaia...@gmail.com, golang-nuts
To create static libraries, run `go install`. For example, `go
install github.com/everjit/lon`.

Ian

desaia...@gmail.com

unread,
Sep 29, 2017, 1:03:15 AM9/29/17
to golang-nuts
Thanks Ian

Can you please provide command line to build executable using library 

go build -linkshared main.go 

-linkshared not supported on darwin/amd64


doesn't work


Thanks for the help

Rgds

Ian Lance Taylor

unread,
Sep 29, 2017, 9:47:21 AM9/29/17
to Abhijit Desai, golang-nuts
On Thu, Sep 28, 2017 at 10:02 PM, <desaia...@gmail.com> wrote:
>
> Can you please provide command line to build executable using library
>
> go build -linkshared main.go
>
> -linkshared not supported on darwin/amd64
>
>
> doesn't work

You asked about creating either a static or dynamic library, and I
explained how to create a static library.

You are correct that building a dynamic library is not supported on
Darwin at present. It's only supported on GNU/Linux. It would be
nice if someone looked into that on Darwin. I don't know how hard it
would be.

Ian


> On Friday, September 29, 2017 at 9:55:53 AM UTC+5:30, Ian Lance Taylor
> wrote:
>>
>> On Thu, Sep 28, 2017 at 9:21 PM, <desaia...@gmail.com> wrote:
>> >
>> > Want to create libraries ( static or dynamic ) so that that I don't want
>> > to
>> > compile every time when I build my executable
>> >
>> > "github.com/everjit/Ion" <--- should not refer to code rather it should
>> > refer to build library like .so or .dll ( in windows ) and will provide
>> > that
>> > to go build command line.
>> >
>> > package main
>> >
>> > import (
>> > "github.com/everjit/Ion"
>> > "strings"
>> > }
>> >
>> > func main(){
>> > Ion.Invoke()
>> > }
>> >
>> > Please help
>>
>> To create static libraries, run `go install`. For example, `go
>> install github.com/everjit/lon`.
>>
>> Ian
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

gary.wi...@victoriaplumb.com

unread,
Sep 29, 2017, 10:52:49 AM9/29/17
to golang-nuts
You could try plugins:

desaia...@gmail.com

unread,
Sep 30, 2017, 1:44:20 AM9/30/17
to golang-nuts
yes Ian

Thanks for the help

Can you please provide me for Ubuntu

Thanks,

Abhi

desaia...@gmail.com

unread,
Sep 30, 2017, 2:38:23 AM9/30/17
to golang-nuts
Basically want to distribute my library without code and then client will refer it as a library in his application

Rgds,

Abhi

Ian Lance Taylor

unread,
Oct 1, 2017, 8:07:06 PM10/1/17
to Abhijit Desai, golang-nuts
On Fri, Sep 29, 2017 at 10:43 PM, <desaia...@gmail.com> wrote:
>
> Can you please provide me for Ubuntu

See https://golang.org/cmd/go and https://golang.org/s/execmodes . If
those don't help, please ask a more specific question.

Ian
Reply all
Reply to author
Forward
0 new messages