FAQ
Hi,

I'm trying to build my package https://github.com/steeve/libtorrent-go
using SWIG.
I've built SWIG from source from today's master, and it runs okay.

However, when I try to build the generated package inside my go program, I
get this:

C source files not allowed when not using cgo: libtorrent_gc.c

Looking at the code in golang, I decide to add import "C" to libtorrent_gc.c
(why SWIG doesn't do it itself is an open question, should it?).

Running the build again, it starts to build okay, but fails at:

../libtorrent-go/libtorrent_gc.c:34:10: fatal error: 'runtime.h' file not
found

If I remove the file, it builds okay, but the program fails to start
because the symbols are not set (this is what this file does)
Here is a quick preview of the file, just in
case: http://pastebin.com/dPVZZL5T

Here is the full output with -x -v: http://pastebin.com/AL2fKWij
Here is the full output when creating
libtorrent-go: http://pastebin.com/EzebdV4t

Also, as I understand it, 5c/6c/8c will be removed at some point. What is
the suggested way of moving forward for these cases?

Thank you!

--
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

  • Steeve Morin at Nov 5, 2014 at 1:41 am
    I've done some more test, and found that if I try to go build the package,
    somehow it's gcc who is executed against the libtorrent_gc.c file, not 6c:

    WORK=/tmp/go-build185137340
    github.com/steeve/libtorrent-go
    mkdir -p $WORK/github.com/steeve/libtorrent-go/_obj/
    mkdir -p $WORK/github.com/steeve/
    cd /Users/steeve/projects/go/src/github.com/steeve/libtorrent-go
    CGO_LDFLAGS="-g" "-O2" /usr/local/go/pkg/tool/linux_amd64/cgo -objdir
    $WORK/github.com/steeve/libtorrent-go/_obj/ -- -I
    $WORK/github.com/steeve/libtorrent-go/_obj/ libtorrent.go
    /usr/local/go/pkg/tool/linux_amd64/6c -F -V -w -trimpath $WORK -I
    $WORK/github.com/steeve/libtorrent-go/_obj/ -I
    /usr/local/go/pkg/linux_amd64 -o
    $WORK/github.com/steeve/libtorrent-go/_obj/_cgo_defun.6 -D GOOS_linux -D
    GOARCH_amd64 $WORK/github.com/steeve/libtorrent-go/_obj/_cgo_defun.c
    gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -print-libgcc-file-name
    gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -I
    $WORK/github.com/steeve/libtorrent-go/_obj/ -g -O2 -o
    $WORK/github.com/steeve/libtorrent-go/_obj/_cgo_main.o -c
    $WORK/github.com/steeve/libtorrent-go/_obj/_cgo_main.c
    gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -I
    $WORK/github.com/steeve/libtorrent-go/_obj/ -g -O2 -o
    $WORK/github.com/steeve/libtorrent-go/_obj/_cgo_export.o -c
    $WORK/github.com/steeve/libtorrent-go/_obj/_cgo_export.c
    gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -I
    $WORK/github.com/steeve/libtorrent-go/_obj/ -g -O2 -o
    $WORK/github.com/steeve/libtorrent-go/_obj/libtorrent.cgo2.o -c
    $WORK/github.com/steeve/libtorrent-go/_obj/libtorrent.cgo2.c
    gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -I
    $WORK/github.com/steeve/libtorrent-go/_obj/ -g -O2 -o
    $WORK/github.com/steeve/libtorrent-go/_obj/libtorrent_gc.o -c
    ./libtorrent_gc.c
    # github.com/steeve/libtorrent-go
    ./libtorrent_gc.c:34:21: fatal error: runtime.h: No such file or directory
    compilation terminated.
    On Wednesday, November 5, 2014 2:20:52 AM UTC+1, Steeve Morin wrote:

    Hi,

    I'm trying to build my package https://github.com/steeve/libtorrent-go
    using SWIG.
    I've built SWIG from source from today's master, and it runs okay.

    However, when I try to build the generated package inside my go program, I
    get this:

    C source files not allowed when not using cgo: libtorrent_gc.c

    Looking at the code in golang, I decide to add import "C" to
    libtorrent_gc.c (why SWIG doesn't do it itself is an open question,
    should it?).

    Running the build again, it starts to build okay, but fails at:

    ../libtorrent-go/libtorrent_gc.c:34:10: fatal error: 'runtime.h' file not
    found

    If I remove the file, it builds okay, but the program fails to start
    because the symbols are not set (this is what this file does)
    Here is a quick preview of the file, just in case:
    http://pastebin.com/dPVZZL5T

    Here is the full output with -x -v: http://pastebin.com/AL2fKWij
    Here is the full output when creating libtorrent-go:
    http://pastebin.com/EzebdV4t

    Also, as I understand it, 5c/6c/8c will be removed at some point. What is
    the suggested way of moving forward for these cases?

    Thank you!
    --
    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.
  • Steeve Morin at Nov 5, 2014 at 2:54 am
    Ok so I've gone further by having go itself invoke SWIG, via a swigcxx file
    (which was not easy since I had a lot of -D on the command line, it would
    be nice if Go could propagate them the way it does for -I).

    The package builds and installs fine, however, I get this when building a
    example program:
    Undefined symbols for architecture x86_64:
       "_x_cgo_free", referenced from:
           __cgo_free in go.o
       "_x_cgo_init", referenced from:
           __cgo_init in go.o
       "_x_cgo_malloc", referenced from:
           __cgo_malloc in go.o
       "_x_cgo_thread_start", referenced from:
           __cgo_thread_start in go.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see
    invocation)

    Am I missing something ?

    Thanks!
    On Wednesday, November 5, 2014 2:41:00 AM UTC+1, Steeve Morin wrote:

    I've done some more test, and found that if I try to go build the package,
    somehow it's gcc who is executed against the libtorrent_gc.c file, not 6c:

    WORK=/tmp/go-build185137340
    github.com/steeve/libtorrent-go
    mkdir -p $WORK/github.com/steeve/libtorrent-go/_obj/
    mkdir -p $WORK/github.com/steeve/
    cd /Users/steeve/projects/go/src/github.com/steeve/libtorrent-go
    CGO_LDFLAGS="-g" "-O2" /usr/local/go/pkg/tool/linux_amd64/cgo -objdir
    $WORK/github.com/steeve/libtorrent-go/_obj/ -- -I $WORK/
    github.com/steeve/libtorrent-go/_obj/ libtorrent.go
    /usr/local/go/pkg/tool/linux_amd64/6c -F -V -w -trimpath $WORK -I $WORK/
    github.com/steeve/libtorrent-go/_obj/ -I /usr/local/go/pkg/linux_amd64 -o
    $WORK/github.com/steeve/libtorrent-go/_obj/_cgo_defun.6 -D GOOS_linux -D
    GOARCH_amd64 $WORK/github.com/steeve/libtorrent-go/_obj/_cgo_defun.c
    gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -print-libgcc-file-name
    gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -I $WORK/
    github.com/steeve/libtorrent-go/_obj/ -g -O2 -o $WORK/
    github.com/steeve/libtorrent-go/_obj/_cgo_main.o -c $WORK/
    github.com/steeve/libtorrent-go/_obj/_cgo_main.c
    gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -I $WORK/
    github.com/steeve/libtorrent-go/_obj/ -g -O2 -o $WORK/
    github.com/steeve/libtorrent-go/_obj/_cgo_export.o -c $WORK/
    github.com/steeve/libtorrent-go/_obj/_cgo_export.c
    gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -I $WORK/
    github.com/steeve/libtorrent-go/_obj/ -g -O2 -o $WORK/
    github.com/steeve/libtorrent-go/_obj/libtorrent.cgo2.o -c $WORK/
    github.com/steeve/libtorrent-go/_obj/libtorrent.cgo2.c
    gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -I $WORK/
    github.com/steeve/libtorrent-go/_obj/ -g -O2 -o $WORK/
    github.com/steeve/libtorrent-go/_obj/libtorrent_gc.o -c ./libtorrent_gc.c
    # github.com/steeve/libtorrent-go
    ./libtorrent_gc.c:34:21: fatal error: runtime.h: No such file or directory
    compilation terminated.
    On Wednesday, November 5, 2014 2:20:52 AM UTC+1, Steeve Morin wrote:

    Hi,

    I'm trying to build my package https://github.com/steeve/libtorrent-go
    using SWIG.
    I've built SWIG from source from today's master, and it runs okay.

    However, when I try to build the generated package inside my go program,
    I get this:

    C source files not allowed when not using cgo: libtorrent_gc.c

    Looking at the code in golang, I decide to add import "C" to
    libtorrent_gc.c (why SWIG doesn't do it itself is an open question,
    should it?).

    Running the build again, it starts to build okay, but fails at:

    ../libtorrent-go/libtorrent_gc.c:34:10: fatal error: 'runtime.h' file not
    found

    If I remove the file, it builds okay, but the program fails to start
    because the symbols are not set (this is what this file does)
    Here is a quick preview of the file, just in case:
    http://pastebin.com/dPVZZL5T

    Here is the full output with -x -v: http://pastebin.com/AL2fKWij
    Here is the full output when creating libtorrent-go:
    http://pastebin.com/EzebdV4t

    Also, as I understand it, 5c/6c/8c will be removed at some point. What is
    the suggested way of moving forward for these cases?

    Thank you!
    --
    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.
  • Steeve Morin at Nov 5, 2014 at 3:15 am
    And also get this when trying to build:

    ld: warning: ignoring file /var/tmp/go-link-78lKPa/000000.o, file was built
    for unsupported file format ( 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00 0x00
    0x00 0x00 0x00 0x00 0x00 0x00 0x00 ) which is not the architecture being
    linked (x86_64): /var/tmp/go-link-78lKPa/000000.o
    ld: warning: ignoring file /var/tmp/go-link-78lKPa/000003.o, file was built
    for unsupported file format ( 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00 0x00
    0x00 0x00 0x00 0x00 0x00 0x00 0x00 ) which is not the architecture being
    linked (x86_64): /var/tmp/go-link-78lKPa/000003.o

    --
    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.
  • Ian Taylor at Nov 5, 2014 at 3:35 am

    On Tue, Nov 4, 2014 at 7:15 PM, Steeve Morin wrote:

    Ok so I've gone further by having go itself invoke SWIG, via a
    swigcxx file (which was not easy since I had a lot of -D on the
    command line, it would be nice if Go could propagate them the way it
    does for -I).
    Using a .swigcxx file is the right approach.


    Undefined symbols for architecture x86_64:
    "_x_cgo_free", referenced from:
    __cgo_free in go.o
    I'm troubled by the leading underscores here. The later message shows
    an ELF file, but ELF doesn't use leading underscores. Darwin does use
    leading underscores, but then why would you have an ELF file?

    A couple of things I didn't see mentioned: what platform are you on,
    and what version of Go are you using?

    And also get this when trying to build:

    ld: warning: ignoring file /var/tmp/go-link-78lKPa/000000.o, file was built
    for unsupported file format ( 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00 0x00
    0x00 0x00 0x00 0x00 0x00 0x00 0x00 ) which is not the architecture being
    linked (x86_64): /var/tmp/go-link-78lKPa/000000.o
    ld: warning: ignoring file /var/tmp/go-link-78lKPa/000003.o, file was built
    for unsupported file format ( 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00 0x00
    0x00 0x00 0x00 0x00 0x00 0x00 0x00 ) which is not the architecture being
    linked (x86_64): /var/tmp/go-link-78lKPa/000003.o
    This is a problem that you need to fix.

    Unfortunately it's a completely useless error message, as it doesn't
    provide enough information to know the architecture. It's a 64-bit
    little-endian ELF file, but it doesn't say the processor.

    Perhaps your default compiler does not generate x86_64 ELF files. Is
    that possible?

    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.
  • Steeve Morin at Nov 5, 2014 at 3:43 am
    I am cross compiling to darwin from a Linux host indeed, so what I get from you is that somewhere $CC or $CXX isn't called? But rather plain old gcc (from the host, that is)?

    Steeve
    On 5 nov. 2014, at 04:35, Ian Taylor wrote:

    On Tue, Nov 4, 2014 at 7:15 PM, Steeve Morin wrote:

    Ok so I've gone further by having go itself invoke SWIG, via a
    swigcxx file (which was not easy since I had a lot of -D on the
    command line, it would be nice if Go could propagate them the way it
    does for -I).
    Using a .swigcxx file is the right approach.


    Undefined symbols for architecture x86_64:
    "_x_cgo_free", referenced from:
    __cgo_free in go.o
    I'm troubled by the leading underscores here. The later message shows
    an ELF file, but ELF doesn't use leading underscores. Darwin does use
    leading underscores, but then why would you have an ELF file?

    A couple of things I didn't see mentioned: what platform are you on,
    and what version of Go are you using?

    And also get this when trying to build:

    ld: warning: ignoring file /var/tmp/go-link-78lKPa/000000.o, file was built
    for unsupported file format ( 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00 0x00
    0x00 0x00 0x00 0x00 0x00 0x00 0x00 ) which is not the architecture being
    linked (x86_64): /var/tmp/go-link-78lKPa/000000.o
    ld: warning: ignoring file /var/tmp/go-link-78lKPa/000003.o, file was built
    for unsupported file format ( 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00 0x00
    0x00 0x00 0x00 0x00 0x00 0x00 0x00 ) which is not the architecture being
    linked (x86_64): /var/tmp/go-link-78lKPa/000003.o
    This is a problem that you need to fix.

    Unfortunately it's a completely useless error message, as it doesn't
    provide enough information to know the architecture. It's a 64-bit
    little-endian ELF file, but it doesn't say the processor.

    Perhaps your default compiler does not generate x86_64 ELF files. Is
    that possible?

    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.
  • Ian Taylor at Nov 5, 2014 at 4:01 am

    On Tue, Nov 4, 2014 at 7:43 PM, Steeve Morin wrote:
    I am cross compiling to darwin from a Linux host indeed, so what I get from you is that somewhere $CC or $CXX isn't called? But rather plain old gcc (from the host, that is)?
    It should indeed call $CC or $CXX in all cases. If you have set those
    environment variables to the cross-compiler you need, then something
    else is happening.

    Can you show us the go build -x output when using the .swigcxx file?

    Ian


    On 5 nov. 2014, at 04:35, Ian Taylor wrote:

    On Tue, Nov 4, 2014 at 7:15 PM, Steeve Morin wrote:

    Ok so I've gone further by having go itself invoke SWIG, via a
    swigcxx file (which was not easy since I had a lot of -D on the
    command line, it would be nice if Go could propagate them the way it
    does for -I).
    Using a .swigcxx file is the right approach.


    Undefined symbols for architecture x86_64:
    "_x_cgo_free", referenced from:
    __cgo_free in go.o
    I'm troubled by the leading underscores here. The later message shows
    an ELF file, but ELF doesn't use leading underscores. Darwin does use
    leading underscores, but then why would you have an ELF file?

    A couple of things I didn't see mentioned: what platform are you on,
    and what version of Go are you using?

    And also get this when trying to build:

    ld: warning: ignoring file /var/tmp/go-link-78lKPa/000000.o, file was built
    for unsupported file format ( 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00 0x00
    0x00 0x00 0x00 0x00 0x00 0x00 0x00 ) which is not the architecture being
    linked (x86_64): /var/tmp/go-link-78lKPa/000000.o
    ld: warning: ignoring file /var/tmp/go-link-78lKPa/000003.o, file was built
    for unsupported file format ( 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00 0x00
    0x00 0x00 0x00 0x00 0x00 0x00 0x00 ) which is not the architecture being
    linked (x86_64): /var/tmp/go-link-78lKPa/000003.o
    This is a problem that you need to fix.

    Unfortunately it's a completely useless error message, as it doesn't
    provide enough information to know the architecture. It's a 64-bit
    little-endian ELF file, but it doesn't say the processor.

    Perhaps your default compiler does not generate x86_64 ELF files. Is
    that possible?

    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.
  • Steeve Morin at Nov 5, 2014 at 12:58 pm
    Hey Ian,

    Thanks for looking into this.

    Here is the full output: https://gist.github.com/steeve/8f9adf78c282bb8ffc2f
    Just in case, please note that I've cut the warning (there's lot of them).

    Also, the weird thing is that if I only have one .go file (libtorrent.go)
    that does the import "C", it doesn't compile saying there's no go file, so
    I need that empty.go one.

    Steeve
    On Wednesday, November 5, 2014 5:01:27 AM UTC+1, Ian Lance Taylor wrote:

    On Tue, Nov 4, 2014 at 7:43 PM, Steeve Morin <steeve...@gmail.com
    <javascript:>> wrote:
    I am cross compiling to darwin from a Linux host indeed, so what I get
    from you is that somewhere $CC or $CXX isn't called? But rather plain old
    gcc (from the host, that is)?

    It should indeed call $CC or $CXX in all cases. If you have set those
    environment variables to the cross-compiler you need, then something
    else is happening.

    Can you show us the go build -x output when using the .swigcxx file?

    Ian


    On 5 nov. 2014, at 04:35, Ian Taylor <ia...@golang.org <javascript:>>
    wrote:
    On Tue, Nov 4, 2014 at 7:15 PM, Steeve Morin <steeve...@gmail.com
    <javascript:>> wrote:
    Ok so I've gone further by having go itself invoke SWIG, via a
    swigcxx file (which was not easy since I had a lot of -D on the
    command line, it would be nice if Go could propagate them the way it
    does for -I).
    Using a .swigcxx file is the right approach.


    Undefined symbols for architecture x86_64:
    "_x_cgo_free", referenced from:
    __cgo_free in go.o
    I'm troubled by the leading underscores here. The later message shows
    an ELF file, but ELF doesn't use leading underscores. Darwin does use
    leading underscores, but then why would you have an ELF file?

    A couple of things I didn't see mentioned: what platform are you on,
    and what version of Go are you using?

    And also get this when trying to build:

    ld: warning: ignoring file /var/tmp/go-link-78lKPa/000000.o, file was
    built
    for unsupported file format ( 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00
    0x00
    0x00 0x00 0x00 0x00 0x00 0x00 0x00 ) which is not the architecture
    being
    linked (x86_64): /var/tmp/go-link-78lKPa/000000.o
    ld: warning: ignoring file /var/tmp/go-link-78lKPa/000003.o, file was
    built
    for unsupported file format ( 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00
    0x00
    0x00 0x00 0x00 0x00 0x00 0x00 0x00 ) which is not the architecture
    being
    linked (x86_64): /var/tmp/go-link-78lKPa/000003.o
    This is a problem that you need to fix.

    Unfortunately it's a completely useless error message, as it doesn't
    provide enough information to know the architecture. It's a 64-bit
    little-endian ELF file, but it doesn't say the processor.

    Perhaps your default compiler does not generate x86_64 ELF files. Is
    that possible?

    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.
  • Steeve Morin at Nov 5, 2014 at 3:13 pm
    I have also ran file on all the .o files generated

    https://gist.github.com/steeve/8f9adf78c282bb8ffc2f#file-files

    They are all Mach-O, as expected.
    On Wednesday, November 5, 2014 1:58:24 PM UTC+1, Steeve Morin wrote:

    Hey Ian,

    Thanks for looking into this.

    Here is the full output:
    https://gist.github.com/steeve/8f9adf78c282bb8ffc2f
    Just in case, please note that I've cut the warning (there's lot of them).

    Also, the weird thing is that if I only have one .go file (libtorrent.go)
    that does the import "C", it doesn't compile saying there's no go file, so
    I need that empty.go one.

    Steeve
    On Wednesday, November 5, 2014 5:01:27 AM UTC+1, Ian Lance Taylor wrote:

    On Tue, Nov 4, 2014 at 7:43 PM, Steeve Morin <steeve...@gmail.com>
    wrote:
    I am cross compiling to darwin from a Linux host indeed, so what I get
    from you is that somewhere $CC or $CXX isn't called? But rather plain old
    gcc (from the host, that is)?

    It should indeed call $CC or $CXX in all cases. If you have set those
    environment variables to the cross-compiler you need, then something
    else is happening.

    Can you show us the go build -x output when using the .swigcxx file?

    Ian


    On 5 nov. 2014, at 04:35, Ian Taylor wrote:

    On Tue, Nov 4, 2014 at 7:15 PM, Steeve Morin <steeve...@gmail.com>
    wrote:
    Ok so I've gone further by having go itself invoke SWIG, via a
    swigcxx file (which was not easy since I had a lot of -D on the
    command line, it would be nice if Go could propagate them the way it
    does for -I).
    Using a .swigcxx file is the right approach.


    Undefined symbols for architecture x86_64:
    "_x_cgo_free", referenced from:
    __cgo_free in go.o
    I'm troubled by the leading underscores here. The later message shows
    an ELF file, but ELF doesn't use leading underscores. Darwin does use
    leading underscores, but then why would you have an ELF file?

    A couple of things I didn't see mentioned: what platform are you on,
    and what version of Go are you using?

    And also get this when trying to build:

    ld: warning: ignoring file /var/tmp/go-link-78lKPa/000000.o, file was
    built
    for unsupported file format ( 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00
    0x00
    0x00 0x00 0x00 0x00 0x00 0x00 0x00 ) which is not the architecture
    being
    linked (x86_64): /var/tmp/go-link-78lKPa/000000.o
    ld: warning: ignoring file /var/tmp/go-link-78lKPa/000003.o, file was
    built
    for unsupported file format ( 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00
    0x00
    0x00 0x00 0x00 0x00 0x00 0x00 0x00 ) which is not the architecture
    being
    linked (x86_64): /var/tmp/go-link-78lKPa/000003.o
    This is a problem that you need to fix.

    Unfortunately it's a completely useless error message, as it doesn't
    provide enough information to know the architecture. It's a 64-bit
    little-endian ELF file, but it doesn't say the processor.

    Perhaps your default compiler does not generate x86_64 ELF files. Is
    that possible?

    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.
  • Steeve Morin at Nov 5, 2014 at 5:11 pm
    Ok so somehow it now works... I must have done something while generating
    the outputs...

    I've also done some patches to SWIG, of which I'm going to open PRs.

    In any case, thank you very much for the help Ian.

    On Wednesday, November 5, 2014 4:13:18 PM UTC+1, Steeve Morin wrote:

    I have also ran file on all the .o files generated

    https://gist.github.com/steeve/8f9adf78c282bb8ffc2f#file-files

    They are all Mach-O, as expected.
    On Wednesday, November 5, 2014 1:58:24 PM UTC+1, Steeve Morin wrote:

    Hey Ian,

    Thanks for looking into this.

    Here is the full output:
    https://gist.github.com/steeve/8f9adf78c282bb8ffc2f
    Just in case, please note that I've cut the warning (there's lot of them).

    Also, the weird thing is that if I only have one .go file (libtorrent.go)
    that does the import "C", it doesn't compile saying there's no go file, so
    I need that empty.go one.

    Steeve
    On Wednesday, November 5, 2014 5:01:27 AM UTC+1, Ian Lance Taylor wrote:

    On Tue, Nov 4, 2014 at 7:43 PM, Steeve Morin <steeve...@gmail.com>
    wrote:
    I am cross compiling to darwin from a Linux host indeed, so what I get
    from you is that somewhere $CC or $CXX isn't called? But rather plain old
    gcc (from the host, that is)?

    It should indeed call $CC or $CXX in all cases. If you have set those
    environment variables to the cross-compiler you need, then something
    else is happening.

    Can you show us the go build -x output when using the .swigcxx file?

    Ian


    On 5 nov. 2014, at 04:35, Ian Taylor wrote:

    On Tue, Nov 4, 2014 at 7:15 PM, Steeve Morin <steeve...@gmail.com>
    wrote:
    Ok so I've gone further by having go itself invoke SWIG, via a
    swigcxx file (which was not easy since I had a lot of -D on the
    command line, it would be nice if Go could propagate them the way it
    does for -I).
    Using a .swigcxx file is the right approach.


    Undefined symbols for architecture x86_64:
    "_x_cgo_free", referenced from:
    __cgo_free in go.o
    I'm troubled by the leading underscores here. The later message
    shows
    an ELF file, but ELF doesn't use leading underscores. Darwin does
    use
    leading underscores, but then why would you have an ELF file?

    A couple of things I didn't see mentioned: what platform are you on,
    and what version of Go are you using?

    And also get this when trying to build:

    ld: warning: ignoring file /var/tmp/go-link-78lKPa/000000.o, file
    was built
    for unsupported file format ( 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01
    0x00 0x00
    0x00 0x00 0x00 0x00 0x00 0x00 0x00 ) which is not the architecture
    being
    linked (x86_64): /var/tmp/go-link-78lKPa/000000.o
    ld: warning: ignoring file /var/tmp/go-link-78lKPa/000003.o, file
    was built
    for unsupported file format ( 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01
    0x00 0x00
    0x00 0x00 0x00 0x00 0x00 0x00 0x00 ) which is not the architecture
    being
    linked (x86_64): /var/tmp/go-link-78lKPa/000003.o
    This is a problem that you need to fix.

    Unfortunately it's a completely useless error message, as it doesn't
    provide enough information to know the architecture. It's a 64-bit
    little-endian ELF file, but it doesn't say the processor.

    Perhaps your default compiler does not generate x86_64 ELF files. Is
    that possible?

    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.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedNov 5, '14 at 1:20a
activeNov 5, '14 at 5:11p
posts10
users2
websitegolang.org

2 users in discussion

Steeve Morin: 8 posts Ian Taylor: 2 posts

People

Translate

site design / logo © 2022 Grokbase