Yes, this works for a simple program I have. Now I modified 
the helloworld to use glog as follows:

package main                                                                
   
                                                                            
   
import (                                                                    
   
  "fmt"                                                                    
    
  "github.com/golang/glog"                                                  
   
)                                                                          
    
                                                                            
   
func main() {                                                              
    
  fmt.Println("Hello world....")                                            
   
  glog.Info("Hello world...")                                              
    
}                                                                          
    

But now I get another error from libglog.a:

amandeep@s113ldom1:~/workspace$ go build -gccgoflags=-m64 helloworld.go 
# command-line-arguments
ld: warning: file 
/opt/go_pkgs/pkg/gccgo_solaris_sparc/github.com/golang/libglog.a(_go_.o): 
wrong ELF class: ELFCLASS32
Undefined                       first referenced
 symbol                             in file
github_com_golang_glog..import      $WORK/b001/_pkg_.a(_go_.o)
github_com_golang_glog.Info         $WORK/b001/_pkg_.a(_go_.o)
ld: fatal: symbol referencing errors
collect2: error: ld returned 1 exit status

So, I thought recompiling glog with 64 bit option would help. None of the 
following helped:

sudo GOPATH=/opt/go_pkgs/ CGO_LDFLAGS='-m64' go install
sudo GOPATH=/opt/go_pkgs/ go install -gccgoflags '-m64'
sudo GOPATH=/opt/go_pkgs/ go install -gccgoflags='-m64'

All of these generate the following:

amandeep@s113ldom1:/opt/go_pkgs/src/github.com/golang/glog$ file 
/opt/go_pkgs/pkg/gccgo_solaris_sparc/github.com/golang/libglog.a 
/opt/go_pkgs/pkg/gccgo_solaris_sparc/github.com/golang/libglog.a:      
 current ar archive, 32-bit symbol table

Regards,
Aman

On Thursday, September 27, 2018 at 3:01:12 PM UTC-7, Ian Lance Taylor wrote:
>
> On Thu, Sep 27, 2018 at 2:57 PM, Amandeep Gautam 
> <amandee...@gmail.com <javascript:>> wrote: 
> > Hi, 
> >    I am trying to compile a 64bit executable using gccgo on Solaris 
> 11/10. 
> > Following is what I have tried: 
> > 
> > CGO_LDFLAGS='-m64' go build hello_world.go 
> > GOARCH=sparc64 CGO_LDFLAGS='-m64' go build hello_world.go 
> > 
> > Below is the output of the first command: 
> > 
> > amandeep@s113ldom1:~/workspace$ CGO_LDFLAGS='-m64' go build pqrs.go 
> > # command-line-arguments 
> > ld: warning: file $WORK/b001/_pkg_.a(_go_.o): wrong ELF class: 
> ELFCLASS32 
> > Undefined                       first referenced 
> >  symbol                             in file 
> > main.main 
> > /usr/gnu/lib/gcc/sparc-sun-solaris2.11/8.2.1/../../../sparcv9/libgo.so 
> > __go_init_main 
> > /usr/gnu/lib/gcc/sparc-sun-solaris2.11/8.2.1/../../../sparcv9/libgo.so 
> > ld: fatal: symbol referencing errors 
> > collect2: error: ld returned 1 exit status 
> > 
> > However, I am able to generate 64 bit executable for c++ helloworld 
> using 
> > just gcc, so I am hoping it boils down to passing the right set of 
> flags. 
> > For example: 
> > 
> > amandeep@s113ldom1:~/workspace$ /usr/gnu/bin/gcc -m64 helloworld.c 
> > amandeep@s113ldom1:~/workspace$ file ./a.out 
> > ./a.out:        ELF 64-bit MSB executable SPARCV9 Version 1, dynamically 
> > linked, not stripped, no debugging information available 
> > amandeep@s113ldom1:~/workspace$ file /usr/gnu/bin/gcc 
> > /usr/gnu/bin/gcc:       ELF 32-bit MSB executable SPARC32PLUS Version 1, 
> V8+ 
> > Required, dynamically linked, not stripped 
> > 
> > How would you compile a 64 bit executable for Solaris using gccgo? 
>
> CGO_LDFLAGS only affects your program if it actually uses cgo. 
>
> Does it work to do 
>     go build -gccgoflags=-m64 
> ? 
>

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