Does #cgo support linux environment variables?

467 views
Skip to first unread message

Alex Jin

unread,
Jun 20, 2013, 5:49:20 AM6/20/13
to golan...@googlegroups.com
My cgo code needs to call a third-party C library, whose location might vary. I'd like to take a linux environment variable to specify where it is, as below:

// #cgo linux CFLAGS: ${THE_SDK_HOME}/include

Unfortunately, go failed to compile above code.

Does anybody know how to resolve this issue? or I have to use pkg-config?

minux

unread,
Jun 20, 2013, 6:17:34 AM6/20/13
to Alex Jin, golan...@googlegroups.com
On Thu, Jun 20, 2013 at 5:49 PM, Alex Jin <toal...@gmail.com> wrote:

My cgo code needs to call a third-party C library, whose location might vary. I'd like to take a linux environment variable to specify where it is, as below:

// #cgo linux CFLAGS: ${THE_SDK_HOME}/include

Unfortunately, go failed to compile above code.
it is not supported.

Does anybody know how to resolve this issue? or I have to use pkg-config?
another option is setting CGO_CFLAGS and CGO_LDFLAGS environment variables before calling "go build/install".

Alex Jin

unread,
Jun 20, 2013, 6:44:25 AM6/20/13
to golan...@googlegroups.com, Alex Jin
Thanks! it works very well.

在 2013年6月20日星期四UTC+8下午6时17分34秒,minux写道:
Reply all
Reply to author
Forward
0 new messages