Re: [go-nuts] How to link different static libararies on different platforms?

2019-04-03 Thread T L


On Wednesday, April 3, 2019 at 1:00:24 PM UTC-4, Ian Lance Taylor wrote:
>
> On Wed, Apr 3, 2019 at 8:30 AM T L > 
> wrote: 
> > 
> > Assume I have a .go soruce file like: 
> > 
> > /* 
> > #cgo LDFLAGS: -L${SRCDIR}/lib/static/linux/amd64 -lmylib 
> > ... // more flags 
> > */ 
> > import "C" 
> > 
> > ... // many cross-platform Go code lines 
> > 
> > 
> > Now, It compiles ok on Linux AMD64 platform. 
> > 
> > There are several library files under different subfolders of 
> "${SRCDIR}/lib/static". 
> > For example, the Linux-amd64 version is put in the "/linux/amd64" 
> subfolers. 
> > How to let the cgo directives to adaptively select the corresponding 
> static library file on different platforms? 
>
> Use a build tag in your #cgo directive: 
>
> #cgo linux LDFLAGS: 
>
> See the examples at https://golang.org/cmd/cgo. 
>
> Ian 
>

Thanks for the info, 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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] How to link different static libararies on different platforms?

2019-04-03 Thread Ian Lance Taylor
On Wed, Apr 3, 2019 at 8:30 AM T L  wrote:
>
> Assume I have a .go soruce file like:
>
> /*
> #cgo LDFLAGS: -L${SRCDIR}/lib/static/linux/amd64 -lmylib
> ... // more flags
> */
> import "C"
>
> ... // many cross-platform Go code lines
>
>
> Now, It compiles ok on Linux AMD64 platform.
>
> There are several library files under different subfolders of 
> "${SRCDIR}/lib/static".
> For example, the Linux-amd64 version is put in the "/linux/amd64" subfolers.
> How to let the cgo directives to adaptively select the corresponding static 
> library file on different platforms?

Use a build tag in your #cgo directive:

#cgo linux LDFLAGS:

See the examples at https://golang.org/cmd/cgo.

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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] How to link different static libararies on different platforms?

2019-04-03 Thread T L
Assume I have a .go soruce file like:

/*
#cgo LDFLAGS: -L${SRCDIR}/lib/static/linux/amd64 -lmylib
... // more flags
*/
import "C"

... // many cross-platform Go code lines


Now, It compiles ok on Linux AMD64 platform.

There are several library files under different subfolders of 
"${SRCDIR}/lib/static".
For example, the Linux-amd64 version is put in the "/linux/amd64" subfolers.
How to let the cgo directives to adaptively select the corresponding static 
library file on different platforms?

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.