FAQ
Hello,

I found out that by default, an executable that depends on external
libraries, in my case GLFW3 and OpenGL, when built on a certain version of
OS X won't run on a lower version of OS X. An executable built from the
same sources on a lower version of OS X will run on higher versions of OS X
just fine. I don't know what is causing this. I have seen an error:
"Illegal instruction 4" when running a binary compiled on OS X 10.8 on
10.7. Is there a way, compile time flags perhaps, to prevent this from
happening? Ideally one would want to be able to build an application on
whatever OS version that Go supports and have it work out of the box on any
other OS version, as long as the libraries used are compatible?


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

Search Discussions

  • Ian Lance Taylor at Nov 28, 2014 at 4:11 pm

    On Thu, Nov 27, 2014 at 4:12 PM, wrote:
    I found out that by default, an executable that depends on external
    libraries, in my case GLFW3 and OpenGL, when built on a certain version of
    OS X won't run on a lower version of OS X. An executable built from the same
    sources on a lower version of OS X will run on higher versions of OS X just
    fine. I don't know what is causing this. I have seen an error: "Illegal
    instruction 4" when running a binary compiled on OS X 10.8 on 10.7. Is
    there a way, compile time flags perhaps, to prevent this from happening?
    Ideally one would want to be able to build an application on whatever OS
    version that Go supports and have it work out of the box on any other OS
    version, as long as the libraries used are compatible?
    This is typical for all development environments. Backward
    compatibility (building on version X runs on version X + 1) is doable.
    Forward compatility (building on version X + 1 runs on version X) is
    very hard. Forward compatibility essentially requires that version X
    anticipate all the changes in version X + 1.

    Since you say this happens with executables that depend on external
    libraries not written in Go, this is not a Go issue. Perhaps there is
    some external compiler and linker options you can use, via your CC
    setting and via Go's -ldflags=-extldflags= option. Other than that
    there is nothing that Go can do to help.

    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Andrey mirtchovski at Nov 28, 2014 at 4:31 pm
    I have the same issue. I used to solve it by keeping a 10.7 VM just
    for the purpose of compiling using go's 10.6 binaries, but there is a
    better solution -- before you compile export the following:

    $ export MACOSX_DEPLOYMENT_TARGET=10.7
    $ go build

    make sure you have 10.7sdk in the appropriate directory, xcode's
    Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/

    here's how it runs on 10.7 without the above (defaults to 10.8):

    $ ./program_using_cgo
    Segmentation fault: 11

    the crash report states:
    Exception Type: EXC_BAD_ACCESS (SIGSEGV)
    Exception Codes: KERN_PROTECTION_FAILURE at 0x00007fff5fc01028

    cheers, andrey

    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Lars Seipel at Nov 29, 2014 at 3:13 pm

    On Fri, Nov 28, 2014 at 09:31:47AM -0700, andrey mirtchovski wrote:
    $ export MACOSX_DEPLOYMENT_TARGET=10.7
    $ go build

    make sure you have 10.7sdk in the appropriate directory
    There's also the -mmacosx-version-min=10.y flag to the C compiler. As
    far as I can see, using it doesn't require any older SDK installed.
    Seems to work fine on 10.9 with just the xcode command line tools
    installed. Trivial C program no longer crashes with illegal instruction
    when executed on an older Mac running 10.6.

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedNov 28, '14 at 3:43p
activeNov 29, '14 at 3:13p
posts4
users4
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase