On Thu, Sep 13, 2018 at 7:16 PM,  <amand...@cohesity.com> wrote:
>
> Trying to compile the following on Solaris 10 gives the error: call of
> non-function C.testc
>
> package main
>
> /*
> #include <stdio.h>
>
> void testc() {
>     printf("Hello cgo");
> }
> */
> import "C"
>
> func main() {
>     C.testc()
> }
>
> The output of go env is below:
> bash-4.3$ go env
> GOARCH="sparc"
> GOBIN=""
> GOCACHE="/export/home/amandeep/.cache/go-build"
> GOEXE=""
> GOHOSTARCH="sparc"
> GOHOSTOS="solaris"
> GOOS="solaris"
> GOPATH="/export/home/amandeep/go"
> GORACE=""
> GOROOT="/usr/gnu"
> GOTMPDIR=""
> GOTOOLDIR="/usr/gnu/libexec/gcc/sparc-sun-solaris2.10/8.2.1"
> GCCGO="/usr/gnu/bin/gccgo"
> CC="gcc"
> CXX="g++"
> CGO_ENABLED="1"
> CGO_CFLAGS="-g -O2"
> CGO_CPPFLAGS=""
> CGO_CXXFLAGS="-g -O2"
> CGO_FFLAGS="-g -O2"
> CGO_LDFLAGS="-g -O2"
> PKG_CONFIG="pkg-config"
> GOGCCFLAGS="-fPIC -pthread -fmessage-length=0
> -fdebug-prefix-map=/tmp/go-build622699141=/tmp/go-build
> -gno-record-gcc-switches -funwind-tables"
>
> How can we debug the issue? What am I missing? a simple go file (without
> cgo) compiles and runs just fine. Additionally, this runs just fine on
> Solaris 11 as well.

The cgo tool determines whether testc is a function based in part on
the debug info generated by the C compiler.  It looks like you are
using GCC; what version of GCC are you using?

You can make some progress in debugging this by running `go build -x`
to see exactly how cgo is invoked, then running that invocation and
adding the -debug-gcc option.

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.

Reply via email to